From 9f7472222cbfe03b09a6caec2ff7b50595f43483 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 23 Jul 2023 18:58:40 +0100 Subject: [PATCH] treewide: use 'lib.getExe' when possible Don't use it in wireguard to keep it consistent, as only half the commands could use it. --- home/mail/accounts/default.nix | 2 +- home/mail/himalaya/default.nix | 2 +- home/wm/default.nix | 4 ++-- home/wm/i3/default.nix | 6 +++--- home/wm/screen-lock/default.nix | 2 +- modules/services/drone/runner-docker/default.nix | 3 +-- modules/services/drone/runner-exec/default.nix | 3 +-- modules/services/flood/default.nix | 2 +- modules/services/lohr/default.nix | 4 +--- modules/services/nginx/sso/default.nix | 4 ++-- pkgs/ff2mpv-go/default.nix | 2 +- pkgs/unbound-zones-adblock/default.nix | 2 +- 12 files changed, 16 insertions(+), 20 deletions(-) diff --git a/home/mail/accounts/default.nix b/home/mail/accounts/default.nix index f513605..9ccc643 100644 --- a/home/mail/accounts/default.nix +++ b/home/mail/accounts/default.nix @@ -8,7 +8,7 @@ let realName = lib.mkDefault "Bruno BELANYI"; userName = lib.mkDefault (mkMailAddress address domain); passwordCommand = - lib.mkDefault [ "${pkgs.ambroisie.bw-pass}/bin/bw-pass" "Mail" passName ]; + lib.mkDefault [ (lib.getExe pkgs.ambroisie.bw-pass) "Mail" passName ]; address = mkMailAddress address domain; aliases = builtins.map (lib.flip mkMailAddress domain) aliases; diff --git a/home/mail/himalaya/default.nix b/home/mail/himalaya/default.nix index c2d3b05..849a415 100644 --- a/home/mail/himalaya/default.nix +++ b/home/mail/himalaya/default.nix @@ -9,7 +9,7 @@ in settings = { notify-cmd = let - notify-send = "${pkgs.libnotify}/bin/notify-send"; + notify-send = lib.getExe pkgs.libnotify; in pkgs.writeScript "mail-notifier" '' SENDER="$1" diff --git a/home/wm/default.nix b/home/wm/default.nix index fb9ecee..6a615e5 100644 --- a/home/wm/default.nix +++ b/home/wm/default.nix @@ -47,8 +47,8 @@ in command = mkOption { type = types.str; - default = "${pkgs.i3lock}/bin/i3lock -n -c 000000"; - example = "\${pkgs.i3lock}/bin/i3lock -n -i lock.png"; + default = "${lib.getExe pkgs.i3lock} -n -c 000000"; + example = "\${lib.getExe pkgs.i3lock} -n -i lock.png"; description = "Locker command to run"; }; diff --git a/home/wm/i3/default.nix b/home/wm/i3/default.nix index 34c1db4..d1dbe2c 100644 --- a/home/wm/i3/default.nix +++ b/home/wm/i3/default.nix @@ -27,13 +27,13 @@ let genMovementBindings = f: addVimKeyBindings (lib.my.genAttrs' movementKeys f); # Used in multiple scripts to show messages through keybindings - notify-send = "${pkgs.libnotify}/bin/notify-send"; + notify-send = lib.getExe pkgs.libnotify; # Screen backlight management - changeBacklight = "${pkgs.ambroisie.change-backlight}/bin/change-backlight"; + changeBacklight = lib.getExe pkgs.ambroisie.change-backlight; # Audio and volume management - changeAudio = "${pkgs.ambroisie.change-audio}/bin/change-audio"; + changeAudio = lib.getExe pkgs.ambroisie.change-audio; # Lock management toggleXautolock = diff --git a/home/wm/screen-lock/default.nix b/home/wm/screen-lock/default.nix index 95060b8..3b2ead6 100644 --- a/home/wm/screen-lock/default.nix +++ b/home/wm/screen-lock/default.nix @@ -5,7 +5,7 @@ let notficationCmd = let duration = toString (cfg.notify.delay * 1000); - notifyCmd = "${pkgs.libnotify}/bin/notify-send -u critical -t ${duration}"; + notifyCmd = "${lib.getExe pkgs.libnotify} -u critical -t ${duration}"; in # Needs to be surrounded by quotes for systemd to launch it correctly ''"${notifyCmd} -- 'Locking in ${toString cfg.notify.delay} seconds'"''; diff --git a/modules/services/drone/runner-docker/default.nix b/modules/services/drone/runner-docker/default.nix index 6ccb5fe..e53c608 100644 --- a/modules/services/drone/runner-docker/default.nix +++ b/modules/services/drone/runner-docker/default.nix @@ -2,7 +2,6 @@ let cfg = config.my.services.drone; hasRunner = (name: builtins.elem name cfg.runners); - dockerPkg = pkgs.drone-runner-docker; in { config = lib.mkIf (cfg.enable && hasRunner "docker") { @@ -25,7 +24,7 @@ in EnvironmentFile = [ cfg.sharedSecretFile ]; - ExecStart = "${dockerPkg}/bin/drone-runner-docker"; + ExecStart = lib.getExe pkgs.drone-runner-docker; User = "drone-runner-docker"; Group = "drone-runner-docker"; }; diff --git a/modules/services/drone/runner-exec/default.nix b/modules/services/drone/runner-exec/default.nix index f0dddb9..a9bb563 100644 --- a/modules/services/drone/runner-exec/default.nix +++ b/modules/services/drone/runner-exec/default.nix @@ -2,7 +2,6 @@ let cfg = config.my.services.drone; hasRunner = (name: builtins.elem name cfg.runners); - execPkg = pkgs.drone-runner-exec; in { config = lib.mkIf (cfg.enable && hasRunner "exec") { @@ -53,7 +52,7 @@ in EnvironmentFile = [ cfg.sharedSecretFile ]; - ExecStart = "${execPkg}/bin/drone-runner-exec"; + ExecStart = lib.getExe pkgs.drone-runner-exec; User = "drone-runner-exec"; Group = "drone-runner-exec"; }; diff --git a/modules/services/flood/default.nix b/modules/services/flood/default.nix index ae8e219..ff5d941 100644 --- a/modules/services/flood/default.nix +++ b/modules/services/flood/default.nix @@ -30,7 +30,7 @@ in serviceConfig = { ExecStart = lib.concatStringsSep " " [ - "${pkgs.flood}/bin/flood" + (lib.getExe pkgs.flood) "--port ${builtins.toString cfg.port}" "--rundir /var/lib/${cfg.stateDir}" ]; diff --git a/modules/services/lohr/default.nix b/modules/services/lohr/default.nix index f43bc40..245567c 100644 --- a/modules/services/lohr/default.nix +++ b/modules/services/lohr/default.nix @@ -4,8 +4,6 @@ let cfg = config.my.services.lohr; settingsFormat = pkgs.formats.yaml { }; - lohrPkg = pkgs.ambroisie.lohr; - lohrStateDirectory = "lohr"; lohrHome = "/var/lib/lohr/"; in @@ -80,7 +78,7 @@ in let configFile = settingsFormat.generate "lohr-config.yaml" cfg.setting; in - "${lohrPkg}/bin/lohr --config ${configFile}"; + "${lib.getExe pkgs.ambroisie.lohr} --config ${configFile}"; StateDirectory = lohrStateDirectory; WorkingDirectory = lohrHome; User = "lohr"; diff --git a/modules/services/nginx/sso/default.nix b/modules/services/nginx/sso/default.nix index 13292ec..cbb35d5 100644 --- a/modules/services/nginx/sso/default.nix +++ b/modules/services/nginx/sso/default.nix @@ -60,7 +60,7 @@ in WorkingDirectory = "/var/lib/nginx-sso"; # The files to be merged might not have the correct permissions ExecStartPre = ''+${pkgs.writeScript "merge-nginx-sso-config" '' - #!${pkgs.bash}/bin/bash + #!${lib.getExe pkgs.bash} rm -f '${confPath}' ${utils.genJqSecretsReplacementSnippet cfg.configuration confPath} @@ -70,7 +70,7 @@ in '' }''; ExecStart = lib.mkForce '' - ${pkg}/bin/nginx-sso \ + ${lib.getExe pkg} \ --config ${confPath} \ --frontend-dir ${pkg}/share/frontend ''; diff --git a/pkgs/ff2mpv-go/default.nix b/pkgs/ff2mpv-go/default.nix index dcdb7f3..fdd9201 100644 --- a/pkgs/ff2mpv-go/default.nix +++ b/pkgs/ff2mpv-go/default.nix @@ -12,7 +12,7 @@ buildGoModule rec { vendorHash = null; postPatch = '' - sed -i -e 's,"mpv","${mpv}/bin/mpv",' ff2mpv.go + sed -i -e 's,"mpv","${lib.getExe mpv}",' ff2mpv.go ''; postInstall = '' diff --git a/pkgs/unbound-zones-adblock/default.nix b/pkgs/unbound-zones-adblock/default.nix index 824a7d6..f8d89b1 100644 --- a/pkgs/unbound-zones-adblock/default.nix +++ b/pkgs/unbound-zones-adblock/default.nix @@ -10,7 +10,7 @@ stdenvNoCC.mkDerivation { installPhase = let gawkCmd = lib.concatStringsSep " " [ - ''${gawk}/bin/awk'' + (lib.getExe gawk) '''{sub(/\r$/,"")}'' ''{sub(/^127\.0\.0\.1/,"0.0.0.0")}'' ''BEGIN { OFS = "" }''