mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-14 13:39:15 +03:00
nixos/stc: Improve mount unit handling
We should sometimes restart the units rather than reloading them so the changes are actually applied. / and /nix are explicitly excluded because there was some very old issue where these were unmounted. I don't think this will affect many people since most people use fstab mounts instead but I plan to adapt this behavior for fstab mounts as well in the future (once I wrote a test for the fstab thingies).
This commit is contained in:
parent
37b8244412
commit
eb831f759b
3 changed files with 51 additions and 9 deletions
|
@ -450,7 +450,7 @@ in {
|
|||
];
|
||||
};
|
||||
|
||||
mountModified.configuration = {
|
||||
mountOptionsModified.configuration = {
|
||||
systemd.mounts = [
|
||||
{
|
||||
description = "Testmount";
|
||||
|
@ -463,6 +463,19 @@ in {
|
|||
];
|
||||
};
|
||||
|
||||
mountModified.configuration = {
|
||||
systemd.mounts = [
|
||||
{
|
||||
description = "Testmount";
|
||||
what = "ramfs";
|
||||
type = "ramfs";
|
||||
where = "/testmount";
|
||||
options = "size=10M";
|
||||
wantedBy = [ "local-fs.target" ];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
timer.configuration = {
|
||||
systemd.timers.test-timer = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
|
@ -1137,7 +1150,8 @@ in {
|
|||
switch_to_specialisation("${machine}", "mount")
|
||||
out = machine.succeed("mount | grep 'on /testmount'")
|
||||
assert_contains(out, "size=1024k")
|
||||
out = switch_to_specialisation("${machine}", "mountModified")
|
||||
# Changing options reloads the unit
|
||||
out = switch_to_specialisation("${machine}", "mountOptionsModified")
|
||||
assert_lacks(out, "stopping the following units:")
|
||||
assert_lacks(out, "NOT restarting the following changed units:")
|
||||
assert_contains(out, "reloading the following units: testmount.mount\n")
|
||||
|
@ -1147,6 +1161,17 @@ in {
|
|||
# It changed
|
||||
out = machine.succeed("mount | grep 'on /testmount'")
|
||||
assert_contains(out, "size=10240k")
|
||||
# Changing anything but `Options=` restarts the unit
|
||||
out = switch_to_specialisation("${machine}", "mountModified")
|
||||
assert_lacks(out, "stopping the following units:")
|
||||
assert_lacks(out, "NOT restarting the following changed units:")
|
||||
assert_lacks(out, "reloading the following units:")
|
||||
assert_contains(out, "\nrestarting the following units: testmount.mount\n")
|
||||
assert_lacks(out, "\nstarting the following units:")
|
||||
assert_lacks(out, "the following new units were started:")
|
||||
# It changed
|
||||
out = machine.succeed("mount | grep 'on /testmount'")
|
||||
assert_contains(out, "ramfs")
|
||||
|
||||
with subtest("timers"):
|
||||
switch_to_specialisation("${machine}", "timer")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue