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 775f381a9e
  ("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.
This commit is contained in:
Bjørn Forsman 2017-06-01 22:35:40 +02:00
parent f12b0a2179
commit 581226cfb4
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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 = ''