From 581226cfb456b4c116594f1b79f45945703a4a4c Mon Sep 17 00:00:00 2001 From: Bjørn Forsman Date: Thu, 1 Jun 2017 22:35:40 +0200 Subject: nixos/bcache: /bin/sh -> ${bash}/bin/sh Or else `services.udev.packages = [ bcache-tools ]` cannot be used. To not break bcache in the initrd I'm modifying this in stage-1.nix: - --replace /bin/sh ${extraUtils}/bin/sh + --replace ${bash}/bin/sh ${extraUtils}/bin/sh Reasoning behind that change: * If not modifying the /bin/sh pattern in any way, it will also match ${bash}/bin/sh, creating a broken path like /nix/store/HASH-bash/nix/store/HASH-bash/bin/sh in the udev rule file. * The addition of /bin/sh was done in 775f381a9e34 ("stage-1: add bcache support"). It seems somewhat plausible that no new users have appeared since then and we can take this opportunity to back out of this change without much fear of regressions. If there _are_ regressions, they should be in the form of build time errors, not runtime (boot), due to how the udev rule output is checked for invalid path references. So low risk, IMHO. * An alternative approach could be to copy the /bin/sh substitute rule over to the non-initrd udev rules implementation in NixOS, but I think this way is better: - The rules file comes with a working path out of the box. - We can use more precise pattern matching when modifying the udev rules for the initrd. --- nixos/modules/system/boot/stage-1.nix | 2 +- pkgs/tools/filesystems/bcache-tools/default.nix | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index e3a3b6f88cf2..73608a0e27f2 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -167,7 +167,7 @@ let --replace /sbin/blkid ${extraUtils}/bin/blkid \ --replace ${pkgs.lvm2}/sbin ${extraUtils}/bin \ --replace /sbin/mdadm ${extraUtils}/bin/mdadm \ - --replace /bin/sh ${extraUtils}/bin/sh \ + --replace ${pkgs.bash}/bin/sh ${extraUtils}/bin/sh \ --replace /usr/bin/readlink ${extraUtils}/bin/readlink \ --replace /usr/bin/basename ${extraUtils}/bin/basename \ --replace ${udev}/bin/udevadm ${extraUtils}/bin/udevadm diff --git a/pkgs/tools/filesystems/bcache-tools/default.nix b/pkgs/tools/filesystems/bcache-tools/default.nix index e1a2f7d5bf7e..1eedff5c011e 100644 --- a/pkgs/tools/filesystems/bcache-tools/default.nix +++ b/pkgs/tools/filesystems/bcache-tools/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, pkgconfig, utillinux }: +{ stdenv, fetchurl, pkgconfig, utillinux, bash }: stdenv.mkDerivation rec { name = "bcache-tools-${version}"; @@ -29,6 +29,7 @@ stdenv.mkDerivation rec { preBuild = '' export makeFlags="$makeFlags PREFIX=\"$out\" UDEVLIBDIR=\"$out/lib/udev/\""; + sed -e "s|/bin/sh|${bash}/bin/sh|" -i *.rules ''; preInstall = '' -- cgit 1.4.1