!PSmBFWNKoXmlQBzUQf:helsinki-systems.de

Stage 1 systemd

83 Members
systemd in NixOs's stage 1, replacing the current bash tooling https://github.com/NixOS/nixpkgs/projects/5127 Servers

Load older messages


SenderMessageTime
20 Mar 2022
@elvishjerricco:matrix.org@elvishjerricco:matrix.org Janne Heß: Mainly because it doesn't matter, unlike in actual NixOS 20:16:38
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgBefore I had a lot of things working, it was way easier to just have /bin rather than having to go spelunking through /nix20:18:01
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgwhen something gets wildly borked it's nice to have there20:18:15
@janne.hess:helsinki-systems.de@janne.hess:helsinki-systems.dehmm, does the test work for you?20:18:16
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgyes20:18:20
@janne.hess:helsinki-systems.de@janne.hess:helsinki-systems.deinteresting, so some local modification must be breaking it…20:18:32
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgwhat's the breakage?20:18:41
@janne.hess:helsinki-systems.de@janne.hess:helsinki-systems.de [FAILED] Failed to start Make File System on /dev/vda. 20:18:56
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgUh oh20:19:17
@janne.hess:helsinki-systems.de@janne.hess:helsinki-systems.deummmm interesting20:19:33
@janne.hess:helsinki-systems.de@janne.hess:helsinki-systems.dethe modification that broke it was my Environment= stuff20:19:41
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgSystemd needs to find mke2fs on PATH20:20:20
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgDoes setting Environment= override PATH even if you don't use it to set PATH?20:22:04
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgEr, no, emergency.service uses it to set HOME=/root, and that doesn't break PATH in my emergency shell20:22:27
@janne.hess:helsinki-systems.de@janne.hess:helsinki-systems.de ah yeah for some reason it sets PATH=:. I'll take a look at this later because it turns out the argument passing doesn't work :/ 20:24:33
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgOh20:24:42
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgI bet I know what's up with that20:24:47
@elvishjerricco:matrix.org@elvishjerricco:matrix.org The code that converts services.foo.path to services.foo.environment.PATH 20:25:16
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgIt's not conditional, so it'll always set it to empty20:25:29
@elvishjerricco:matrix.org@elvishjerricco:matrix.org (and apparently incorrectly, as it does : :P) 20:25:42
@janne.hess:helsinki-systems.de@janne.hess:helsinki-systems.deah because there is a default path in stage 2?20:25:47
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgright20:25:54
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgYea so that's a bug20:26:05
@elvishjerricco:matrix.org@elvishjerricco:matrix.org So we probably want to add the paths from DefaultEnvironment to the path -> PATH conversion 20:28:09
@elvishjerricco:matrix.org@elvishjerricco:matrix.org

Or, hah, this probably works:

diff --git a/nixos/lib/systemd-lib.nix b/nixos/lib/systemd-lib.nix
index 3129fbe7bdb..4ee40f2fa08 100644
--- a/nixos/lib/systemd-lib.nix
+++ b/nixos/lib/systemd-lib.nix
@@ -332,7 +332,7 @@ in rec {
     systemd
   ];
 
-  initrdServiceConfig = mkServiceConfig [];
+  initrdServiceConfig = mkServiceConfig ["/"];
 
   mountConfig = { config, ... }: {
     config = {
20:29:27
@elvishjerricco:matrix.org@elvishjerricco:matrix.orghighly jank20:29:39
@janne.hess:helsinki-systems.de@janne.hess:helsinki-systems.deoof20:30:05
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgI'm going to take off again for a while. Let me know if you figure anything out20:30:39
@janne.hess:helsinki-systems.de@janne.hess:helsinki-systems.de

okay so about the PATH stuff: I came up with this:

diff --git a/nixos/lib/systemd-lib.nix b/nixos/lib/systemd-lib.nix
index 3129fbe7bdb..7850d5f4524 100644
--- a/nixos/lib/systemd-lib.nix
+++ b/nixos/lib/systemd-lib.nix
@@ -396,6 +396,12 @@ in rec {
       text = commonUnitText def +
         ''
           [Service]
+          ${concatMapStrings (n:
+              let s = optionalString (def.environment.${n} != null && n == "PATH" -> def.environment.${n} != ":")
+                (lib.traceValSeq "Environment=${builtins.toJSON "${n}=${def.environment.${n}}"}\n");
+              # systemd max line length is now 1MiB
+              # https://github.com/systemd/systemd/commit/e6dde451a51dc5aaa7f4d98d39b8fe735f73d2af
+              in if stringLength s >= 1048576 then throw "The value of the environment variable ‘${n}’ in systemd service ‘${name}.service’ is too long." else s) (attrNames def.environment)}
           ${attrsToSection def.serviceConfig}
         '';
     };
23:17:31
@janne.hess:helsinki-systems.de@janne.hess:helsinki-systems.deabout the serialization stuff: I spent some hours patching systemd and it works in theory now. This does however not work when we run stage-2-init.sh in between the systemd executions because there is a short time where the shell script is running and no systemd which causes systemd to miss signals, causing it to hang forever in bootup (sounds strange but makes sense when going into details I'm too tired to write down)23:19:11

Show newer messages


Back to Room ListRoom Version: 6