11 Oct 2024 |
ElvishJerricco | Willi Butz: If that doc is right I don't think you need to do anything. Just put all the mounts in fileSystems , and systemd will make the sources automatically as directories. Then stage 2 tmpfiles takes care of permissions | 18:19:28 |
ElvishJerricco | I need to test this now... | 18:19:48 |
Willi Butz | ah that's what I meant, there is also DirectoryMode= for mount units | 18:20:23 |
ElvishJerricco | yea but I think that only applies to the mountpoint, not the bind source | 18:20:57 |
Willi Butz | ah good point | 18:21:16 |
Willi Butz | doing mounts first with implicit parent creation and then running regular tmpfiles sounds like a much cleaner approach | 18:22:09 |
emily | In reply to @elvishjerricco:matrix.org
in systemd.mount 's section on What= :
If this mount is a bind mount and the specified path does not exist yet it is created as directory.
!! | 18:22:54 |
emily | wonderful | 18:22:56 |
Willi Butz | https://github.com/WilliButz/preservation/issues/5#issuecomment-2407625582 | 18:23:08 |
ElvishJerricco | hm, I'm not sure it's working... | 18:23:14 |
emily | that should make the module really trivial if it works right? | 18:23:27 |
emily | it'd be lovely to get it in NixOS | 18:23:34 |
ElvishJerricco | oh no it totally works. My test is just bad | 18:23:48 |
emily | impermanence is like the #1 third-party module people use, so if we have a clean and simple systemd-native way to do it upstream that'd be excellent | 18:23:52 |
aloisw | Sure it's more popular than home-manager? | 18:24:16 |
emily | hm | 18:24:23 |
emily | ok, fair | 18:24:24 |
emily | I don't think of home-manager as a third-party module | 18:24:28 |
ElvishJerricco | (but it is a lot smaller than home-manager) | 18:24:34 |
emily | it's its entirely own… whatever you call instantiations of the module system with an activation setup | 18:24:40 |
emily | with a third-party module sitting on the side for integration | 18:24:46 |
ElvishJerricco | Willi Butz: Yea check it out:
with import <nixpkgs> {};
nixosTest {
name = "foo";
nodes.machine.virtualisation.fileSystems."/foo" = {
device = "/bar";
options = ["bind"];
};
testScript = ''
machine.wait_for_unit("local-fs.target")
machine.succeed("touch /bar/hi")
machine.succeed("stat /foo/hi")
'';
}
Totally works
| 18:25:04 |
emily | it's the #1 third-party module that solely relates to NixOS :) | 18:25:06 |
mjm | i would kind of love if services.* modules could declare their state directories, so that if you enabled preservation, it worked automatically | 18:25:13 |
mjm | (i have something like that in my own modules) | 18:25:21 |
mjm | that gets weird maybe if you have multiple preservation roots | 18:25:45 |
Willi Butz | In reply to @elvishjerricco:matrix.org
Willi Butz: Yea check it out:
with import <nixpkgs> {};
nixosTest {
name = "foo";
nodes.machine.virtualisation.fileSystems."/foo" = {
device = "/bar";
options = ["bind"];
};
testScript = ''
machine.wait_for_unit("local-fs.target")
machine.succeed("touch /bar/hi")
machine.succeed("stat /foo/hi")
'';
}
Totally works
nice! I'll see if I can rework the module soonish | 18:25:49 |
emily | isn't that what the systemd state directory stuff is for? | 18:25:52 |
emily | but also I thought part of the idea was that it should be opt-in what you actually preserve | 18:26:06 |
emily | since lots of stuff has state | 18:26:08 |