| 9 Apr 2022 |
@elvishjerricco:matrix.org | But yea, I do wonder if we can get away with not doing so much patching on stuff like LVM udev rules, since we don't need to be so strict about the sandboxed environment (since this is a sandboxed environment). Like we could just start putting stuff at /usr/bin or on PATH to satisfy these things for initrd | 02:00:27 |
@elvishjerricco:matrix.org | We only don't do that in nixos because the whole philosophy of Nix is that these things exist simultaneously yet independently, whereas there's none of that in initrd | 02:02:44 |
bobvanderlinden | Hmm, for NixOS I feel better setting the path to a /nix/store/ instead of /run/current-system to be honest. Or there is a specific reason to use /run/current-system, but I doubt that isn't possible with path in .service or something like that. | 02:09:55 |
bobvanderlinden | * Hmm, for NixOS I feel better setting the PATH to a /nix/store/ instead of hardcoding /run/current-system to be honest. Or there is a specific reason to use /run/current-system, but I doubt that isn't possible with path in .service or something like that. | 02:10:40 |
@elvishjerricco:matrix.org | Well in NixOS we use /run/current-system/sw/bin for PATH so that you don't need an up-to-date PATH env variable for your terminal to be using the right programs | 02:11:04 |
@elvishjerricco:matrix.org | Like if you add or upgrade a package in environment.systemPackages, you need that package to be in the old PATH env variable | 02:11:43 |
@elvishjerricco:matrix.org | so we just make that generic | 02:11:49 |
bobvanderlinden | Ah, if it is a script that is required to be executed ad-hoc, that indeed is a reason to use /run/current-system | 02:12:16 |
@elvishjerricco:matrix.org | (and disable Bash's PATH caching) | 02:12:19 |
@elvishjerricco:matrix.org | well also just for using a terminal as a human | 02:12:34 |
@elvishjerricco:matrix.org | nixos-rebuild switch, why isn't my package there? | 02:12:45 |
@elvishjerricco:matrix.org | Because you have the old PATH | 02:12:48 |
bobvanderlinden | In reply to @elvishjerricco:matrix.org Like if you add or upgrade a package in environment.systemPackages, you need that package to be in the old PATH env variable Good point. Not sure if that's possible with .service paths | 02:13:06 |
@elvishjerricco:matrix.org | Definitely not | 02:13:22 |
bobvanderlinden | I probably don't have a good grasp on the nixos switch/activation | 02:18:01 |
@janne.hess:helsinki-systems.de | In reply to @bobvanderlinden_:matrix.org I probably don't have a good grasp on the nixos switch/activation I wrote a manual chapter about that | 13:15:07 |
@janne.hess:helsinki-systems.de | https://nixos.org/manual/nixos/unstable/index.html#sec-switching-systems | 13:17:32 |
@janne.hess:helsinki-systems.de | here we go upstreaming my garbage: https://github.com/systemd/systemd/pull/23033 | 15:44:59 |
@janne.hess:helsinki-systems.de | Arian ElvishJerricco : nailed it: https://github.com/NixOS/nixpkgs/pull/167168 | 16:11:30 |
@janne.hess:helsinki-systems.de | this is one commit of fixups, one commit where I use my ugly hack and one where I replace that ugly hack with a systemd patch. My idea is to pop the third commit into a separate PR that goes to staging and have the other two commits go directly to master. This way we get the new functionality without having to wait for staging. They are currently in one PR so you can see the combined diff more easily | 16:12:32 |
@elvishjerricco:matrix.org | Janne Heß: I still don't understand why we need the systemd patch. Why can't we run nixos activation and then leave /sysroot/run mounted, preventing systemd from trying to do it? | 23:36:36 |
| 10 Apr 2022 |
@elvishjerricco:matrix.org | Well I tried it and it failed spectacularly :P Not sure why | 01:01:16 |
@elvishjerricco:matrix.org | Janne Heß: This works for me:
diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix
index 59dd508932f..6a9b8f90926 100644
--- a/nixos/modules/system/boot/systemd/initrd.nix
+++ b/nixos/modules/system/boot/systemd/initrd.nix
@@ -487,27 +487,11 @@ in {
# and /run/current-system. Also /tmp can be mounted to ensure that
# it will be empty in stage 2.
mkdir -p /tmp /sysroot/run /sysroot/tmp
- mount --bind /run /sysroot/run
- mount --bind /tmp /sysroot/tmp
- mount --make-private /sysroot/run
+ mount --rbind /run /sysroot/run
# Initialize the system
export IN_NIXOS_SYSTEMD_STAGE1=1
- chroot /sysroot $closure/prepare-root
-
- # Since the activation script may create new mounts under /run, move these
- # from /sysroot/run to /run to ensure that systemd moves them later.
- while read -r _ where _; do
- if [[ "$where" == /sysroot/run/* ]]; then
- newWhere="''${where#/sysroot}"
- mkdir -p "$newWhere"
- mount --move "$where" "$newWhere"
- fi
- done < /proc/self/mounts
-
- # systemd will only move /run if it's not a mountpoint yet, so unmount it
- umount /sysroot/run
- umount /sysroot/tmp
+ exec chroot /sysroot $closure/prepare-root
'';
};
diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix
index f17ce344ce8..e130abbf27f 100644
--- a/pkgs/os-specific/linux/systemd/default.nix
+++ b/pkgs/os-specific/linux/systemd/default.nix
@@ -178,12 +178,6 @@ stdenv.mkDerivation {
# need (AFAICT).
# See https://github.com/systemd/systemd/pull/20479 for upstream discussion.
./0019-core-handle-lookup-paths-being-symlinks.patch
-
- # Make systemd compatible with our initrd
- (fetchpatch {
- url = "https://github.com/systemd/systemd/commit/7653dfef361c070a14a45ab69b820a5f22e3a58d.patch";
- sha256 = "0z8axwin1xkp2ldnlvy0mk7biisykbzvkjvza3kpqa8pmp0vn2sm";
- })
] ++ lib.optional stdenv.hostPlatform.isMusl (
let
oe-core = fetchzip {
| 03:12:06 |
@elvishjerricco:matrix.org | * Janne Heß: This works for me:
diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix
index 59dd508932f..6a9b8f90926 100644
--- a/nixos/modules/system/boot/systemd/initrd.nix
+++ b/nixos/modules/system/boot/systemd/initrd.nix
@@ -487,27 +487,11 @@ in {
# and /run/current-system. Also /tmp can be mounted to ensure that
# it will be empty in stage 2.
mkdir -p /tmp /sysroot/run /sysroot/tmp
- mount --bind /run /sysroot/run
- mount --bind /tmp /sysroot/tmp
+ mount --rbind /run /sysroot/run
mount --make-private /sysroot/run
# Initialize the system
export IN_NIXOS_SYSTEMD_STAGE1=1
- chroot /sysroot $closure/prepare-root
-
- # Since the activation script may create new mounts under /run, move these
- # from /sysroot/run to /run to ensure that systemd moves them later.
- while read -r _ where _; do
- if [[ "$where" == /sysroot/run/* ]]; then
- newWhere="''${where#/sysroot}"
- mkdir -p "$newWhere"
- mount --move "$where" "$newWhere"
- fi
- done < /proc/self/mounts
-
- # systemd will only move /run if it's not a mountpoint yet, so unmount it
- umount /sysroot/run
- umount /sysroot/tmp
+ exec chroot /sysroot $closure/prepare-root
'';
};
diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix
index f17ce344ce8..e130abbf27f 100644
--- a/pkgs/os-specific/linux/systemd/default.nix
+++ b/pkgs/os-specific/linux/systemd/default.nix
@@ -178,12 +178,6 @@ stdenv.mkDerivation {
# need (AFAICT).
# See https://github.com/systemd/systemd/pull/20479 for upstream discussion.
./0019-core-handle-lookup-paths-being-symlinks.patch
-
- # Make systemd compatible with our initrd
- (fetchpatch {
- url = "https://github.com/systemd/systemd/commit/7653dfef361c070a14a45ab69b820a5f22e3a58d.patch";
- sha256 = "0z8axwin1xkp2ldnlvy0mk7biisykbzvkjvza3kpqa8pmp0vn2sm";
- })
] ++ lib.optional stdenv.hostPlatform.isMusl (
let
oe-core = fetchzip {
| 03:13:58 |
@elvishjerricco:matrix.org | * Janne Heß: This works for me:
diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix
index 59dd508932f..67b1af5f6d1 100644
--- a/nixos/modules/system/boot/systemd/initrd.nix
+++ b/nixos/modules/system/boot/systemd/initrd.nix
@@ -413,7 +413,7 @@ in {
"${cfg.package.util-linux}/bin/sulogin"
# so NSS can look up usernames
- "${pkgs.glibc}/lib/libnss_files.so"
+ "${pkgs.glibc}/lib/libnss_files.so.2"
] ++ jobScripts;
targets.initrd.aliases = ["default.target"];
@@ -488,26 +488,11 @@ in {
# it will be empty in stage 2.
mkdir -p /tmp /sysroot/run /sysroot/tmp
mount --bind /run /sysroot/run
- mount --bind /tmp /sysroot/tmp
mount --make-private /sysroot/run
# Initialize the system
export IN_NIXOS_SYSTEMD_STAGE1=1
- chroot /sysroot $closure/prepare-root
-
- # Since the activation script may create new mounts under /run, move these
- # from /sysroot/run to /run to ensure that systemd moves them later.
- while read -r _ where _; do
- if [[ "$where" == /sysroot/run/* ]]; then
- newWhere="''${where#/sysroot}"
- mkdir -p "$newWhere"
- mount --move "$where" "$newWhere"
- fi
- done < /proc/self/mounts
-
- # systemd will only move /run if it's not a mountpoint yet, so unmount it
- umount /sysroot/run
- umount /sysroot/tmp
+ exec chroot /sysroot $closure/prepare-root
'';
};
diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix
index f17ce344ce8..e130abbf27f 100644
--- a/pkgs/os-specific/linux/systemd/default.nix
+++ b/pkgs/os-specific/linux/systemd/default.nix
@@ -178,12 +178,6 @@ stdenv.mkDerivation {
# need (AFAICT).
# See https://github.com/systemd/systemd/pull/20479 for upstream discussion.
./0019-core-handle-lookup-paths-being-symlinks.patch
-
- # Make systemd compatible with our initrd
- (fetchpatch {
- url = "https://github.com/systemd/systemd/commit/7653dfef361c070a14a45ab69b820a5f22e3a58d.patch";
- sha256 = "0z8axwin1xkp2ldnlvy0mk7biisykbzvkjvza3kpqa8pmp0vn2sm";
- })
] ++ lib.optional stdenv.hostPlatform.isMusl (
let
oe-core = fetchzip {
| 03:15:20 |
@elvishjerricco:matrix.org | * Janne Heß: This works for me:
diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix
index 59dd508932f..515e30b6c9b 100644
--- a/nixos/modules/system/boot/systemd/initrd.nix
+++ b/nixos/modules/system/boot/systemd/initrd.nix
@@ -488,26 +488,11 @@ in {
# it will be empty in stage 2.
mkdir -p /tmp /sysroot/run /sysroot/tmp
mount --bind /run /sysroot/run
- mount --bind /tmp /sysroot/tmp
mount --make-private /sysroot/run
# Initialize the system
export IN_NIXOS_SYSTEMD_STAGE1=1
- chroot /sysroot $closure/prepare-root
-
- # Since the activation script may create new mounts under /run, move these
- # from /sysroot/run to /run to ensure that systemd moves them later.
- while read -r _ where _; do
- if [[ "$where" == /sysroot/run/* ]]; then
- newWhere="''${where#/sysroot}"
- mkdir -p "$newWhere"
- mount --move "$where" "$newWhere"
- fi
- done < /proc/self/mounts
-
- # systemd will only move /run if it's not a mountpoint yet, so unmount it
- umount /sysroot/run
- umount /sysroot/tmp
+ exec chroot /sysroot $closure/prepare-root
'';
};
diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix
index f17ce344ce8..e130abbf27f 100644
--- a/pkgs/os-specific/linux/systemd/default.nix
+++ b/pkgs/os-specific/linux/systemd/default.nix
@@ -178,12 +178,6 @@ stdenv.mkDerivation {
# need (AFAICT).
# See https://github.com/systemd/systemd/pull/20479 for upstream discussion.
./0019-core-handle-lookup-paths-being-symlinks.patch
-
- # Make systemd compatible with our initrd
- (fetchpatch {
- url = "https://github.com/systemd/systemd/commit/7653dfef361c070a14a45ab69b820a5f22e3a58d.patch";
- sha256 = "0z8axwin1xkp2ldnlvy0mk7biisykbzvkjvza3kpqa8pmp0vn2sm";
- })
] ++ lib.optional stdenv.hostPlatform.isMusl (
let
oe-core = fetchzip {
| 03:15:48 |
@elvishjerricco:matrix.org | * Janne Heß: This works for me:
diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix
index 59dd508932f..b388852e342 100644
--- a/nixos/modules/system/boot/systemd/initrd.nix
+++ b/nixos/modules/system/boot/systemd/initrd.nix
@@ -486,28 +486,13 @@ in {
# We need to propagate /run for things like /run/booted-system
# and /run/current-system. Also /tmp can be mounted to ensure that
# it will be empty in stage 2.
- mkdir -p /tmp /sysroot/run /sysroot/tmp
+ mkdir -p /sysroot/run
mount --bind /run /sysroot/run
- mount --bind /tmp /sysroot/tmp
mount --make-private /sysroot/run
# Initialize the system
export IN_NIXOS_SYSTEMD_STAGE1=1
- chroot /sysroot $closure/prepare-root
-
- # Since the activation script may create new mounts under /run, move these
- # from /sysroot/run to /run to ensure that systemd moves them later.
- while read -r _ where _; do
- if [[ "$where" == /sysroot/run/* ]]; then
- newWhere="''${where#/sysroot}"
- mkdir -p "$newWhere"
- mount --move "$where" "$newWhere"
- fi
- done < /proc/self/mounts
-
- # systemd will only move /run if it's not a mountpoint yet, so unmount it
- umount /sysroot/run
- umount /sysroot/tmp
+ exec chroot /sysroot $closure/prepare-root
'';
};
diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix
index f17ce344ce8..e130abbf27f 100644
--- a/pkgs/os-specific/linux/systemd/default.nix
+++ b/pkgs/os-specific/linux/systemd/default.nix
@@ -178,12 +178,6 @@ stdenv.mkDerivation {
# need (AFAICT).
# See https://github.com/systemd/systemd/pull/20479 for upstream discussion.
./0019-core-handle-lookup-paths-being-symlinks.patch
-
- # Make systemd compatible with our initrd
- (fetchpatch {
- url = "https://github.com/systemd/systemd/commit/7653dfef361c070a14a45ab69b820a5f22e3a58d.patch";
- sha256 = "0z8axwin1xkp2ldnlvy0mk7biisykbzvkjvza3kpqa8pmp0vn2sm";
- })
] ++ lib.optional stdenv.hostPlatform.isMusl (
let
oe-core = fetchzip {
| 03:18:14 |
@elvishjerricco:matrix.org | * Janne Heß: This works for me:
diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix
index 59dd508932f..491984d0347 100644
--- a/nixos/modules/system/boot/systemd/initrd.nix
+++ b/nixos/modules/system/boot/systemd/initrd.nix
@@ -481,37 +481,18 @@ in {
exit 0
fi
- echo 'SYSTEMCTL_FORCE_HANDOVER=1' > /etc/switch-root.conf
-
# We need to propagate /run for things like /run/booted-system
# and /run/current-system. Also /tmp can be mounted to ensure that
# it will be empty in stage 2.
- mkdir -p /tmp /sysroot/run /sysroot/tmp
+ mkdir -p /sysroot/run
mount --bind /run /sysroot/run
- mount --bind /tmp /sysroot/tmp
mount --make-private /sysroot/run
# Initialize the system
export IN_NIXOS_SYSTEMD_STAGE1=1
- chroot /sysroot $closure/prepare-root
-
- # Since the activation script may create new mounts under /run, move these
- # from /sysroot/run to /run to ensure that systemd moves them later.
- while read -r _ where _; do
- if [[ "$where" == /sysroot/run/* ]]; then
- newWhere="''${where#/sysroot}"
- mkdir -p "$newWhere"
- mount --move "$where" "$newWhere"
- fi
- done < /proc/self/mounts
-
- # systemd will only move /run if it's not a mountpoint yet, so unmount it
- umount /sysroot/run
- umount /sysroot/tmp
+ exec chroot /sysroot $closure/prepare-root
'';
};
-
- services.initrd-switch-root.serviceConfig.EnvironmentFile = "-/etc/switch-root.conf";
};
};
}
diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix
index f17ce344ce8..e130abbf27f 100644
--- a/pkgs/os-specific/linux/systemd/default.nix
+++ b/pkgs/os-specific/linux/systemd/default.nix
@@ -178,12 +178,6 @@ stdenv.mkDerivation {
# need (AFAICT).
# See https://github.com/systemd/systemd/pull/20479 for upstream discussion.
./0019-core-handle-lookup-paths-being-symlinks.patch
-
- # Make systemd compatible with our initrd
- (fetchpatch {
- url = "https://github.com/systemd/systemd/commit/7653dfef361c070a14a45ab69b820a5f22e3a58d.patch";
- sha256 = "0z8axwin1xkp2ldnlvy0mk7biisykbzvkjvza3kpqa8pmp0vn2sm";
- })
] ++ lib.optional stdenv.hostPlatform.isMusl (
let
oe-core = fetchzip {
| 03:20:11 |
@elvishjerricco:matrix.org | I also had to change libnss_files.so to libnss_files.so.2 for whatever reason | 03:23:36 |
@elvishjerricco:matrix.org | * I also had to change libnss_files.so to libnss_files.so.2 since for whatever reason the former doesn't exist anymore | 03:23:59 |