treewide: systemdSupport: use lib.meta.availableOn

Many packages have some kind of flag indicating whether or not to build with
systemd support.  Most of these default to `stdenv.isLinux`, but systemd does
not build on (and is marked `broken` for) `isStatic`.  Only a few packages have
the needed `&& !isStatic` in the default value for their parameter.

This commit moves the logic for the default value of these flags into
`systemd.meta.{platforms,badPlatforms}` and evaluates those conditions using
`lib.meta.availableOn`.

This provides three benefits:

1. The default values are set correctly (i.e. including `&& isStatic`)

2. The default values are set consistently

3. The way is paved for any future non-Linux systemd platforms (FreeBSD is
   reported to have experimental systemd support)
This commit is contained in:
Adam Joseph 2022-09-21 00:04:52 -07:00
parent 5b66b6b8c2
commit 42815b4a0c
41 changed files with 51 additions and 51 deletions

View File

@ -1,4 +1,6 @@
{ cmake { lib
, stdenv
, cmake
, pkg-config , pkg-config
, boost , boost
, curl , curl
@ -12,13 +14,11 @@
, libopenmpt , libopenmpt
, mpg123 , mpg123
, ncurses , ncurses
, lib
, stdenv
, taglib , taglib
# Linux Dependencies # Linux Dependencies
, alsa-lib , alsa-lib
, pulseaudio , pulseaudio
, systemdSupport ? stdenv.isLinux , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd , systemd
# Darwin Dependencies # Darwin Dependencies
, Cocoa , Cocoa

View File

@ -44,7 +44,7 @@
else if withMotif then "motif" else if withMotif then "motif"
else if withAthena then "athena" else if withAthena then "athena"
else "lucid") else "lucid")
, withSystemd ? stdenv.isLinux, systemd , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
}: }:
assert (libXft != null) -> libpng != null; # probably a bug assert (libXft != null) -> libpng != null; # probably a bug

View File

@ -25,7 +25,7 @@
# optional server deps # optional server deps
, libmicrohttpd , libmicrohttpd
, libsodium , libsodium
, withSystemd ? stdenv.isLinux , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd ? null , systemd ? null
# options # options

View File

@ -26,12 +26,11 @@
, openvdb , openvdb
, pcre , pcre
, qhull , qhull
, systemd
, tbb , tbb
, wxGTK31 , wxGTK31
, xorg , xorg
, fetchpatch , fetchpatch
, withSystemd ? stdenv.isLinux , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
}: }:
let let
wxGTK-prusa = wxGTK31.overrideAttrs (old: rec { wxGTK-prusa = wxGTK31.overrideAttrs (old: rec {

View File

@ -5,7 +5,7 @@
, pkg-config , pkg-config
, scdoc , scdoc
, stdenv , stdenv
, systemdSupport ? stdenv.isLinux, systemd , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {

View File

@ -45,7 +45,7 @@
, ungoogled ? false, ungoogled-chromium , ungoogled ? false, ungoogled-chromium
# Optional dependencies: # Optional dependencies:
, libgcrypt ? null # cupsSupport , libgcrypt ? null # cupsSupport
, systemdSupport ? stdenv.isLinux , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd , systemd
}: }:

View File

@ -17,7 +17,7 @@
, Security , Security
, withKeyring ? true , withKeyring ? true
, libsecret , libsecret
, withSystemd ? stdenv.isLinux , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd , systemd
}: }:

View File

@ -24,7 +24,7 @@
, enableQt ? false , enableQt ? false
, qt5 , qt5
, nixosTests , nixosTests
, enableSystemd ? stdenv.isLinux , enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, enableDaemon ? true , enableDaemon ? true
, enableCli ? true , enableCli ? true
, installLib ? false , installLib ? false

View File

@ -8,7 +8,7 @@
, curl , curl
, sqlite , sqlite
, libnotify , libnotify
, withSystemd ? stdenv.isLinux , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd , systemd
}: }:

View File

@ -15,7 +15,7 @@ rec {
, iptables, e2fsprogs, xz, util-linux, xfsprogs, git , iptables, e2fsprogs, xz, util-linux, xfsprogs, git
, procps, rootlesskit, slirp4netns, fuse-overlayfs, nixosTests , procps, rootlesskit, slirp4netns, fuse-overlayfs, nixosTests
, clientOnly ? !stdenv.isLinux, symlinkJoin , clientOnly ? !stdenv.isLinux, symlinkJoin
, withSystemd ? stdenv.isLinux, systemd , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
, withBtrfs ? stdenv.isLinux, btrfs-progs , withBtrfs ? stdenv.isLinux, btrfs-progs
, withLvm ? stdenv.isLinux, lvm2 , withLvm ? stdenv.isLinux, lvm2
, withSeccomp ? stdenv.isLinux, libseccomp , withSeccomp ? stdenv.isLinux, libseccomp

View File

@ -6,9 +6,8 @@
, nixosTests , nixosTests
# Used by the NixOS module: # Used by the NixOS module:
, isNixOS ? false , isNixOS ? false
, enableXWayland ? true, xorg , enableXWayland ? true, xorg
, systemdSupport ? stdenv.isLinux , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
, dbusSupport ? true , dbusSupport ? true
, dbus , dbus
, trayEnabled ? systemdSupport && dbusSupport , trayEnabled ? systemdSupport && dbusSupport

View File

@ -1,7 +1,7 @@
{ lib, stdenv, fetchFromGitHub { lib, stdenv, fetchFromGitHub
, meson, ninja, pkg-config, scdoc, wayland-scanner , meson, ninja, pkg-config, scdoc, wayland-scanner
, wayland, wayland-protocols, runtimeShell , wayland, wayland-protocols, runtimeShell
, systemdSupport ? stdenv.isLinux, systemd , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {

View File

@ -21,7 +21,7 @@
, parallelBuild ? false , parallelBuild ? false
, systemd , systemd
, wxSupport ? true , wxSupport ? true
, systemdSupport ? stdenv.isLinux # systemd support in epmd , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd # systemd support in epmd
# updateScript deps # updateScript deps
, writeScript , writeScript
, common-updater-scripts , common-updater-scripts

View File

@ -52,7 +52,7 @@ let
, cgotoSupport ? false , cgotoSupport ? false
, embedSupport ? false , embedSupport ? false
, ipv6Support ? true , ipv6Support ? true
, systemdSupport ? stdenv.isLinux , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd
, valgrindSupport ? !stdenv.isDarwin && lib.meta.availableOn stdenv.hostPlatform valgrind , valgrindSupport ? !stdenv.isDarwin && lib.meta.availableOn stdenv.hostPlatform valgrind
, ztsSupport ? apxs2Support , ztsSupport ? apxs2Support
}@args: }@args:

View File

@ -3,7 +3,7 @@
, fetchurl , fetchurl
, pkg-config , pkg-config
, expat , expat
, enableSystemd ? stdenv.isLinux && !stdenv.hostPlatform.isStatic , enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemdMinimal
, systemdMinimal , systemdMinimal
, audit , audit
, libapparmor , libapparmor

View File

@ -21,7 +21,7 @@
, docbook_xml_dtd_412 , docbook_xml_dtd_412
, gtk-doc , gtk-doc
, coreutils , coreutils
, useSystemd ? stdenv.isLinux , useSystemd ? lib.meta.availableOn stdenv.hostPlatform systemdMinimal
, systemdMinimal , systemdMinimal
, elogind , elogind
# A few tests currently fail on musl (polkitunixusertest, polkitunixgrouptest, polkitidentitytest segfault). # A few tests currently fail on musl (polkitunixusertest, polkitunixgrouptest, polkitidentitytest segfault).

View File

@ -24,7 +24,7 @@
, zlib , zlib
, icu , icu
, systemd , systemd
, systemdSupport ? stdenv.hostPlatform.isLinux , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd
, nixosTests , nixosTests
}: }:

View File

@ -63,7 +63,7 @@
, addOpenGLRunpath , addOpenGLRunpath
, enableGeoLocation ? true , enableGeoLocation ? true
, withLibsecret ? true , withLibsecret ? true
, systemdSupport ? stdenv.isLinux , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd
}: }:
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {

View File

@ -6,7 +6,7 @@
, systemd , systemd
, check , check
, subunit , subunit
, withSystemd ? stdenv.isLinux , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {

View File

@ -9,7 +9,7 @@
, libtiff , libtiff
, pam , pam
, dbus , dbus
, enableSystemd ? stdenv.isLinux , enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd , systemd
, acl , acl
, gmp , gmp

View File

@ -5,7 +5,7 @@
, gtk2, gdk-pixbuf, gdk-pixbuf-xlib, libxml2, pam , gtk2, gdk-pixbuf, gdk-pixbuf-xlib, libxml2, pam
, systemd, coreutils , systemd, coreutils
, forceInstallAllHacks ? false , forceInstallAllHacks ? false
, withSystemd ? stdenv.isLinux , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {

View File

@ -7,7 +7,7 @@
# `ps` with systemd support is able to properly report different # `ps` with systemd support is able to properly report different
# attributes like unit name, so we want to have it on linux. # attributes like unit name, so we want to have it on linux.
, withSystemd ? stdenv.isLinux && !stdenv.hostPlatform.isStatic , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd , systemd
# procps is mostly Linux-only. Most commands require a running Linux # procps is mostly Linux-only. Most commands require a running Linux

View File

@ -6,7 +6,7 @@
, ncurses , ncurses
, pamSupport ? true , pamSupport ? true
, pam , pam
, systemdSupport ? stdenv.isLinux && !stdenv.hostPlatform.isStatic , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd , systemd
, nlsSupport ? true , nlsSupport ? true
, translateManpages ? true , translateManpages ? true

View File

@ -26,8 +26,7 @@
, python3 , python3
, rustPlatform , rustPlatform
, openssl , openssl
, systemd , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
, withSystemd ? stdenv.isLinux
, zlib , zlib
, rsync , rsync
, withCockpit ? true , withCockpit ? true

View File

@ -1,5 +1,6 @@
{ lib, stdenv, fetchFromGitHub, python3, openssl, rustPlatform { lib, stdenv, fetchFromGitHub, python3, openssl, rustPlatform
, enableSystemd ? stdenv.isLinux, nixosTests , enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
, nixosTests
, enableRedis ? true , enableRedis ? true
, callPackage , callPackage
}: }:

View File

@ -1,9 +1,10 @@
{ enableSystemd ? stdenv.isLinux { lib
, stdenv
, systemd
, enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, fetchFromGitHub , fetchFromGitHub
, fetchpatch , fetchpatch
, lib
, python3 , python3
, stdenv
}: }:
python3.pkgs.buildPythonPackage rec { python3.pkgs.buildPythonPackage rec {

View File

@ -10,7 +10,7 @@
, libuv , libuv
, libwebsockets , libwebsockets
, openssl , openssl
, withSystemd ? stdenv.isLinux , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd , systemd
, fetchpatch , fetchpatch
}: }:

View File

@ -10,7 +10,7 @@
, systemd , systemd
, wafHook , wafHook
, websocketpp , websocketpp
, withSystemd ? stdenv.isLinux , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, withWebSocket ? true , withWebSocket ? true
}: }:

View File

@ -1,6 +1,6 @@
{ lib, stdenv, fetchurl, lua, pkg-config, nixosTests { lib, stdenv, fetchurl, lua, pkg-config, nixosTests
, tcl, which, ps, getconf , tcl, which, ps, getconf
, withSystemd ? stdenv.isLinux && !stdenv.hostPlatform.isStatic, systemd , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
# dependency ordering is broken at the moment when building with openssl # dependency ordering is broken at the moment when building with openssl
, tlsSupport ? !stdenv.hostPlatform.isStatic, openssl , tlsSupport ? !stdenv.hostPlatform.isStatic, openssl
}: }:

View File

@ -9,7 +9,7 @@
, x11Support ? false , x11Support ? false
, useSystemd ? stdenv.isLinux , useSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, # Whether to support the JACK sound system as a backend. , # Whether to support the JACK sound system as a backend.
jackaudioSupport ? false jackaudioSupport ? false

View File

@ -3,7 +3,7 @@
# plugins: list of strings, eg. [ "python2" "python3" ] # plugins: list of strings, eg. [ "python2" "python3" ]
, plugins ? [] , plugins ? []
, pam, withPAM ? stdenv.isLinux , pam, withPAM ? stdenv.isLinux
, systemd, withSystemd ? stdenv.isLinux , systemd, withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, libcap, withCap ? stdenv.isLinux , libcap, withCap ? stdenv.isLinux
, python2, python3, ncurses , python2, python3, ncurses
, ruby, php , ruby, php

View File

@ -1,7 +1,7 @@
{ lib, stdenv, fetchurl, pkg-config, python3, bluez { lib, stdenv, fetchurl, pkg-config, python3, bluez
, tcl, acl, kmod, coreutils, shadow, util-linux, udev , tcl, acl, kmod, coreutils, shadow, util-linux, udev
, alsaSupport ? stdenv.isLinux, alsa-lib , alsaSupport ? stdenv.isLinux, alsa-lib
, systemdSupport ? stdenv.isLinux, systemd , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {

View File

@ -6,7 +6,7 @@
, libevent , libevent
, ncurses , ncurses
, pkg-config , pkg-config
, withSystemd ? stdenv.isLinux && !stdenv.hostPlatform.isStatic, systemd , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
, withUtf8proc ? true, utf8proc # gets Unicode updates faster than glibc , withUtf8proc ? true, utf8proc # gets Unicode updates faster than glibc
, withUtempter ? stdenv.isLinux && !stdenv.hostPlatform.isMusl, libutempter , withUtempter ? stdenv.isLinux && !stdenv.hostPlatform.isMusl, libutempter
}: }:

View File

@ -8,7 +8,7 @@
, pkg-config , pkg-config
, systemd , systemd
, hostname , hostname
, withSystemd ? stdenv.isLinux , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, extraTags ? [ ] , extraTags ? [ ]
}: }:

View File

@ -2,7 +2,7 @@
, openssl , openssl
, ppp , ppp
, systemd , systemd
, withSystemd ? stdenv.isLinux , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, withPpp ? stdenv.isLinux , withPpp ? stdenv.isLinux
}: }:

View File

@ -7,7 +7,7 @@
, openssl , openssl
, openssl_1_1 , openssl_1_1
, pam , pam
, useSystemd ? stdenv.isLinux , useSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd , systemd
, update-systemd-resolved , update-systemd-resolved
, util-linux , util-linux

View File

@ -22,7 +22,7 @@
, enableCommandNotFound ? false , enableCommandNotFound ? false
, enableBashCompletion ? false , enableBashCompletion ? false
, bash-completion ? null , bash-completion ? null
, enableSystemd ? stdenv.isLinux , enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd , systemd
}: }:

View File

@ -2,8 +2,7 @@
, ncurses , ncurses
, IOKit , IOKit
, sensorsSupport ? stdenv.isLinux, lm_sensors , sensorsSupport ? stdenv.isLinux, lm_sensors
, systemdSupport ? stdenv.isLinux && !stdenv.hostPlatform.isStatic , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
, systemd
}: }:
assert systemdSupport -> stdenv.isLinux; assert systemdSupport -> stdenv.isLinux;

View File

@ -30,7 +30,7 @@
, xz , xz
# Conditionally recommended # Conditionally recommended
, systemdSupport ? stdenv.isLinux , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd , systemd
# Recommended # Recommended

View File

@ -10,7 +10,7 @@
, fastJson , fastJson
, withKrb5 ? true , withKrb5 ? true
, libkrb5 , libkrb5
, withSystemd ? stdenv.isLinux , withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd , systemd
, withJemalloc ? true , withJemalloc ? true
, jemalloc , jemalloc

View File

@ -1,11 +1,13 @@
{ beam { lib
, beam
, callPackage , callPackage
, openssl_1_1 , openssl_1_1
, wxGTK32 , wxGTK32
, buildPackages , buildPackages
, stdenv , stdenv
, wxSupport ? true , wxSupport ? true
, systemdSupport ? stdenv.isLinux , systemd
, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd
}: }:
let let