shishi: replace mkFlag with lib.enableFeature and lib.withFeature

+13 -21
+13 -21
pkgs/servers/shishi/default.nix
··· 6 }: 7 8 let 9 - mkFlag = trueStr: falseStr: cond: name: val: "--" 10 - + (if cond then trueStr else falseStr) 11 - + name 12 - + lib.optionalString (val != null && cond != false) "=${val}"; 13 - mkEnable = mkFlag "enable-" "disable-"; 14 - mkWith = mkFlag "with-" "without-"; 15 - mkOther = mkFlag "" "" true; 16 - 17 shouldUsePkg = pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null; 18 19 optPam = shouldUsePkg pam; ··· 37 buildInputs = [ libgcrypt libgpg-error libtasn1 optPam optLibidn optGnutls ]; 38 39 configureFlags = [ 40 - (mkOther "sysconfdir" "/etc") 41 - (mkOther "localstatedir" "/var") 42 - (mkEnable true "libgcrypt" null) 43 - (mkEnable (optPam != null) "pam" null) 44 - (mkEnable true "ipv6" null) 45 - (mkWith (optLibidn != null) "stringprep" null) 46 - (mkEnable (optGnutls != null) "starttls" null) 47 - (mkEnable true "des" null) 48 - (mkEnable true "3des" null) 49 - (mkEnable true "aes" null) 50 - (mkEnable true "md" null) 51 - (mkEnable false "null" null) 52 - (mkEnable true "arcfour" null) 53 ]; 54 55 NIX_CFLAGS_COMPILE
··· 6 }: 7 8 let 9 shouldUsePkg = pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null; 10 11 optPam = shouldUsePkg pam; ··· 29 buildInputs = [ libgcrypt libgpg-error libtasn1 optPam optLibidn optGnutls ]; 30 31 configureFlags = [ 32 + "--sysconfdir=/etc" 33 + "--localstatedir=/var" 34 + (enableFeature true "libgcrypt") 35 + (enableFeature (optPam != null) "pam") 36 + (enableFeature true "ipv6") 37 + (withFeature (optLibidn != null) "stringprep") 38 + (enableFeature (optGnutls != null) "starttls") 39 + (enableFeature true "des") 40 + (enableFeature true "3des") 41 + (enableFeature true "aes") 42 + (enableFeature true "md") 43 + (enableFeature false "null") 44 + (enableFeature true "arcfour") 45 ]; 46 47 NIX_CFLAGS_COMPILE