vpnc-scripts: only reference systemd when available

This fixes e.g. static builds, where systemd is unsupported.
This commit is contained in:
Alyssa Ross 2025-06-01 14:44:10 +02:00
parent 06892faa1a
commit 5ca7d9a48b

View file

@ -10,6 +10,7 @@
nettools, nettools,
openresolv, openresolv,
systemd, systemd,
withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
}: }:
stdenv.mkDerivation { stdenv.mkDerivation {
@ -36,7 +37,10 @@ stdenv.mkDerivation {
'' ''
+ lib.optionalString stdenv.hostPlatform.isLinux '' + lib.optionalString stdenv.hostPlatform.isLinux ''
substituteInPlace $out/bin/vpnc-script \ substituteInPlace $out/bin/vpnc-script \
--replace "/sbin/resolvconf" "${openresolv}/bin/resolvconf" \ --replace "/sbin/resolvconf" "${openresolv}/bin/resolvconf"
''
+ lib.optionalString withSystemd ''
substituteInPlace $out/bin/vpnc-script \
--replace "/usr/bin/resolvectl" "${systemd}/bin/resolvectl" --replace "/usr/bin/resolvectl" "${systemd}/bin/resolvectl"
'' ''
+ '' + ''