From dacbee21829cdac656711a5362e6eca90d4c2da6 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 19 Feb 2022 21:51:01 -0800 Subject: [PATCH] util-linux: remove `? null` from inputs and convert to boolean flags Prior to this commit, util-linux supported compilation without systemd if systemd==null. This commit preserves that behavior, and additionally triggers it when the global systemdSupport attr is set to false. The systemdSupport argument is understood by many other nixpkgs expressions and can be set globally in ~/.config/nixpkgs/config.nix. Co-authored-by: Sandro --- pkgs/os-specific/linux/util-linux/default.nix | 19 +++++++++++-------- pkgs/top-level/all-packages.nix | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pkgs/os-specific/linux/util-linux/default.nix b/pkgs/os-specific/linux/util-linux/default.nix index d54f577def3e..3efb3914b85e 100644 --- a/pkgs/os-specific/linux/util-linux/default.nix +++ b/pkgs/os-specific/linux/util-linux/default.nix @@ -1,10 +1,13 @@ { lib, stdenv, fetchurl, pkg-config, zlib, shadow, libcap_ng -, ncurses ? null, pam, systemd ? null +, ncursesSupport ? true +, ncurses, pam +, systemdSupport ? stdenv.isLinux +, systemd , nlsSupport ? true }: stdenv.mkDerivation rec { - pname = "util-linux" + lib.optionalString ( !nlsSupport && ncurses == null && systemd == null ) "-minimal"; + pname = "util-linux" + lib.optionalString (!nlsSupport && !ncursesSupport && !systemdSupport) "-minimal"; version = "2.37.4"; src = fetchurl { @@ -40,9 +43,9 @@ stdenv.mkDerivation rec { "--disable-makeinstall-setuid" "--disable-makeinstall-chown" "--disable-su" # provided by shadow (lib.enableFeature nlsSupport "nls") - (lib.withFeature (ncurses != null) "ncursesw") - (lib.withFeature (systemd != null) "systemd") - (lib.withFeatureAs (systemd != null) + (lib.withFeature ncursesSupport "ncursesw") + (lib.withFeature systemdSupport "systemd") + (lib.withFeatureAs systemdSupport "systemdsystemunitdir" "${placeholder "bin"}/lib/systemd/system/") "SYSCONFSTATICDIR=${placeholder "lib"}/lib" ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) @@ -56,9 +59,9 @@ stdenv.mkDerivation rec { ]; nativeBuildInputs = [ pkg-config ]; - buildInputs = - [ zlib pam libcap_ng ] - ++ lib.filter (p: p != null) [ ncurses systemd ]; + buildInputs = [ zlib pam libcap_ng ] + ++ lib.optionals ncursesSupport [ ncurses ] + ++ lib.optionals systemdSupport [ systemd ]; doCheck = false; # "For development purpose only. Don't execute on production system!" diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 627a407cad2d..81da603405b9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -23477,8 +23477,8 @@ with pkgs; util-linuxMinimal = if stdenv.isLinux then util-linux.override { nlsSupport = false; - ncurses = null; - systemd = null; + ncursesSupport = false; + systemdSupport = false; } else util-linux; v4l-utils = qt5.callPackage ../os-specific/linux/v4l-utils { };