1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-02 21:51:50 +02:00

Merge remote-tracking branch 'detsys/detsys-main' into lazy-trees-tmp

This commit is contained in:
Eelco Dolstra 2025-04-23 12:25:28 +02:00
commit a6faa69fc8
109 changed files with 1219 additions and 546 deletions

View file

@ -6,6 +6,6 @@ file=build-hook-ca-floating.nix
enableFeatures "ca-derivations"
CONTENT_ADDRESSED=true
NIX_TESTS_CA_BY_DEFAULT=true
source build-remote.sh

View file

@ -13,7 +13,7 @@ unset NIX_STATE_DIR
function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
EXTRA_SYSTEM_FEATURES=()
if [[ -n "${CONTENT_ADDRESSED-}" ]]; then
if [[ -n "${NIX_TESTS_CA_BY_DEFAULT-}" ]]; then
EXTRA_SYSTEM_FEATURES=("ca-derivations")
fi

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
export NIX_TESTS_CA_BY_DEFAULT=1
cd ..
source derivation-advanced-attributes.sh

View file

@ -8,10 +8,11 @@ suites += {
'name': 'ca',
'deps': [],
'tests': [
'build-cache.sh',
'build-with-garbage-path.sh',
'build.sh',
'build-cache.sh',
'concurrent-builds.sh',
'derivation-advanced-attributes.sh',
'derivation-json.sh',
'duplicate-realisation-in-closure.sh',
'eval-store.sh',

View file

@ -2,6 +2,6 @@
source common.sh
CONTENT_ADDRESSED=true
NIX_TESTS_CA_BY_DEFAULT=true
cd ..
source ./nix-shell.sh

View file

@ -12,11 +12,19 @@ badExitCode=0
store="$TEST_ROOT/store"
if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
drvDir=ia
flags=(--arg contentAddress false)
else
drvDir=ca
flags=(--arg contentAddress true --extra-experimental-features ca-derivations)
fi
for nixFile in derivation/*.nix; do
drvPath=$(env -u NIX_STORE nix-instantiate --store "$store" --pure-eval --expr "$(< "$nixFile")")
drvPath=$(env -u NIX_STORE nix-instantiate --store "$store" --pure-eval "${flags[@]}" --expr "$(< "$nixFile")")
testName=$(basename "$nixFile" .nix)
got="${store}${drvPath}"
expected="derivation/$testName.drv"
expected="derivation/${drvDir}/${testName}.drv"
diffAndAcceptInner "$testName" "$got" "$expected"
done

View file

@ -1,6 +1,24 @@
derivation {
name = "advanced-attributes-defaults";
{ contentAddress }:
let
caArgs =
if contentAddress then
{
__contentAddressed = true;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
}
else
{ };
derivation' = args: derivation (caArgs // args);
system = "my-system";
in
derivation' {
inherit system;
name = "advanced-attributes-defaults";
builder = "/bin/bash";
args = [
"-c"

View file

@ -1,6 +1,24 @@
derivation {
name = "advanced-attributes-structured-attrs-defaults";
{ contentAddress }:
let
caArgs =
if contentAddress then
{
__contentAddressed = true;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
}
else
{ };
derivation' = args: derivation (caArgs // args);
system = "my-system";
in
derivation' {
inherit system;
name = "advanced-attributes-structured-attrs-defaults";
builder = "/bin/bash";
args = [
"-c"

View file

@ -1 +0,0 @@
Derive([("bin","/nix/store/pbzb48v0ycf80jgligcp4n8z0rblna4n-advanced-attributes-structured-attrs-bin","",""),("dev","/nix/store/7xapi8jv7flcz1qq8jhw55ar8ag8hldh-advanced-attributes-structured-attrs-dev","",""),("out","/nix/store/mpq3l1l1qc2yr50q520g08kprprwv79f-advanced-attributes-structured-attrs","","")],[("/nix/store/4xm4wccqsvagz9gjksn24s7rip2fdy7v-foo.drv",["out"]),("/nix/store/plsq5jbr5nhgqwcgb2qxw7jchc09dnl8-bar.drv",["out"])],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__json","{\"__darwinAllowLocalNetworking\":true,\"__impureHostDeps\":[\"/usr/bin/ditto\"],\"__noChroot\":true,\"__sandboxProfile\":\"sandcastle\",\"allowSubstitutes\":false,\"builder\":\"/bin/bash\",\"impureEnvVars\":[\"UNICORN\"],\"name\":\"advanced-attributes-structured-attrs\",\"outputChecks\":{\"bin\":{\"disallowedReferences\":[\"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar\"],\"disallowedRequisites\":[\"/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar\"]},\"dev\":{\"maxClosureSize\":5909,\"maxSize\":789},\"out\":{\"allowedReferences\":[\"/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo\"],\"allowedRequisites\":[\"/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo\"]}},\"outputs\":[\"out\",\"bin\",\"dev\"],\"preferLocalBuild\":true,\"requiredSystemFeatures\":[\"rainbow\",\"uid-range\"],\"system\":\"my-system\"}"),("bin","/nix/store/pbzb48v0ycf80jgligcp4n8z0rblna4n-advanced-attributes-structured-attrs-bin"),("dev","/nix/store/7xapi8jv7flcz1qq8jhw55ar8ag8hldh-advanced-attributes-structured-attrs-dev"),("out","/nix/store/mpq3l1l1qc2yr50q520g08kprprwv79f-advanced-attributes-structured-attrs")])

View file

@ -1,6 +1,21 @@
{ contentAddress }:
let
caArgs =
if contentAddress then
{
__contentAddressed = true;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
}
else
{ };
derivation' = args: derivation (caArgs // args);
system = "my-system";
foo = derivation {
foo = derivation' {
inherit system;
name = "foo";
builder = "/bin/bash";
@ -8,8 +23,13 @@ let
"-c"
"echo foo > $out"
];
outputs = [
"out"
"dev"
];
};
bar = derivation {
bar = derivation' {
inherit system;
name = "bar";
builder = "/bin/bash";
@ -17,9 +37,14 @@ let
"-c"
"echo bar > $out"
];
outputs = [
"out"
"dev"
];
};
in
derivation {
derivation' {
inherit system;
name = "advanced-attributes-structured-attrs";
builder = "/bin/bash";
@ -41,11 +66,11 @@ derivation {
outputChecks = {
out = {
allowedReferences = [ foo ];
allowedRequisites = [ foo ];
allowedRequisites = [ foo.dev ];
};
bin = {
disallowedReferences = [ bar ];
disallowedRequisites = [ bar ];
disallowedRequisites = [ bar.dev ];
};
dev = {
maxSize = 789;

View file

@ -1 +0,0 @@
Derive([("out","/nix/store/33a6fdmn8q9ih9d7npbnrxn2q56a4l8q-advanced-attributes","","")],[("/nix/store/4xm4wccqsvagz9gjksn24s7rip2fdy7v-foo.drv",["out"]),("/nix/store/plsq5jbr5nhgqwcgb2qxw7jchc09dnl8-bar.drv",["out"])],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__darwinAllowLocalNetworking","1"),("__impureHostDeps","/usr/bin/ditto"),("__noChroot","1"),("__sandboxProfile","sandcastle"),("allowSubstitutes",""),("allowedReferences","/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo"),("allowedRequisites","/nix/store/3c08bzb71z4wiag719ipjxr277653ynp-foo"),("builder","/bin/bash"),("disallowedReferences","/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar"),("disallowedRequisites","/nix/store/7rhsm8i393hm1wcsmph782awg1hi2f7x-bar"),("impureEnvVars","UNICORN"),("name","advanced-attributes"),("out","/nix/store/33a6fdmn8q9ih9d7npbnrxn2q56a4l8q-advanced-attributes"),("preferLocalBuild","1"),("requiredSystemFeatures","rainbow uid-range"),("system","my-system")])

View file

@ -1,6 +1,21 @@
{ contentAddress }:
let
caArgs =
if contentAddress then
{
__contentAddressed = true;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
}
else
{ };
derivation' = args: derivation (caArgs // args);
system = "my-system";
foo = derivation {
foo = derivation' {
inherit system;
name = "foo";
builder = "/bin/bash";
@ -8,8 +23,13 @@ let
"-c"
"echo foo > $out"
];
outputs = [
"out"
"dev"
];
};
bar = derivation {
bar = derivation' {
inherit system;
name = "bar";
builder = "/bin/bash";
@ -17,9 +37,14 @@ let
"-c"
"echo bar > $out"
];
outputs = [
"out"
"dev"
];
};
in
derivation {
derivation' {
inherit system;
name = "advanced-attributes";
builder = "/bin/bash";
@ -33,9 +58,9 @@ derivation {
impureEnvVars = [ "UNICORN" ];
__darwinAllowLocalNetworking = true;
allowedReferences = [ foo ];
allowedRequisites = [ foo ];
allowedRequisites = [ foo.dev ];
disallowedReferences = [ bar ];
disallowedRequisites = [ bar ];
disallowedRequisites = [ bar.dev ];
requiredSystemFeatures = [
"rainbow"
"uid-range"

View file

@ -0,0 +1 @@
Derive([("out","","r:sha256","")],[],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("builder","/bin/bash"),("name","advanced-attributes-defaults"),("out","/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9"),("outputHashAlgo","sha256"),("outputHashMode","recursive"),("system","my-system")])

View file

@ -0,0 +1 @@
Derive([("dev","","r:sha256",""),("out","","r:sha256","")],[],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__json","{\"builder\":\"/bin/bash\",\"name\":\"advanced-attributes-structured-attrs-defaults\",\"outputHashAlgo\":\"sha256\",\"outputHashMode\":\"recursive\",\"outputs\":[\"out\",\"dev\"],\"system\":\"my-system\"}"),("dev","/02qcpld1y6xhs5gz9bchpxaw0xdhmsp5dv88lh25r2ss44kh8dxz"),("out","/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9")])

View file

@ -0,0 +1 @@
Derive([("bin","","r:sha256",""),("dev","","r:sha256",""),("out","","r:sha256","")],[("/nix/store/j56sf12rxpcv5swr14vsjn5cwm6bj03h-foo.drv",["dev","out"]),("/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv",["dev","out"])],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__json","{\"__darwinAllowLocalNetworking\":true,\"__impureHostDeps\":[\"/usr/bin/ditto\"],\"__noChroot\":true,\"__sandboxProfile\":\"sandcastle\",\"allowSubstitutes\":false,\"builder\":\"/bin/bash\",\"impureEnvVars\":[\"UNICORN\"],\"name\":\"advanced-attributes-structured-attrs\",\"outputChecks\":{\"bin\":{\"disallowedReferences\":[\"/0nyw57wm2iicnm9rglvjmbci3ikmcp823czdqdzdcgsnnwqps71g\"],\"disallowedRequisites\":[\"/07f301yqyz8c6wf6bbbavb2q39j4n8kmcly1s09xadyhgy6x2wr8\"]},\"dev\":{\"maxClosureSize\":5909,\"maxSize\":789},\"out\":{\"allowedReferences\":[\"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9\"],\"allowedRequisites\":[\"/0nr45p69vn6izw9446wsh9bng9nndhvn19kpsm4n96a5mycw0s4z\"]}},\"outputHashAlgo\":\"sha256\",\"outputHashMode\":\"recursive\",\"outputs\":[\"out\",\"bin\",\"dev\"],\"preferLocalBuild\":true,\"requiredSystemFeatures\":[\"rainbow\",\"uid-range\"],\"system\":\"my-system\"}"),("bin","/04f3da1kmbr67m3gzxikmsl4vjz5zf777sv6m14ahv22r65aac9m"),("dev","/02qcpld1y6xhs5gz9bchpxaw0xdhmsp5dv88lh25r2ss44kh8dxz"),("out","/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9")])

View file

@ -0,0 +1 @@
Derive([("out","","r:sha256","")],[("/nix/store/j56sf12rxpcv5swr14vsjn5cwm6bj03h-foo.drv",["dev","out"]),("/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv",["dev","out"])],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__darwinAllowLocalNetworking","1"),("__impureHostDeps","/usr/bin/ditto"),("__noChroot","1"),("__sandboxProfile","sandcastle"),("allowSubstitutes",""),("allowedReferences","/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"),("allowedRequisites","/0nr45p69vn6izw9446wsh9bng9nndhvn19kpsm4n96a5mycw0s4z"),("builder","/bin/bash"),("disallowedReferences","/0nyw57wm2iicnm9rglvjmbci3ikmcp823czdqdzdcgsnnwqps71g"),("disallowedRequisites","/07f301yqyz8c6wf6bbbavb2q39j4n8kmcly1s09xadyhgy6x2wr8"),("impureEnvVars","UNICORN"),("name","advanced-attributes"),("out","/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9"),("outputHashAlgo","sha256"),("outputHashMode","recursive"),("preferLocalBuild","1"),("requiredSystemFeatures","rainbow uid-range"),("system","my-system")])

View file

@ -0,0 +1 @@
Derive([("bin","/nix/store/qjjj3zrlimpjbkk686m052b3ks9iz2sl-advanced-attributes-structured-attrs-bin","",""),("dev","/nix/store/lpz5grl48v93pdadavyg5is1rqvfdipf-advanced-attributes-structured-attrs-dev","",""),("out","/nix/store/nzvz1bmh1g89a5dkpqcqan0av7q3hgv3-advanced-attributes-structured-attrs","","")],[("/nix/store/afc3vbjbzql750v2lp8gxgaxsajphzih-foo.drv",["dev","out"]),("/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv",["dev","out"])],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__json","{\"__darwinAllowLocalNetworking\":true,\"__impureHostDeps\":[\"/usr/bin/ditto\"],\"__noChroot\":true,\"__sandboxProfile\":\"sandcastle\",\"allowSubstitutes\":false,\"builder\":\"/bin/bash\",\"impureEnvVars\":[\"UNICORN\"],\"name\":\"advanced-attributes-structured-attrs\",\"outputChecks\":{\"bin\":{\"disallowedReferences\":[\"/nix/store/r5cff30838majxk5mp3ip2diffi8vpaj-bar\"],\"disallowedRequisites\":[\"/nix/store/9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev\"]},\"dev\":{\"maxClosureSize\":5909,\"maxSize\":789},\"out\":{\"allowedReferences\":[\"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo\"],\"allowedRequisites\":[\"/nix/store/z0rjzy29v9k5qa4nqpykrbzirj7sd43v-foo-dev\"]}},\"outputs\":[\"out\",\"bin\",\"dev\"],\"preferLocalBuild\":true,\"requiredSystemFeatures\":[\"rainbow\",\"uid-range\"],\"system\":\"my-system\"}"),("bin","/nix/store/qjjj3zrlimpjbkk686m052b3ks9iz2sl-advanced-attributes-structured-attrs-bin"),("dev","/nix/store/lpz5grl48v93pdadavyg5is1rqvfdipf-advanced-attributes-structured-attrs-dev"),("out","/nix/store/nzvz1bmh1g89a5dkpqcqan0av7q3hgv3-advanced-attributes-structured-attrs")])

View file

@ -0,0 +1 @@
Derive([("out","/nix/store/swkj0mrq0cq3dfli95v4am0427mi2hxf-advanced-attributes","","")],[("/nix/store/afc3vbjbzql750v2lp8gxgaxsajphzih-foo.drv",["dev","out"]),("/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv",["dev","out"])],[],"my-system","/bin/bash",["-c","echo hello > $out"],[("__darwinAllowLocalNetworking","1"),("__impureHostDeps","/usr/bin/ditto"),("__noChroot","1"),("__sandboxProfile","sandcastle"),("allowSubstitutes",""),("allowedReferences","/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"),("allowedRequisites","/nix/store/z0rjzy29v9k5qa4nqpykrbzirj7sd43v-foo-dev"),("builder","/bin/bash"),("disallowedReferences","/nix/store/r5cff30838majxk5mp3ip2diffi8vpaj-bar"),("disallowedRequisites","/nix/store/9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev"),("impureEnvVars","UNICORN"),("name","advanced-attributes"),("out","/nix/store/swkj0mrq0cq3dfli95v4am0427mi2hxf-advanced-attributes"),("preferLocalBuild","1"),("requiredSystemFeatures","rainbow uid-range"),("system","my-system")])

View file

@ -28,6 +28,7 @@ suites += {
'commit-lock-file-summary.sh',
'non-flake-inputs.sh',
'relative-paths.sh',
'relative-paths-lockfile.sh',
'symlink-paths.sh',
'debugger.sh',
'source-paths.sh',

View file

@ -0,0 +1,73 @@
#!/usr/bin/env bash
source ./common.sh
requireGit
# Test a "vendored" subflake dependency. This is a relative path flake
# which doesn't reference the root flake and has its own lock file.
#
# This might occur in a monorepo for example. The root flake.lock is
# populated from the dependency's flake.lock.
rootFlake="$TEST_ROOT/flake1"
subflake="$rootFlake/sub"
depFlakeA="$TEST_ROOT/depFlakeA"
depFlakeB="$TEST_ROOT/depFlakeB"
rm -rf "$rootFlake"
mkdir -p "$rootFlake" "$subflake" "$depFlakeA" "$depFlakeB"
cat > "$depFlakeA/flake.nix" <<EOF
{
outputs = { self }: {
x = 11;
};
}
EOF
cat > "$depFlakeB/flake.nix" <<EOF
{
outputs = { self }: {
x = 13;
};
}
EOF
[[ $(nix eval "$depFlakeA#x") = 11 ]]
[[ $(nix eval "$depFlakeB#x") = 13 ]]
cat > "$subflake/flake.nix" <<EOF
{
inputs.dep.url = "path:$depFlakeA";
outputs = { self, dep }: {
inherit (dep) x;
y = self.x - 1;
};
}
EOF
cat > "$rootFlake/flake.nix" <<EOF
{
inputs.sub.url = ./sub;
outputs = { self, sub }: {
x = 2;
y = sub.y / self.x;
};
}
EOF
[[ $(nix eval "$subflake#y") = 10 ]]
[[ $(nix eval "$rootFlake#y") = 5 ]]
nix flake update --flake "path:$subflake" --override-input dep "$depFlakeB"
[[ $(nix eval "path:$subflake#y") = 12 ]]
# Expect that changes to sub/flake.lock are propagated to the root flake.
# FIXME: doesn't work at the moment #7730
[[ $(nix eval "$rootFlake#y") = 6 ]] || true
# This will force refresh flake.lock with changes from sub/flake.lock
nix flake update --flake "$rootFlake"
[[ $(nix eval "$rootFlake#y") = 6 ]]

View file

@ -108,3 +108,24 @@ EOF
[[ $(nix eval "$rootFlake#z") = 90 ]]
fi
# https://github.com/NixOS/nix/pull/10089#discussion_r2041984987
# https://github.com/NixOS/nix/issues/13018
mkdir -p "$TEST_ROOT/issue-13018/example"
(
cd "$TEST_ROOT/issue-13018"
git init
echo '{ outputs = _: { }; }' >flake.nix
cat >example/flake.nix <<EOF
{
inputs.parent.url = ../.;
outputs = { parent, ... }: builtins.seq parent { ok = null; };
}
EOF
git add -N .
cd example
# Important: the error does not trigger for an in-memory lock!
nix flake lock
# would fail:
nix eval .#ok
)

View file

@ -52,7 +52,7 @@ cp "${config_nix}" $flake1Dir/
# Test upgrading from nix-env.
nix-env -f ./user-envs.nix -i foo-1.0
nix profile list | grep -A2 'Name:.*foo' | grep 'Store paths:.*foo-1.0'
nix profile install $flake1Dir -L
nix profile add $flake1Dir -L
nix profile list | grep -A4 'Name:.*flake1' | grep 'Locked flake URL:.*narHash'
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
[ -e $TEST_HOME/.nix-profile/share/man ]
@ -64,12 +64,12 @@ nix profile diff-closures | grep 'env-manifest.nix: ε → ∅'
# Test XDG Base Directories support
export NIX_CONFIG="use-xdg-base-directories = true"
nix profile remove flake1 2>&1 | grep 'removed 1 packages'
nix profile install $flake1Dir
nix profile add $flake1Dir
[[ $($TEST_HOME/.local/state/nix/profile/bin/hello) = "Hello World" ]]
unset NIX_CONFIG
# Test conflicting package install.
nix profile install $flake1Dir 2>&1 | grep "warning: 'flake1' is already installed"
# Test conflicting package add.
nix profile add $flake1Dir 2>&1 | grep "warning: 'flake1' is already added"
# Test upgrading a package.
printf NixOS > $flake1Dir/who
@ -132,16 +132,16 @@ nix profile history | grep 'foo: 1.0 -> ∅'
nix profile diff-closures | grep 'Version 3 -> 4'
# Test installing a non-flake package.
nix profile install --file ./simple.nix ''
nix profile add --file ./simple.nix ''
[[ $(cat $TEST_HOME/.nix-profile/hello) = "Hello World!" ]]
nix profile remove simple 2>&1 | grep 'removed 1 packages'
nix profile install $(nix-build --no-out-link ./simple.nix)
nix profile add $(nix-build --no-out-link ./simple.nix)
[[ $(cat $TEST_HOME/.nix-profile/hello) = "Hello World!" ]]
# Test packages with same name from different sources
mkdir $TEST_ROOT/simple-too
cp ./simple.nix "${config_nix}" simple.builder.sh $TEST_ROOT/simple-too
nix profile install --file $TEST_ROOT/simple-too/simple.nix ''
nix profile add --file $TEST_ROOT/simple-too/simple.nix ''
nix profile list | grep -A4 'Name:.*simple' | grep 'Name:.*simple-1'
nix profile remove simple 2>&1 | grep 'removed 1 packages'
nix profile remove simple-1 2>&1 | grep 'removed 1 packages'
@ -160,13 +160,13 @@ nix profile history | grep "packages.$system.default: 1.0, 1.0-man -> 3.0, 3.0-m
nix profile remove flake1 2>&1 | grep 'removed 1 packages'
printf 4.0 > $flake1Dir/version
printf Utrecht > $flake1Dir/who
nix profile install $flake1Dir
nix profile add $flake1Dir
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello Utrecht" ]]
[[ $(nix path-info --json $(realpath $TEST_HOME/.nix-profile/bin/hello) | jq -r .[].ca) =~ fixed:r:sha256: ]]
# Override the outputs.
nix profile remove simple flake1
nix profile install "$flake1Dir^*"
nix profile add "$flake1Dir^*"
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello Utrecht" ]]
[ -e $TEST_HOME/.nix-profile/share/man ]
[ -e $TEST_HOME/.nix-profile/include ]
@ -179,7 +179,7 @@ nix profile upgrade flake1
[ -e $TEST_HOME/.nix-profile/include ]
nix profile remove flake1 2>&1 | grep 'removed 1 packages'
nix profile install "$flake1Dir^man"
nix profile add "$flake1Dir^man"
(! [ -e $TEST_HOME/.nix-profile/bin/hello ])
[ -e $TEST_HOME/.nix-profile/share/man ]
(! [ -e $TEST_HOME/.nix-profile/include ])
@ -193,9 +193,9 @@ printf World > $flake1Dir/who
cp -r $flake1Dir $flake2Dir
printf World2 > $flake2Dir/who
nix profile install $flake1Dir
nix profile add $flake1Dir
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
expect 1 nix profile install $flake2Dir
expect 1 nix profile add $flake2Dir
diff -u <(
nix --offline profile install $flake2Dir 2>&1 1> /dev/null \
| grep -vE "^warning: " \
@ -214,31 +214,31 @@ error: An existing package already provides the following file:
nix profile remove flake1
The new package can also be installed next to the existing one by assigning a different priority.
The new package can also be added next to the existing one by assigning a different priority.
The conflicting packages have a priority of 5.
To prioritise the new package:
nix profile install path:${flake2Dir}#packages.${system}.default --priority 4
nix profile add path:${flake2Dir}#packages.${system}.default --priority 4
To prioritise the existing package:
nix profile install path:${flake2Dir}#packages.${system}.default --priority 6
nix profile add path:${flake2Dir}#packages.${system}.default --priority 6
EOF
)
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
nix profile install $flake2Dir --priority 100
nix profile add $flake2Dir --priority 100
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
nix profile install $flake2Dir --priority 0
nix profile add $flake2Dir --priority 0
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World2" ]]
# nix profile install $flake1Dir --priority 100
# nix profile add $flake1Dir --priority 100
# [[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
# Ensure that conflicts are handled properly even when the installables aren't
# flake references.
# Regression test for https://github.com/NixOS/nix/issues/8284
clearProfiles
nix profile install $(nix build $flake1Dir --no-link --print-out-paths)
expect 1 nix profile install --impure --expr "(builtins.getFlake ''$flake2Dir'').packages.$system.default"
nix profile add $(nix build $flake1Dir --no-link --print-out-paths)
expect 1 nix profile add --impure --expr "(builtins.getFlake ''$flake2Dir'').packages.$system.default"
# Test upgrading from profile version 2.
clearProfiles

View file

@ -4,7 +4,7 @@ source common.sh
clearStoreIfPossible
if [[ -n ${CONTENT_ADDRESSED:-} ]]; then
if [[ -n ${NIX_TESTS_CA_BY_DEFAULT:-} ]]; then
shellDotNix="$PWD/ca-shell.nix"
else
shellDotNix="$PWD/shell.nix"

View file

@ -162,15 +162,32 @@ foo + baz
# - Modify the flake
# - Re-eval it
# - Check that the result has changed
replResult=$( (
echo "changingThing"
sleep 1 # Leave the repl the time to eval 'foo'
mkfifo repl_fifo
nix repl ./flake < repl_fifo > repl_output 2>&1 &
repl_pid=$!
exec 3>repl_fifo # Open fifo for writing
echo "changingThing" >&3
for i in $(seq 1 1000); do
if grep -q "beforeChange" repl_output; then
break
fi
cat repl_output
sleep 0.1
done
if [[ "$i" -eq 100 ]]; then
echo "Timed out waiting for beforeChange"
exit 1
fi
sed -i 's/beforeChange/afterChange/' flake/flake.nix
echo ":reload"
echo "changingThing"
) | nix repl ./flake)
echo "$replResult" | grepQuiet -s beforeChange
echo "$replResult" | grepQuiet -s afterChange
# Send reload and second command
echo ":reload" >&3
echo "changingThing" >&3
echo "exit" >&3
exec 3>&- # Close fifo
wait $repl_pid # Wait for process to finish
grep -q "afterChange" repl_output
# Test recursive printing and formatting
# Normal output should print attributes in lexicographical order non-recursively