diff --git a/pkgs/os-specific/bsd/freebsd/patches/15.0/rc-bash.patch b/pkgs/os-specific/bsd/freebsd/patches/15.0/rc-bash.patch new file mode 100644 index 000000000000..e793f0c1ffee --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/15.0/rc-bash.patch @@ -0,0 +1,13 @@ +diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr +index 101c69e93cde..b95fc1b93285 100644 +--- a/libexec/rc/rc.subr ++++ b/libexec/rc/rc.subr +@@ -2493,7 +2493,7 @@ ltr() + fi + done + if [ -n "${_var}" ]; then +- setvar "${_var}" "${_out}" ++ printf -v "${_var}" "%s" "${_out}" + else + echo "${_out}" + fi diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/rc.nix b/pkgs/os-specific/bsd/freebsd/pkgs/rc.nix index 96aadbc618f2..6a7a04f6512e 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/rc.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/rc.nix @@ -10,6 +10,14 @@ protect, mount, fsck, + logger, + devmatch, + sort, + kldload, + kldstat, + devctl, + sed, + gnugrep, }: let rcDepsPath = lib.makeBinPath [ @@ -22,6 +30,14 @@ let mount protect fsck + logger + devmatch + sort + kldload + kldstat + devctl + sed + gnugrep ]; in mkDerivation { @@ -43,20 +59,23 @@ mkDerivation { '' + ( let - bins = [ - "/sbin/sysctl" - "/usr/bin/protect" - "/usr/bin/id" - "/bin/ps" - "/bin/cpuset" - "/usr/bin/stat" - "/bin/rm" - "/bin/chmod" - "/bin/cat" - "/bin/sync" - "/bin/sleep" - "/bin/date" - ]; + bins = { + "/sbin/sysctl" = sysctl; + "/usr/bin/protect" = protect; + "/usr/bin/id" = id; + "/bin/ps" = bin; + "/bin/cpuset" = bin; + "/usr/bin/stat" = stat; + "/bin/rm" = bin; + "/bin/chmod" = bin; + "/bin/cat" = bin; + "/bin/sync" = bin; + "/bin/sleep" = bin; + "/bin/date" = bin; + "/usr/bin/logger" = logger; + "logger" = logger; + "kenv" = bin; + }; scripts = [ "rc" "rc.initdiskless" @@ -64,17 +83,26 @@ mkDerivation { "rc.subr" "rc.suspend" "rc.resume" + "rc.conf" ]; scriptPaths = "$BSDSRCDIR/libexec/rc/{${lib.concatStringsSep "," scripts}}"; in # set PATH correctly in scripts '' sed -E -i -e "s|PATH=.*|PATH=${rcDepsPath}|g" ${scriptPaths} + sed -E -i -e "/etc\/rc.subr/i export PATH=${rcDepsPath}" $BSDSRCDIR/libexec/rc/rc.d/* '' - # replace executable absolute filepaths with PATH lookups - + lib.concatMapStringsSep "\n" (fname: '' - sed -E -i -e "s|${fname}|${lib.last (lib.splitString "/" fname)}|g" \ - ${scriptPaths}'') bins + # replace executable references with nix store filepaths + + lib.concatMapStringsSep "\n" ( + { + fname ? name, + name, + value, + }: + '' + sed -E -i -e "s|${fname}|${lib.getBin value}/bin/${lib.last (lib.splitString "/" fname)}|g" \ + ${scriptPaths}'' + ) (lib.attrsToList bins) + "\n" );