mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
mkBinaryCache: fix nixos/tests/binary-cache.nix
This commit is contained in:
parent
16dab34ee2
commit
6b261ea59d
1 changed files with 26 additions and 8 deletions
|
@ -9,18 +9,37 @@ import ./make-test-python.nix (
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
imports = [ ../modules/installer/cd-dvd/channel.nix ];
|
imports = [ ../modules/installer/cd-dvd/channel.nix ];
|
||||||
environment.systemPackages = [ pkgs.python3 ];
|
environment.systemPackages = with pkgs; [
|
||||||
system.extraDependencies = [ pkgs.hello.inputDerivation ];
|
openssl
|
||||||
|
python3
|
||||||
|
];
|
||||||
|
|
||||||
|
# We encrypt the binary cache before putting it on the machine so Nix
|
||||||
|
# doesn't bring any references along.
|
||||||
|
environment.etc."binary-cache.tar.gz.encrypted".source =
|
||||||
|
with pkgs;
|
||||||
|
runCommand "binary-cache.tar.gz.encrypted"
|
||||||
|
{
|
||||||
|
allowReferences = [ ];
|
||||||
|
nativeBuildInputs = [ openssl ];
|
||||||
|
}
|
||||||
|
''
|
||||||
|
tar -czf tmp.tar.gz -C "${mkBinaryCache { rootPaths = [ hello ]; }}" .
|
||||||
|
openssl enc -aes-256-cbc -salt -in tmp.tar.gz -out $out -k mysecretpassword
|
||||||
|
'';
|
||||||
|
|
||||||
nix.extraOptions = ''
|
nix.extraOptions = ''
|
||||||
experimental-features = nix-command
|
experimental-features = nix-command
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
# Build the cache, then remove it from the store
|
# Decrypt the cache into /tmp/binary-cache.tar.gz
|
||||||
cachePath = machine.succeed("nix-build --no-out-link -E 'with import <nixpkgs> {}; mkBinaryCache { rootPaths = [hello]; }'").strip()
|
machine.succeed("openssl enc -d -aes-256-cbc -in /etc/binary-cache.tar.gz.encrypted -out /tmp/binary-cache.tar.gz -k mysecretpassword")
|
||||||
machine.succeed("cp -r %s/. /tmp/cache" % cachePath)
|
|
||||||
machine.succeed("nix-store --delete " + cachePath)
|
# Untar the cache into /tmp/cache
|
||||||
|
machine.succeed("mkdir /tmp/cache")
|
||||||
|
machine.succeed("tar -C /tmp/cache -xf /tmp/binary-cache.tar.gz")
|
||||||
|
|
||||||
# Sanity test of cache structure
|
# Sanity test of cache structure
|
||||||
status, stdout = machine.execute("ls /tmp/cache")
|
status, stdout = machine.execute("ls /tmp/cache")
|
||||||
|
@ -42,8 +61,7 @@ import ./make-test-python.nix (
|
||||||
if not match: raise Exception("Couldn't find hello store path in cache")
|
if not match: raise Exception("Couldn't find hello store path in cache")
|
||||||
storePath = match[1]
|
storePath = match[1]
|
||||||
|
|
||||||
# Delete the store path
|
# Make sure the store path doesn't exist yet
|
||||||
machine.succeed("nix-store --delete " + storePath)
|
|
||||||
machine.succeed("[ ! -d %s ] || exit 1" % storePath)
|
machine.succeed("[ ! -d %s ] || exit 1" % storePath)
|
||||||
|
|
||||||
# Should be able to build hello using the cache
|
# Should be able to build hello using the cache
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue