Stage 1 systemd | 84 Members | |
| systemd in NixOs's stage 1, replacing the current bash tooling https://github.com/NixOS/nixpkgs/projects/51 | 27 Servers |
| Sender | Message | Time |
|---|---|---|
| 20 Mar 2022 | ||
| I just realized that systemd does some wacky stuff where stage-2 systemd binary inherits state from the stage-1 systemd binary. E.g. to show stage-1 boot times in systemd-analyze blame I think this currently doesn't work in Nixos as our stage 2 is a shell script execing into systemd instead of systemd that also calls a shellscript | 14:15:00 | |
| This might also be something we want to change. Have the first executable in stage-2 be systemd proper | 14:15:16 | |
| ElvishJerricco: just looked at your PR. Looks good 👍️ I do think it'll help to at least split off the changes to systemd-lib.nix and utils.nix to a separate PR to ease the review process. | 15:33:06 | |
| Hopefully https://github.com/NixOS/nixpkgs/pull/164016 can be merged soonish, so the changes your PR introduced will be clearer in the diff. | 15:34:17 | |
| I do think it might help to have an executable like make-initramfs-ng/find-dependencies that doesn't copy everything first to a root dir and afterwards package those files up using cpio. A slight optimization, but I think that can be a separate PR with a separate discission. I won't mention it in the PR to avoid nitty-gritty discussions. | 15:36:43 | |
In reply to @arianvp:matrix.orgThat's the --deserialize flag, I had a pr for that | 15:37:01 | |
| https://github.com/NixOS/nixpkgs/pull/137122/files | 15:38:27 | |
| this one, the commit is still good to go | 15:38:34 | |
In reply to @arianvp:matrix.orgI don't think that's remotely possible | 15:38:46 | |
To be more precise, initrd systemd calls real systemd with some arguments. On my CentOS 7, PID 1 is /usr/lib/systemd/systemd --switched-root --system --deserialize 22. My PR should properly forward all flags from the shell script so that should work. The 22 (in this case) is the file descriptor that holds the initrd systemd state that is deserialized into the new systemd. stage-2-init.sh already uses the exec bash call which inherits all FDs so as long as stage-2-init.sh doesn't touch these FDs, it should work properly | 15:44:10 | |
| also ElvishJerricco I found this to improve things because I can set env vars:
| 16:32:52 | |
(on top of your PR). I wonder if we should use cfg.globalEnvironment here. It sets LOCALE_ARCHIVE and TZDIR | 16:33:31 | |
In reply to @janne.hess:helsinki-systems.deI'd rather see a boot.inird.systemd.globalEnvironment instead. Just to avoid unintended changes to initrd.That said, I'm not sure if it's needed if we can set envvars to specific values boot.initrd.systemd.services.emergency.environment.SOME_VAR = "3";.Are things like LOCALE_ARCHIVE and TZDIR needed in initrd? | 17:00:48 | |
In reply to @janne.hess:helsinki-systems.de* I'd rather see a boot.inird.systemd.globalEnvironment instead. Just to avoid unintended changes to initrd.That said, I'm not sure if it's needed if we can set envvars to specific values boot.initrd.systemd.services.emergency.environment.SOME_VAR = "3";.Are things like LOCALE_ARCHIVE and TZDIR needed (or even usable) in initrd? | 17:00:58 | |
LOCALE_ARCHIVE and TZDIR are probably more optional. Adding a global option and not populating it by default would be a good way imo. For me, I needed the environment for boot.initrd.systemd.services.emergency.environment.SYSTEMD_SULOGIN_FORCE = "1"; | 17:02:00 | |
also, you mentioned something about /proc/sys/kernel/modprobe. How did you set it in your attempt? Because it looks like it's not set at all in the PR | 17:02:46 | |
In reply to @arianvp:matrix.orgYep. I mentioned this in the PR. We can either do activation in stage one with nixos-enter, or maybe do something clever with systemd generators | 17:05:26 | |
In reply to @bobvanderlinden_:matrix.orgI think that's a good point. I'd like to make that change but just didn't bother last night. I wouldn't be opposed to a patch to change that in this PR | 17:06:41 | |
| Janne Heß: I did not realize it was possible to do the serialization thing without switch-root'ing to exactly the systemd binary. Cool, I'll take a look | 17:09:25 | |
| Janne Heß: Yea we might want a globalEnvironment thing, I just didn't see a need, since initrd is really supposed to just launch and die as quickly as possible | 17:11:33 | |
yeah people will probably not get mad if it's missing. It's something that can be added later. A working systemd.services.<?>.environment is more useful though ;) | 17:13:02 | |
Janne Heß: Is there a reason boot.initrd.systemd.services.emergency.environtment doesn't work on its own though? | 17:13:27 | |
Also, for the modprobe thing, it's in the object that gets symlinked to /etc/sysctl.d/nixos.conf | 17:13:45 | |
In reply to @elvishjerricco:matrix.org Yeah you are missing:
| 17:14:04 | |
| (but without the globalEnvironment, just def.environment) | 17:14:12 | |
Ohhh, def.environment doesn't just get assigned to serviceConfig.Environment like e.g. path gets set to environment.PATH | 17:15:13 | |
| Ok, yea that needs a fixing | 17:15:23 | |
| yeah | 17:15:29 | |
ElvishJerricco no worries. I was thinking these kinds of optimizations can also happen after the PR. I'd rather be in a state where the PR is merged and multiple people can create PRs to improve the various parts of initrd-systemd, rather than everyone commenting/attempting to make changes to the PR itself, leaving you to be the central person that needs to do things: a situation I'd like to avoid with the time it takes for some PRs | 17:16:14 | |
| bobvanderlinden: Yea, I agree that delaying the PR with endless discussion would be unfortunate. But delaying for actual completed patches to be included is reasonable | 17:17:09 | |