mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-15 14:26:33 +01:00
6abbe725ca
The activation script that remounts the /etc overlay now handles other mount points on top of /etc by bind mounting them to the new temporary /etc overlay and then atomically revealing it.
49 lines
1.6 KiB
Nix
49 lines
1.6 KiB
Nix
{ lib, ... }: {
|
|
|
|
name = "activation-etc-overlay-mutable";
|
|
|
|
meta.maintainers = with lib.maintainers; [ nikstur ];
|
|
|
|
nodes.machine = { pkgs, ... }: {
|
|
system.etc.overlay.enable = true;
|
|
system.etc.overlay.mutable = true;
|
|
|
|
# Prerequisites
|
|
boot.initrd.systemd.enable = true;
|
|
boot.kernelPackages = pkgs.linuxPackages_latest;
|
|
|
|
specialisation.new-generation.configuration = {
|
|
environment.etc."newgen".text = "newgen";
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
with subtest("/etc is mounted as an overlay"):
|
|
machine.succeed("findmnt --kernel --type overlay /etc")
|
|
|
|
with subtest("switching to the same generation"):
|
|
machine.succeed("/run/current-system/bin/switch-to-configuration test")
|
|
|
|
with subtest("switching to a new generation"):
|
|
machine.fail("stat /etc/newgen")
|
|
machine.succeed("echo -n 'mutable' > /etc/mutable")
|
|
|
|
# Directory
|
|
machine.succeed("mkdir /etc/mountpoint")
|
|
machine.succeed("mount -t tmpfs tmpfs /etc/mountpoint")
|
|
machine.succeed("touch /etc/mountpoint/extra-file")
|
|
|
|
# File
|
|
machine.succeed("touch /etc/filemount")
|
|
machine.succeed("mount --bind /dev/null /etc/filemount")
|
|
|
|
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"
|
|
|
|
print(machine.succeed("findmnt /etc/mountpoint"))
|
|
print(machine.succeed("stat /etc/mountpoint/extra-file"))
|
|
print(machine.succeed("findmnt /etc/filemount"))
|
|
'';
|
|
}
|