forked from lix-project/lix
Add a test for nix run
with CA derivations
This commit is contained in:
parent
f0c0052d4b
commit
f46adb783c
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -82,6 +82,7 @@ perl/Makefile.config
|
||||||
/tests/shell
|
/tests/shell
|
||||||
/tests/shell.drv
|
/tests/shell.drv
|
||||||
/tests/config.nix
|
/tests/config.nix
|
||||||
|
/tests/ca/config.nix
|
||||||
|
|
||||||
# /tests/lang/
|
# /tests/lang/
|
||||||
/tests/lang/*.out
|
/tests/lang/*.out
|
||||||
|
|
1
tests/ca/config.nix.in
Symbolic link
1
tests/ca/config.nix.in
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../config.nix.in
|
|
@ -1,4 +1,11 @@
|
||||||
with import ../config.nix;
|
with import ./config.nix;
|
||||||
|
|
||||||
|
let mkCADerivation = args: mkDerivation ({
|
||||||
|
__contentAddressed = true;
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
} // args);
|
||||||
|
in
|
||||||
|
|
||||||
{ seed ? 0 }:
|
{ seed ? 0 }:
|
||||||
# A simple content-addressed derivation.
|
# A simple content-addressed derivation.
|
||||||
|
@ -14,7 +21,7 @@ rec {
|
||||||
echo "Hello World" > $out/hello
|
echo "Hello World" > $out/hello
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
rootCA = mkDerivation {
|
rootCA = mkCADerivation {
|
||||||
name = "rootCA";
|
name = "rootCA";
|
||||||
outputs = [ "out" "dev" "foo"];
|
outputs = [ "out" "dev" "foo"];
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
|
@ -27,11 +34,8 @@ rec {
|
||||||
ln -s $out $dev
|
ln -s $out $dev
|
||||||
ln -s $out $foo
|
ln -s $out $foo
|
||||||
'';
|
'';
|
||||||
__contentAddressed = true;
|
|
||||||
outputHashMode = "recursive";
|
|
||||||
outputHashAlgo = "sha256";
|
|
||||||
};
|
};
|
||||||
dependentCA = mkDerivation {
|
dependentCA = mkCADerivation {
|
||||||
name = "dependent";
|
name = "dependent";
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
echo "building a dependent derivation"
|
echo "building a dependent derivation"
|
||||||
|
@ -39,20 +43,14 @@ rec {
|
||||||
cat ${rootCA}/self/dep
|
cat ${rootCA}/self/dep
|
||||||
echo ${rootCA}/self/dep > $out/dep
|
echo ${rootCA}/self/dep > $out/dep
|
||||||
'';
|
'';
|
||||||
__contentAddressed = true;
|
|
||||||
outputHashMode = "recursive";
|
|
||||||
outputHashAlgo = "sha256";
|
|
||||||
};
|
};
|
||||||
transitivelyDependentCA = mkDerivation {
|
transitivelyDependentCA = mkCADerivation {
|
||||||
name = "transitively-dependent";
|
name = "transitively-dependent";
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
echo "building transitively-dependent"
|
echo "building transitively-dependent"
|
||||||
cat ${dependentCA}/dep
|
cat ${dependentCA}/dep
|
||||||
echo ${dependentCA} > $out
|
echo ${dependentCA} > $out
|
||||||
'';
|
'';
|
||||||
__contentAddressed = true;
|
|
||||||
outputHashMode = "recursive";
|
|
||||||
outputHashAlgo = "sha256";
|
|
||||||
};
|
};
|
||||||
dependentNonCA = mkDerivation {
|
dependentNonCA = mkDerivation {
|
||||||
name = "dependent-non-ca";
|
name = "dependent-non-ca";
|
||||||
|
@ -72,6 +70,14 @@ rec {
|
||||||
cat ${dependentCA}/dep
|
cat ${dependentCA}/dep
|
||||||
echo foo > $out
|
echo foo > $out
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
runnable = mkCADerivation rec {
|
||||||
|
name = "runnable-thing";
|
||||||
|
buildCommand = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
echo ${rootCA} # Just to make it depend on it
|
||||||
|
echo "" > $out/bin/${name}
|
||||||
|
chmod +x $out/bin/${name}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
3
tests/ca/flake.nix
Normal file
3
tests/ca/flake.nix
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
outputs = { self }: import ./content-addressed.nix {};
|
||||||
|
}
|
9
tests/ca/nix-run.sh
Executable file
9
tests/ca/nix-run.sh
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
sed -i 's/experimental-features .*/& ca-derivations ca-references nix-command flakes/' "$NIX_CONF_DIR"/nix.conf
|
||||||
|
|
||||||
|
FLAKE_PATH=path:$PWD
|
||||||
|
|
||||||
|
nix run --no-write-lock-file $FLAKE_PATH#runnable
|
|
@ -46,6 +46,7 @@ nix_tests = \
|
||||||
ca/build.sh \
|
ca/build.sh \
|
||||||
ca/substitute.sh \
|
ca/substitute.sh \
|
||||||
ca/signatures.sh \
|
ca/signatures.sh \
|
||||||
|
ca/nix-run.sh \
|
||||||
ca/nix-copy.sh
|
ca/nix-copy.sh
|
||||||
# parallel.sh
|
# parallel.sh
|
||||||
|
|
||||||
|
@ -53,6 +54,6 @@ install-tests += $(foreach x, $(nix_tests), tests/$(x))
|
||||||
|
|
||||||
tests-environment = NIX_REMOTE= $(bash) -e
|
tests-environment = NIX_REMOTE= $(bash) -e
|
||||||
|
|
||||||
clean-files += $(d)/common.sh $(d)/config.nix
|
clean-files += $(d)/common.sh $(d)/config.nix $(d)/ca/config.nix
|
||||||
|
|
||||||
test-deps += tests/common.sh tests/config.nix tests/plugins/libplugintest.$(SO_EXT)
|
test-deps += tests/common.sh tests/config.nix tests/ca/config.nix tests/plugins/libplugintest.$(SO_EXT)
|
||||||
|
|
Loading…
Reference in a new issue