lib/tests: Add test case for imports from derivations
This commit is contained in:
parent
e0ea5f4d9b
commit
2955e6bd26
2 changed files with 21 additions and 1 deletions
|
@ -12,7 +12,7 @@ evalConfig() {
|
|||
local attr=$1
|
||||
shift;
|
||||
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() {
|
||||
|
@ -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}
|
||||
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
|
||||
====== module tests ======
|
||||
$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