VM tests: Initialize the Nix database with correct NAR hashes/sizes
This commit is contained in:
parent
cc0caac098
commit
5193807750
@ -1,11 +1,13 @@
|
|||||||
# Miscellaneous small tests that don't warrant their own VM run.
|
# Miscellaneous small tests that don't warrant their own VM run.
|
||||||
|
|
||||||
import ./make-test.nix ({ pkgs, ...} : {
|
import ./make-test.nix ({ pkgs, ...} : rec {
|
||||||
name = "misc";
|
name = "misc";
|
||||||
meta = with pkgs.stdenv.lib.maintainers; {
|
meta = with pkgs.stdenv.lib.maintainers; {
|
||||||
maintainers = [ eelco chaoflow ];
|
maintainers = [ eelco chaoflow ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
foo = pkgs.writeText "foo" "Hello World";
|
||||||
|
|
||||||
machine =
|
machine =
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
@ -27,10 +29,17 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||||||
security.sudo = { enable = true; wheelNeedsPassword = false; };
|
security.sudo = { enable = true; wheelNeedsPassword = false; };
|
||||||
boot.kernel.sysctl."vm.swappiness" = 1;
|
boot.kernel.sysctl."vm.swappiness" = 1;
|
||||||
boot.kernelParams = [ "vsyscall=emulate" ];
|
boot.kernelParams = [ "vsyscall=emulate" ];
|
||||||
|
system.extraDependencies = [ foo ];
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript =
|
testScript =
|
||||||
''
|
''
|
||||||
|
subtest "nix-db", sub {
|
||||||
|
my $json = $machine->succeed("nix path-info --json ${foo}");
|
||||||
|
$json =~ /"narHash":"sha256:0afw0d9j1hvwiz066z93jiddc33nxg6i6qyp26vnqyglpyfivlq5"/ or die "narHash not set";
|
||||||
|
$json =~ /"narSize":128/ or die "narSize not set";
|
||||||
|
};
|
||||||
|
|
||||||
subtest "nixos-version", sub {
|
subtest "nixos-version", sub {
|
||||||
$machine->succeed("[ `nixos-version | wc -w` = 2 ]");
|
$machine->succeed("[ `nixos-version | wc -w` = 2 ]");
|
||||||
};
|
};
|
||||||
|
@ -8,12 +8,7 @@
|
|||||||
|
|
||||||
{ rootPaths }:
|
{ rootPaths }:
|
||||||
|
|
||||||
#if builtins.langVersion >= 5 then
|
assert builtins.langVersion >= 5;
|
||||||
# FIXME: it doesn't work on Hydra, failing to find mkdir;
|
|
||||||
# perhaps .attrs.sh clobbers PATH with new nix?
|
|
||||||
if false then
|
|
||||||
|
|
||||||
# Nix >= 1.12: Include NAR hash / size info.
|
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "closure-info";
|
name = "closure-info";
|
||||||
@ -36,23 +31,3 @@ if false then
|
|||||||
jq -r .closure[].path < .attrs.json > $out/store-paths
|
jq -r .closure[].path < .attrs.json > $out/store-paths
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
# Nix < 1.12
|
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
name = "closure-info";
|
|
||||||
|
|
||||||
exportReferencesGraph =
|
|
||||||
map (x: [("closure-" + baseNameOf x) x]) rootPaths;
|
|
||||||
|
|
||||||
buildInputs = [ perl ];
|
|
||||||
|
|
||||||
buildCommand =
|
|
||||||
''
|
|
||||||
mkdir $out
|
|
||||||
printRegistration=1 perl ${pathsFromGraph} closure-* > $out/registration
|
|
||||||
perl ${pathsFromGraph} closure-* > $out/store-paths
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user