nixos/etc: make re-mounting /etc overlay idempotent
This commit is contained in:
parent
1e1efbcf8c
commit
5df8caced4
3 changed files with 25 additions and 11 deletions
|
@ -238,7 +238,9 @@ in
|
|||
# this should not run because /etc is mounted via a systemd mount unit
|
||||
# instead. To a large extent this mimics what composefs does. Because
|
||||
# it's relatively simple, however, we avoid the composefs dependency.
|
||||
if [[ ! $IN_NIXOS_SYSTEMD_STAGE1 ]]; then
|
||||
# Since this script is not idempotent, it should not run when etc hasn't
|
||||
# changed.
|
||||
if [[ ! $IN_NIXOS_SYSTEMD_STAGE1 ]] && [[ "${config.system.build.etc}/etc" != "$(readlink -f /run/current-system/etc)" ]]; then
|
||||
echo "remounting /etc..."
|
||||
|
||||
tmpMetadataMount=$(mktemp --directory)
|
||||
|
|
|
@ -20,11 +20,17 @@
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
machine.succeed("findmnt --kernel --type overlay /etc")
|
||||
machine.fail("stat /etc/newgen")
|
||||
with subtest("/etc is mounted as an overlay"):
|
||||
machine.succeed("findmnt --kernel --type overlay /etc")
|
||||
|
||||
machine.succeed("/run/current-system/specialisation/new-generation/bin/switch-to-configuration switch")
|
||||
with subtest("switching to the same generation"):
|
||||
machine.succeed("/run/current-system/bin/switch-to-configuration test")
|
||||
|
||||
assert machine.succeed("cat /etc/newgen") == "newgen"
|
||||
with subtest("switching to a new generation"):
|
||||
machine.fail("stat /etc/newgen")
|
||||
|
||||
machine.succeed("/run/current-system/specialisation/new-generation/bin/switch-to-configuration switch")
|
||||
|
||||
assert machine.succeed("cat /etc/newgen") == "newgen"
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -18,13 +18,19 @@
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
machine.succeed("findmnt --kernel --type overlay /etc")
|
||||
machine.fail("stat /etc/newgen")
|
||||
machine.succeed("echo -n 'mutable' > /etc/mutable")
|
||||
with subtest("/etc is mounted as an overlay"):
|
||||
machine.succeed("findmnt --kernel --type overlay /etc")
|
||||
|
||||
machine.succeed("/run/current-system/specialisation/new-generation/bin/switch-to-configuration switch")
|
||||
with subtest("switching to the same generation"):
|
||||
machine.succeed("/run/current-system/bin/switch-to-configuration test")
|
||||
|
||||
assert machine.succeed("cat /etc/newgen") == "newgen"
|
||||
assert machine.succeed("cat /etc/mutable") == "mutable"
|
||||
with subtest("switching to a new generation"):
|
||||
machine.fail("stat /etc/newgen")
|
||||
machine.succeed("echo -n 'mutable' > /etc/mutable")
|
||||
|
||||
machine.succeed("/run/current-system/specialisation/new-generation/bin/switch-to-configuration switch")
|
||||
|
||||
assert machine.succeed("cat /etc/newgen") == "newgen"
|
||||
assert machine.succeed("cat /etc/mutable") == "mutable"
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue