aboutsummaryrefslogtreecommitdiff
path: root/tests/flake-local-settings.sh
blob: 98ad60174cde25074dffac35a62c2308b70bc5f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
source common.sh

clearStore
rm -rf $TEST_HOME/.cache $TEST_HOME/.config $TEST_HOME/.local

cp ./simple.nix ./simple.builder.sh ./config.nix $TEST_HOME

cd $TEST_HOME

rm -f post-hook-ran
cat <<EOF > echoing-post-hook.sh
#!/bin/sh

echo "ThePostHookRan" > $PWD/post-hook-ran
EOF
chmod +x echoing-post-hook.sh

cat <<EOF > flake.nix
{
    nixConfig.post-build-hook = "$PWD/echoing-post-hook.sh";
    nixConfig.allow-dirty = false; # See #5621

    outputs = a: {
       defaultPackage.$system = import ./simple.nix;
    };
}
EOF

# Without --accept-flake-config, the post hook should not run.
nix build < /dev/null
(! [[ -f post-hook-ran ]])
clearStore

nix build --accept-flake-config
test -f post-hook-ran || fail "The post hook should have ran"