mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-29 08:30:21 +02:00
Fix store imports from NixOS modules (#77416)
Fix store imports from NixOS modules
This commit is contained in:
commit
91da4b3c5d
|
@ -151,8 +151,8 @@ rec {
|
||||||
filterModules = modulesPath: { disabled, modules }:
|
filterModules = modulesPath: { disabled, modules }:
|
||||||
let
|
let
|
||||||
moduleKey = m: if isString m then toString modulesPath + "/" + m else toString m;
|
moduleKey = m: if isString m then toString modulesPath + "/" + m else toString m;
|
||||||
disabledKeys = listToAttrs (map (k: nameValuePair (moduleKey k) null) disabled);
|
disabledKeys = map moduleKey disabled;
|
||||||
keyFilter = filter (attrs: ! disabledKeys ? ${attrs.key});
|
keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
|
||||||
in map (attrs: attrs.module) (builtins.genericClosure {
|
in map (attrs: attrs.module) (builtins.genericClosure {
|
||||||
startSet = keyFilter modules;
|
startSet = keyFilter modules;
|
||||||
operator = attrs: keyFilter attrs.modules;
|
operator = attrs: keyFilter attrs.modules;
|
||||||
|
|
|
@ -12,7 +12,7 @@ evalConfig() {
|
||||||
local attr=$1
|
local attr=$1
|
||||||
shift;
|
shift;
|
||||||
local script="import ./default.nix { modules = [ $@ ];}"
|
local script="import ./default.nix { modules = [ $@ ];}"
|
||||||
nix-instantiate --timeout 1 -E "$script" -A "$attr" --eval-only --show-trace
|
nix-instantiate --timeout 1 -E "$script" -A "$attr" --eval-only --show-trace --read-write-mode
|
||||||
}
|
}
|
||||||
|
|
||||||
reportFailure() {
|
reportFailure() {
|
||||||
|
@ -183,6 +183,9 @@ checkConfigOutput "true" config.enable ./disable-recursive/{main.nix,disable-foo
|
||||||
checkConfigOutput "true" config.enable ./disable-recursive/{main.nix,disable-bar.nix}
|
checkConfigOutput "true" config.enable ./disable-recursive/{main.nix,disable-bar.nix}
|
||||||
checkConfigError 'The option .* defined in .* does not exist' config.enable ./disable-recursive/{main.nix,disable-foo.nix,disable-bar.nix}
|
checkConfigError 'The option .* defined in .* does not exist' config.enable ./disable-recursive/{main.nix,disable-foo.nix,disable-bar.nix}
|
||||||
|
|
||||||
|
# Check that imports can depend on derivations
|
||||||
|
checkConfigOutput "true" config.enable ./import-from-store.nix
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
====== module tests ======
|
====== module tests ======
|
||||||
$pass Pass
|
$pass Pass
|
||||||
|
|
17
lib/tests/modules/import-from-store.nix
Normal file
17
lib/tests/modules/import-from-store.nix
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
drv = derivation {
|
||||||
|
name = "derivation";
|
||||||
|
system = builtins.currentSystem;
|
||||||
|
builder = "/bin/sh";
|
||||||
|
args = [ "-c" "echo {} > $out" ];
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
"${drv}"
|
||||||
|
./declare-enable.nix
|
||||||
|
./define-enable.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue