1
0
mirror of https://github.com/nix-community/home-manager synced 2024-07-01 19:08:33 +02:00
home-manager/tests/stubs.nix

78 lines
1.9 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
let
stubType = types.submodule ({ name, ... }: {
options = {
name = mkOption {
type = types.str;
default = "dummy";
description = "The stub package name.";
};
outPath = mkOption {
type = types.nullOr types.str;
default = "@${name}@";
[23.05] backport #4066 (#4083) * tests: `--show-trace` in CI (#4070) (cherry picked from commit f889ec0ec366e3ad8fb94e3afa7a31f3ee1da3b9) * tests/stubs: inherit default versions from pkgs (#4069) * tests/stubs: inherit default versions from pkgs * tests/browserpass: temporarily disable on darwin The package currently fails to evaluate on darwin due to a nixpkgs problem: https://github.com/NixOS/nixpkgs/pull/236258#issuecomment-1583450593 (cherry picked from commit 69bdd6de50df2082901d94dbf70ecb762d8b636c) * Espanso: Fix broken module to be compatible with Espanso version 2.x (#4066) * Fix espanso module to work with 2.x version * espanso: fix espanso module This module is currently broken. It does not create `config` and `match` folders which are required by espanso 2.x version. This PR fixed this issue and support creating multiple files under `config` and `match` folder. * Espanso: fix espanso module This module is currently broken. It does not create `config` and `match` folders which are required by espanso 2.x version. This PR fixed this issue and support creating multiple files under `config` and `match` folder. Add descriptions * Add versionAtLeast and mkRemovedOptionModule * Correct maintainers list * remove config key from example * format basic-configuration.nix * Update modules/services/espanso.nix Co-authored-by: Naïm Favier <n@monade.li> * fix maintainers list --------- Co-authored-by: Naïm Favier <n@monade.li> (cherry picked from commit 1e5d741ea3f3290d7ac06a02ded24bfdc7aadb37) --------- Co-authored-by: Li Yang <71299093+liyangau@users.noreply.github.com>
2023-06-12 17:05:45 +02:00
defaultText = literalExpression ''"@''${name}@"'';
};
version = mkOption {
type = types.nullOr types.str;
default = null;
[23.05] backport #4066 (#4083) * tests: `--show-trace` in CI (#4070) (cherry picked from commit f889ec0ec366e3ad8fb94e3afa7a31f3ee1da3b9) * tests/stubs: inherit default versions from pkgs (#4069) * tests/stubs: inherit default versions from pkgs * tests/browserpass: temporarily disable on darwin The package currently fails to evaluate on darwin due to a nixpkgs problem: https://github.com/NixOS/nixpkgs/pull/236258#issuecomment-1583450593 (cherry picked from commit 69bdd6de50df2082901d94dbf70ecb762d8b636c) * Espanso: Fix broken module to be compatible with Espanso version 2.x (#4066) * Fix espanso module to work with 2.x version * espanso: fix espanso module This module is currently broken. It does not create `config` and `match` folders which are required by espanso 2.x version. This PR fixed this issue and support creating multiple files under `config` and `match` folder. * Espanso: fix espanso module This module is currently broken. It does not create `config` and `match` folders which are required by espanso 2.x version. This PR fixed this issue and support creating multiple files under `config` and `match` folder. Add descriptions * Add versionAtLeast and mkRemovedOptionModule * Correct maintainers list * remove config key from example * format basic-configuration.nix * Update modules/services/espanso.nix Co-authored-by: Naïm Favier <n@monade.li> * fix maintainers list --------- Co-authored-by: Naïm Favier <n@monade.li> (cherry picked from commit 1e5d741ea3f3290d7ac06a02ded24bfdc7aadb37) --------- Co-authored-by: Li Yang <71299093+liyangau@users.noreply.github.com>
2023-06-12 17:05:45 +02:00
defaultText = literalExpression "pkgs.\${name}.version or null";
};
buildScript = mkOption {
type = types.str;
default = defaultBuildScript;
};
};
});
defaultBuildScript = "mkdir $out";
dummyPackage = pkgs.runCommandLocal "dummy" { } defaultBuildScript;
mkStubPackage = { name ? "dummy", outPath ? null, version ? null
, buildScript ? defaultBuildScript }:
let
pkg = if name == "dummy" && buildScript == defaultBuildScript then
dummyPackage
else
2022-08-07 14:03:37 +02:00
pkgs.runCommandLocal name { pname = name; } buildScript;
in pkg // optionalAttrs (outPath != null) {
inherit outPath;
# Prevent getOutput from descending into outputs
outputSpecified = true;
# Allow the original package to be used in derivation inputs
__spliced = {
buildHost = pkg;
hostTarget = pkg;
};
} // optionalAttrs (version != null) { inherit version; };
in {
options.test.stubs = mkOption {
type = types.attrsOf stubType;
default = { };
description =
"Package attributes that should be replaced by a stub package.";
};
config = {
lib.test.mkStubPackage = mkStubPackage;
[23.05] backport #4066 (#4083) * tests: `--show-trace` in CI (#4070) (cherry picked from commit f889ec0ec366e3ad8fb94e3afa7a31f3ee1da3b9) * tests/stubs: inherit default versions from pkgs (#4069) * tests/stubs: inherit default versions from pkgs * tests/browserpass: temporarily disable on darwin The package currently fails to evaluate on darwin due to a nixpkgs problem: https://github.com/NixOS/nixpkgs/pull/236258#issuecomment-1583450593 (cherry picked from commit 69bdd6de50df2082901d94dbf70ecb762d8b636c) * Espanso: Fix broken module to be compatible with Espanso version 2.x (#4066) * Fix espanso module to work with 2.x version * espanso: fix espanso module This module is currently broken. It does not create `config` and `match` folders which are required by espanso 2.x version. This PR fixed this issue and support creating multiple files under `config` and `match` folder. * Espanso: fix espanso module This module is currently broken. It does not create `config` and `match` folders which are required by espanso 2.x version. This PR fixed this issue and support creating multiple files under `config` and `match` folder. Add descriptions * Add versionAtLeast and mkRemovedOptionModule * Correct maintainers list * remove config key from example * format basic-configuration.nix * Update modules/services/espanso.nix Co-authored-by: Naïm Favier <n@monade.li> * fix maintainers list --------- Co-authored-by: Naïm Favier <n@monade.li> (cherry picked from commit 1e5d741ea3f3290d7ac06a02ded24bfdc7aadb37) --------- Co-authored-by: Li Yang <71299093+liyangau@users.noreply.github.com>
2023-06-12 17:05:45 +02:00
nixpkgs.overlays = mkIf (config.test.stubs != { }) [
(self: super:
mapAttrs (n: v:
mkStubPackage (v // optionalAttrs (v.version == null) {
version = super.${n}.version or null;
})) config.test.stubs)
];
};
}