From 3d774b445340d532d01ce968a29bf781d5459fd9 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 20 Jul 2023 22:00:13 +0300 Subject: [PATCH] util-linux: Fix build on non-Linux Build logs show: > configure: WARNING: non-linux system; not building mount > configure: WARNING: non-linux system; not building swapon So skip these on non-Linux Using getOutput prevents eval failures on other platforms. Things should stay eval'able with NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 Co-authored-by: Artturin --- nixos/modules/system/boot/stage-1.nix | 2 +- pkgs/os-specific/linux/systemd/default.nix | 8 ++++---- pkgs/os-specific/linux/util-linux/default.nix | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index 28b5592d9d7d..08a10cb5edf8 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -122,7 +122,7 @@ let # code, using default options and effectively ignore security relevant # ZFS properties such as `setuid=off` and `exec=off` (unless manually # duplicated in `fileSystems.*.options`, defeating "zfsutil"'s purpose). - copy_bin_and_libs ${pkgs.util-linux.mount}/bin/mount + copy_bin_and_libs ${lib.getOutput "mount" pkgs.util-linux}/bin/mount copy_bin_and_libs ${pkgs.zfs}/bin/mount.zfs ''} diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index 53244a5a9147..7378fa82b3e7 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -517,8 +517,8 @@ stdenv.mkDerivation (finalAttrs: { "-Dsulogin-path=${util-linux.login}/bin/sulogin" "-Dnologin-path=${util-linux.login}/bin/nologin" - "-Dmount-path=${util-linux.mount}/bin/mount" - "-Dumount-path=${util-linux.mount}/bin/umount" + "-Dmount-path=${lib.getOutput "mount" util-linux}/bin/mount" + "-Dumount-path=${lib.getOutput "mount" util-linux}/bin/umount" "-Dcreate-log-dirs=false" # Use cgroupsv2. This is already the upstream default, but better be explicit. @@ -569,8 +569,8 @@ stdenv.mkDerivation (finalAttrs: { "man/systemd-makefs@.service.xml" ]; } - { search = "/sbin/swapon"; replacement = "${util-linux.swap}/sbin/swapon"; where = [ "src/core/swap.c" "src/basic/unit-def.h" ]; } - { search = "/sbin/swapoff"; replacement = "${util-linux.swap}/sbin/swapoff"; where = [ "src/core/swap.c" ]; } + { search = "/sbin/swapon"; replacement = "${lib.getOutput "swap" util-linux}/sbin/swapon"; where = [ "src/core/swap.c" "src/basic/unit-def.h" ]; } + { search = "/sbin/swapoff"; replacement = "${lib.getOutput "swap" util-linux}/sbin/swapoff"; where = [ "src/core/swap.c" ]; } { search = "/bin/echo"; replacement = "${coreutils}/bin/echo"; diff --git a/pkgs/os-specific/linux/util-linux/default.nix b/pkgs/os-specific/linux/util-linux/default.nix index bd87c07879c3..9a335010c872 100644 --- a/pkgs/os-specific/linux/util-linux/default.nix +++ b/pkgs/os-specific/linux/util-linux/default.nix @@ -55,7 +55,7 @@ stdenv.mkDerivation rec { # the greater util-linux toolset. # Compatibility is maintained by symlinking the binaries from the # smaller outputs in the bin output. - outputs = [ "bin" "dev" "out" "lib" "man" "mount" "login" "swap" ]; + outputs = [ "bin" "dev" "out" "lib" "man" ] ++ lib.optionals stdenv.isLinux [ "mount" ] ++ [ "login" ] ++ lib.optionals stdenv.isLinux [ "swap" ]; separateDebugInfo = true; postPatch = '' @@ -110,20 +110,23 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; - postInstall = '' + postInstall = lib.optionalString stdenv.isLinux '' moveToOutput bin/mount "$mount" moveToOutput bin/umount "$mount" ln -svf "$mount/bin/"* $bin/bin/ + '' + '' moveToOutput sbin/nologin "$login" moveToOutput sbin/sulogin "$login" prefix=$login _moveSbin ln -svf "$login/bin/"* $bin/bin/ + '' + lib.optionalString stdenv.isLinux '' moveToOutput sbin/swapon "$swap" moveToOutput sbin/swapoff "$swap" prefix=$swap _moveSbin ln -svf "$swap/bin/"* $bin/bin/ + '' + '' installShellCompletion --bash bash-completion/* '';