From 03fdb31290d1a4a8d23f52206283450d304c3841 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Tue, 29 Jul 2025 12:20:22 -0500 Subject: [PATCH] treewide: add missing package options (#7575) Add options to support more flexible module configurations. Signed-off-by: Austin Horstman --- modules/programs/browserpass.nix | 20 +++++++++++--------- modules/programs/info.nix | 19 ++++++++++--------- modules/programs/irssi.nix | 4 +++- modules/programs/powerline-go.nix | 8 +++++--- modules/programs/zplug.nix | 6 ++++-- modules/services/barrier.nix | 5 ++++- modules/services/blueman-applet.nix | 7 ++++++- modules/services/caffeine.nix | 4 +++- modules/services/devilspie2.nix | 4 +++- modules/services/dropbox.nix | 6 ++++-- modules/services/fluidsynth.nix | 4 +++- modules/services/getmail.nix | 4 +++- modules/services/gnome-keyring.nix | 4 +++- modules/services/grobi.nix | 4 +++- modules/services/hound.nix | 6 ++++-- modules/services/kbfs.nix | 6 ++++-- modules/services/keybase.nix | 10 +++++++--- modules/services/keynav.nix | 4 +++- modules/services/mpris-proxy.nix | 8 ++++++-- modules/services/muchsync.nix | 4 +++- modules/services/network-manager-applet.nix | 6 ++++-- modules/services/pasystray.nix | 4 +++- modules/services/plan9port.nix | 6 ++++-- modules/services/poweralertd.nix | 4 +++- modules/services/psd.nix | 8 +++++--- modules/services/random-background.nix | 4 +++- modules/services/rsibreak.nix | 6 +++--- modules/services/sctd.nix | 8 +++++--- modules/services/ssh-agent.nix | 4 +++- modules/services/systembus-notify.nix | 8 ++++++-- modules/services/tahoe-lafs.nix | 8 ++++++-- modules/services/udiskie.nix | 4 +++- modules/services/xcape.nix | 4 +++- modules/services/xsuspender.nix | 6 ++++-- 34 files changed, 147 insertions(+), 70 deletions(-) diff --git a/modules/programs/browserpass.nix b/modules/programs/browserpass.nix index 01a49308b..56b12e20f 100644 --- a/modules/programs/browserpass.nix +++ b/modules/programs/browserpass.nix @@ -20,6 +20,8 @@ in programs.browserpass = { enable = lib.mkEnableOption "the browserpass extension host application"; + package = lib.mkPackageOption pkgs "browserpass" { }; + browsers = lib.mkOption { type = lib.types.listOf (lib.types.enum browsers); default = browsers; @@ -47,7 +49,7 @@ in # Policies are read from `/etc/brave/policies` only # https://github.com/brave/brave-browser/issues/19052 "${dir}/com.github.browserpass.native.json".source = - "${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json"; + "${cfg.package}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json"; } ] else if x == "chrome" then @@ -61,9 +63,9 @@ in [ { "${dir}/com.github.browserpass.native.json".source = - "${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json"; + "${cfg.package}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json"; "${dir}/../policies/managed/com.github.browserpass.native.json".source = - "${pkgs.browserpass}/lib/browserpass/policies/chromium/com.github.browserpass.native.json"; + "${cfg.package}/lib/browserpass/policies/chromium/com.github.browserpass.native.json"; } ] else if x == "chromium" then @@ -77,11 +79,11 @@ in [ { "${dir}/com.github.browserpass.native.json".source = - "${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json"; + "${cfg.package}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json"; } { "${dir}/../policies/managed/com.github.browserpass.native.json".source = - "${pkgs.browserpass}/lib/browserpass/policies/chromium/com.github.browserpass.native.json"; + "${cfg.package}/lib/browserpass/policies/chromium/com.github.browserpass.native.json"; } ] else if x == "firefox" then @@ -95,7 +97,7 @@ in [ { "${dir}/com.github.browserpass.native.json".source = - "${pkgs.browserpass}/lib/browserpass/hosts/firefox/com.github.browserpass.native.json"; + "${cfg.package}/lib/browserpass/hosts/firefox/com.github.browserpass.native.json"; } ] else if x == "librewolf" then @@ -109,7 +111,7 @@ in [ { "${dir}/com.github.browserpass.native.json".source = - "${pkgs.browserpass}/lib/browserpass/hosts/firefox/com.github.browserpass.native.json"; + "${cfg.package}/lib/browserpass/hosts/firefox/com.github.browserpass.native.json"; } ] @@ -124,9 +126,9 @@ in [ { "${dir}/com.github.browserpass.native.json".source = - "${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json"; + "${cfg.package}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json"; "${dir}/../policies/managed/com.github.browserpass.native.json".source = - "${pkgs.browserpass}/lib/browserpass/policies/chromium/com.github.browserpass.native.json"; + "${cfg.package}/lib/browserpass/policies/chromium/com.github.browserpass.native.json"; } ] else diff --git a/modules/programs/info.nix b/modules/programs/info.nix index 157d3be43..a3042a89d 100644 --- a/modules/programs/info.nix +++ b/modules/programs/info.nix @@ -26,12 +26,6 @@ let cfg = config.programs.info; - - # Installs this package -- the interactive just means that it - # includes the curses `info` program. We also use `install-info` - # from this package in the activation script. - infoPkg = pkgs.texinfoInteractive; - in { imports = [ @@ -41,11 +35,18 @@ in '') ]; - options.programs.info.enable = lib.mkEnableOption "GNU Info"; + options.programs.info = { + enable = lib.mkEnableOption "GNU Info"; + + # Installs this package -- the interactive just means that it + # includes the curses `info` program. We also use `install-info` + # from this package in the activation script. + package = lib.mkPackageOption pkgs "texinfo" { default = "texinfoInteractive"; }; + }; config = lib.mkIf cfg.enable { home.packages = [ - infoPkg + cfg.package # Make sure the target directory is a real directory. (pkgs.runCommandLocal "dummy-info-dir1" { } "mkdir -p $out/share/info") @@ -63,7 +64,7 @@ in PATH="${ lib.makeBinPath [ pkgs.gzip - infoPkg + cfg.package ] }''${PATH:+:}$PATH" \ find -L "${infoPath}" \( -name '*.info' -o -name '*.info.gz' \) \ diff --git a/modules/programs/irssi.nix b/modules/programs/irssi.nix index bc4135068..59c5f4835 100644 --- a/modules/programs/irssi.nix +++ b/modules/programs/irssi.nix @@ -186,6 +186,8 @@ in programs.irssi = { enable = lib.mkEnableOption "the Irssi chat client"; + package = lib.mkPackageOption pkgs "irssi" { nullable = true; }; + extraConfig = mkOption { default = ""; description = "These lines are appended to the Irssi configuration."; @@ -226,7 +228,7 @@ in }; config = lib.mkIf cfg.enable { - home.packages = [ pkgs.irssi ]; + home.packages = lib.mkIf (cfg.package != null) [ cfg.package ]; home.file.".irssi/config".text = '' settings = { diff --git a/modules/programs/powerline-go.nix b/modules/programs/powerline-go.nix index e89f971af..e523526a8 100644 --- a/modules/programs/powerline-go.nix +++ b/modules/programs/powerline-go.nix @@ -60,6 +60,8 @@ in programs.powerline-go = { enable = lib.mkEnableOption "Powerline-go, a beautiful and useful low-latency prompt for your shell"; + package = lib.mkPackageOption pkgs "powerline-go" { }; + modules = mkOption { default = null; type = types.nullOr (types.listOf types.str); @@ -157,7 +159,7 @@ in local old_exit_status=$? ${ if evalMode then "eval " else "PS1=" - }"$(${pkgs.powerline-go}/bin/powerline-go -error $old_exit_status -shell bash${commandLineArguments})" + }"$(${lib.getExe cfg.package} -error $old_exit_status -shell bash${commandLineArguments})" ${cfg.extraUpdatePS1} return $old_exit_status } @@ -171,7 +173,7 @@ in function powerline_precmd() { ${ if evalMode then "eval " else "PS1=" - }"$(${pkgs.powerline-go}/bin/powerline-go -error $? -shell zsh${commandLineArguments})" + }"$(${lib.getExe cfg.package} -error $? -shell zsh${commandLineArguments})" ${cfg.extraUpdatePS1} } @@ -192,7 +194,7 @@ in # https://github.com/justjanne/powerline-go#fish programs.fish.interactiveShellInit = mkIf (cfg.enable && config.programs.fish.enable) '' function fish_prompt - eval ${pkgs.powerline-go}/bin/powerline-go -error $status -jobs (count (jobs -p))${commandLineArguments} + eval ${lib.getExe cfg.package} -error $status -jobs (count (jobs -p))${commandLineArguments} ${cfg.extraUpdatePS1} end ''; diff --git a/modules/programs/zplug.nix b/modules/programs/zplug.nix index ff75378dc..83211904c 100644 --- a/modules/programs/zplug.nix +++ b/modules/programs/zplug.nix @@ -28,6 +28,8 @@ in options.programs.zsh.zplug = { enable = lib.mkEnableOption "zplug - a zsh plugin manager"; + package = lib.mkPackageOption pkgs "zplug" { }; + plugins = mkOption { default = [ ]; type = types.listOf pluginModule; @@ -44,12 +46,12 @@ in }; config = lib.mkIf cfg.enable { - home.packages = [ pkgs.zplug ]; + home.packages = [ cfg.package ]; programs.zsh.initContent = lib.mkOrder 550 '' export ZPLUG_HOME=${cfg.zplugHome} - source ${pkgs.zplug}/share/zplug/init.zsh + source ${cfg.package}/share/zplug/init.zsh ${optionalString (cfg.plugins != [ ]) '' ${lib.concatStrings ( diff --git a/modules/services/barrier.nix b/modules/services/barrier.nix index 582c33b0c..c5ac8b9ac 100644 --- a/modules/services/barrier.nix +++ b/modules/services/barrier.nix @@ -6,6 +6,7 @@ }: let inherit (lib) + getExe' mkEnableOption mkOption optional @@ -26,6 +27,8 @@ in options.services.barrier = { + package = lib.mkPackageOption pkgs "barrier" { }; + client = { enable = mkEnableOption "Barrier Client daemon"; @@ -81,7 +84,7 @@ in Service.ExecStart = with cfg.client; toString ( - [ "${pkgs.barrier}/bin/barrierc" ] + [ "${getExe' cfg.package "barrierc"}" ] ++ optional (name != null) "--name ${name}" ++ optional (!enableCrypto) "--disable-crypto" ++ optional enableDragDrop "--enable-drag-drop" diff --git a/modules/services/blueman-applet.nix b/modules/services/blueman-applet.nix index b6843d9cd..a6697805f 100644 --- a/modules/services/blueman-applet.nix +++ b/modules/services/blueman-applet.nix @@ -4,6 +4,9 @@ pkgs, ... }: +let + cfg = config.services.blueman-applet; +in { options = { services.blueman-applet = { @@ -19,6 +22,8 @@ ``` ''; }; + + package = lib.mkPackageOption pkgs "blueman" { }; }; }; @@ -43,7 +48,7 @@ }; Service = { - ExecStart = "${pkgs.blueman}/bin/blueman-applet"; + ExecStart = "${lib.getExe' cfg.package "blueman-applet"}"; }; }; }; diff --git a/modules/services/caffeine.nix b/modules/services/caffeine.nix index b791ccc71..b42605cf7 100644 --- a/modules/services/caffeine.nix +++ b/modules/services/caffeine.nix @@ -13,6 +13,8 @@ in options = { services.caffeine = { enable = lib.mkEnableOption "Caffeine service"; + + package = lib.mkPackageOption pkgs "caffeine-ng" { }; }; }; @@ -36,7 +38,7 @@ in ProtectSystem = "full"; Type = "exec"; Slice = "session.slice"; - ExecStart = "${pkgs.caffeine-ng}/bin/caffeine"; + ExecStart = "${lib.getExe' cfg.package "caffeine"}"; }; }; }; diff --git a/modules/services/devilspie2.nix b/modules/services/devilspie2.nix index 8c0a20604..75957aede 100644 --- a/modules/services/devilspie2.nix +++ b/modules/services/devilspie2.nix @@ -16,6 +16,8 @@ in Devilspie2, a window matching utility, allowing the user to perform scripted actions on windows as they are created''; + package = lib.mkPackageOption pkgs "devilspie2" { }; + config = lib.mkOption { type = lib.types.lines; default = ""; @@ -37,7 +39,7 @@ in ]; systemd.user.services.devilspie2 = { - Service.ExecStart = "${pkgs.devilspie2}/bin/devilspie2"; + Service.ExecStart = "${lib.getExe cfg.package}"; Unit = { Description = "devilspie2"; After = [ "graphical-session.target" ]; diff --git a/modules/services/dropbox.nix b/modules/services/dropbox.nix index d4891c90e..b38bdd7fa 100644 --- a/modules/services/dropbox.nix +++ b/modules/services/dropbox.nix @@ -8,7 +8,7 @@ let cfg = config.services.dropbox; baseDir = ".dropbox-hm"; - dropboxCmd = "${pkgs.dropbox-cli}/bin/dropbox"; + dropboxCmd = "${lib.getExe' cfg.package "dropbox"}"; homeBaseDir = "${config.home.homeDirectory}/${baseDir}"; in @@ -19,6 +19,8 @@ in services.dropbox = { enable = lib.mkEnableOption "Dropbox daemon"; + package = lib.mkPackageOption pkgs "dropbox-cli" { }; + path = lib.mkOption { type = lib.types.path; default = "${config.home.homeDirectory}/Dropbox"; @@ -34,7 +36,7 @@ in (lib.hm.assertions.assertPlatform "services.dropbox" pkgs lib.platforms.linux) ]; - home.packages = [ pkgs.dropbox-cli ]; + home.packages = [ cfg.package ]; systemd.user.services.dropbox = { Unit = { diff --git a/modules/services/fluidsynth.nix b/modules/services/fluidsynth.nix index 1d10dc460..dd56413d1 100644 --- a/modules/services/fluidsynth.nix +++ b/modules/services/fluidsynth.nix @@ -17,6 +17,8 @@ in services.fluidsynth = { enable = lib.mkEnableOption "fluidsynth midi synthesizer"; + package = lib.mkPackageOption pkgs "fluidsynth" { }; + soundFont = mkOption { type = types.path; default = "${pkgs.soundfont-fluid}/share/soundfonts/FluidR3_GM2-2.sf2"; @@ -71,7 +73,7 @@ in }; Service = { - ExecStart = "${pkgs.fluidsynth}/bin/fluidsynth -a pulseaudio -si ${lib.concatStringsSep " " cfg.extraOptions} ${cfg.soundFont}"; + ExecStart = "${lib.getExe cfg.package} -a pulseaudio -si ${lib.concatStringsSep " " cfg.extraOptions} ${cfg.soundFont}"; }; }; }; diff --git a/modules/services/getmail.nix b/modules/services/getmail.nix index 880252bc3..7eb206af9 100644 --- a/modules/services/getmail.nix +++ b/modules/services/getmail.nix @@ -19,6 +19,8 @@ in services.getmail = { enable = lib.mkEnableOption "the getmail systemd service to automatically retrieve mail"; + package = lib.mkPackageOption pkgs "getmail" { default = "getmail6"; }; + frequency = lib.mkOption { type = lib.types.str; default = "*:0/5"; @@ -45,7 +47,7 @@ in Description = "getmail email fetcher"; }; Service = { - ExecStart = "${pkgs.getmail6}/bin/getmail ${configFiles}"; + ExecStart = "${lib.getExe cfg.package} ${configFiles}"; }; }; diff --git a/modules/services/gnome-keyring.nix b/modules/services/gnome-keyring.nix index 55e813f0b..872c48ac1 100644 --- a/modules/services/gnome-keyring.nix +++ b/modules/services/gnome-keyring.nix @@ -16,6 +16,8 @@ in services.gnome-keyring = { enable = lib.mkEnableOption "GNOME Keyring"; + package = lib.mkPackageOption pkgs "gnome-keyring" { }; + components = lib.mkOption { type = lib.types.listOf ( lib.types.enum [ @@ -63,7 +65,7 @@ in ++ lib.optional (cfg.components != [ ]) ("--components=" + lib.concatStringsSep "," cfg.components) ); in - "${pkgs.gnome-keyring}/bin/gnome-keyring-daemon ${args}"; + "${lib.getExe' cfg.package "gnome-keyring-daemon"} ${args}"; Restart = "on-abort"; }; diff --git a/modules/services/grobi.nix b/modules/services/grobi.nix index d0ff05578..eb2daef6e 100644 --- a/modules/services/grobi.nix +++ b/modules/services/grobi.nix @@ -19,6 +19,8 @@ in services.grobi = { enable = lib.mkEnableOption "the grobi display setup daemon"; + package = lib.mkPackageOption pkgs "grobi" { }; + executeAfter = mkOption { type = with types; listOf str; default = [ ]; @@ -87,7 +89,7 @@ in Service = { Type = "simple"; - ExecStart = "${pkgs.grobi}/bin/grobi watch -v"; + ExecStart = "${lib.getExe cfg.package} watch -v"; Restart = "always"; RestartSec = "2s"; Environment = [ "PATH=${pkgs.xorg.xrandr}/bin:${pkgs.bash}/bin" ]; diff --git a/modules/services/hound.nix b/modules/services/hound.nix index 5b061bfcf..0d6198cf8 100644 --- a/modules/services/hound.nix +++ b/modules/services/hound.nix @@ -30,6 +30,8 @@ in options.services.hound = { enable = lib.mkEnableOption "hound"; + package = lib.mkPackageOption pkgs "hound" { }; + maxConcurrentIndexers = mkOption { type = types.ints.positive; default = 2; @@ -70,7 +72,7 @@ in (lib.hm.assertions.assertPlatform "services.hound" pkgs lib.platforms.linux) ]; - home.packages = [ pkgs.hound ]; + home.packages = [ cfg.package ]; systemd.user.services.hound = { Unit = { @@ -90,7 +92,7 @@ in ] }" ]; - ExecStart = "${pkgs.hound}/bin/houndd ${lib.concatStringsSep " " houndOptions}"; + ExecStart = "${lib.getExe' cfg.package "houndd"} ${lib.concatStringsSep " " houndOptions}"; }; }; }; diff --git a/modules/services/kbfs.nix b/modules/services/kbfs.nix index 27883ae75..4a427d40c 100644 --- a/modules/services/kbfs.nix +++ b/modules/services/kbfs.nix @@ -14,6 +14,8 @@ in services.kbfs = { enable = lib.mkEnableOption "Keybase File System"; + package = lib.mkPackageOption pkgs "kbfs" { }; + mountPoint = lib.mkOption { type = lib.types.str; default = "keybase"; @@ -59,7 +61,7 @@ in "KEYBASE_SYSTEMD=1" ]; ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p ${mountPoint}"; - ExecStart = "${pkgs.kbfs}/bin/kbfsfuse ${toString cfg.extraFlags} ${mountPoint}"; + ExecStart = "${lib.getExe' cfg.package "kbfsfuse"} ${toString cfg.extraFlags} ${mountPoint}"; ExecStopPost = "/run/wrappers/bin/fusermount -u ${mountPoint}"; Restart = "on-failure"; }; @@ -67,7 +69,7 @@ in Install.WantedBy = [ "default.target" ]; }; - home.packages = [ pkgs.kbfs ]; + home.packages = [ cfg.package ]; services.keybase.enable = true; }; } diff --git a/modules/services/keybase.nix b/modules/services/keybase.nix index bd5754646..936b6e671 100644 --- a/modules/services/keybase.nix +++ b/modules/services/keybase.nix @@ -10,20 +10,24 @@ let in { - options.services.keybase.enable = lib.mkEnableOption "Keybase"; + options.services.keybase = { + enable = lib.mkEnableOption "Keybase"; + + package = lib.mkPackageOption pkgs "keybase" { }; + }; config = lib.mkIf cfg.enable { assertions = [ (lib.hm.assertions.assertPlatform "services.keybase" pkgs lib.platforms.linux) ]; - home.packages = [ pkgs.keybase ]; + home.packages = [ cfg.package ]; systemd.user.services.keybase = { Unit.Description = "Keybase service"; Service = { - ExecStart = "${pkgs.keybase}/bin/keybase service --auto-forked"; + ExecStart = "${lib.getExe cfg.package} service --auto-forked"; Restart = "on-failure"; PrivateTmp = true; }; diff --git a/modules/services/keynav.nix b/modules/services/keynav.nix index 406bce1e9..1bbfee5c6 100644 --- a/modules/services/keynav.nix +++ b/modules/services/keynav.nix @@ -12,6 +12,8 @@ in { options.services.keynav = { enable = lib.mkEnableOption "keynav"; + + package = lib.mkPackageOption pkgs "keynav" { }; }; config = lib.mkIf cfg.enable { @@ -27,7 +29,7 @@ in }; Service = { - ExecStart = "${pkgs.keynav}/bin/keynav"; + ExecStart = lib.getExe cfg.package; RestartSec = 3; Restart = "always"; }; diff --git a/modules/services/mpris-proxy.nix b/modules/services/mpris-proxy.nix index 7a936d0ef..f188af815 100644 --- a/modules/services/mpris-proxy.nix +++ b/modules/services/mpris-proxy.nix @@ -12,7 +12,11 @@ in { meta.maintainers = [ lib.maintainers.thibautmarty ]; - options.services.mpris-proxy.enable = lib.mkEnableOption "a proxy forwarding Bluetooth MIDI controls via MPRIS2 to control media players"; + options.services.mpris-proxy = { + enable = lib.mkEnableOption "a proxy forwarding Bluetooth MIDI controls via MPRIS2 to control media players"; + + package = lib.mkPackageOption pkgs "bluez" { }; + }; config = lib.mkIf cfg.enable { assertions = [ @@ -30,7 +34,7 @@ in Service = { Type = "simple"; - ExecStart = "${pkgs.bluez}/bin/mpris-proxy"; + ExecStart = lib.getExe' cfg.package "mpris-proxy"; }; }; }; diff --git a/modules/services/muchsync.nix b/modules/services/muchsync.nix index a4f5e81d0..3b002bd23 100644 --- a/modules/services/muchsync.nix +++ b/modules/services/muchsync.nix @@ -139,6 +139,8 @@ in meta.maintainers = with lib.maintainers; [ euxane ]; options.services.muchsync = { + package = lib.mkPackageOption pkgs "muchsync" { }; + remotes = mkOption { type = with types; attrsOf (submodule syncOptions); default = { }; @@ -190,7 +192,7 @@ in ''"NMBGIT=${config.home.sessionVariables.NMBGIT}"'' ]; ExecStart = lib.concatStringsSep " " ( - [ "${pkgs.muchsync}/bin/muchsync" ] + [ (lib.getExe cfg.package) ] ++ [ "-s ${escapeShellArg remoteCfg.sshCommand}" ] ++ optional (!remoteCfg.upload) "--noup" diff --git a/modules/services/network-manager-applet.nix b/modules/services/network-manager-applet.nix index e6c98e4ee..7bced8c46 100644 --- a/modules/services/network-manager-applet.nix +++ b/modules/services/network-manager-applet.nix @@ -18,6 +18,8 @@ in options = { services.network-manager-applet = { enable = lib.mkEnableOption "the Network Manager applet (nm-applet)"; + + package = lib.mkPackageOption pkgs "networkmanagerapplet" { }; }; }; @@ -27,7 +29,7 @@ in ]; # The package provides some icons that are good to have available. - xdg.systemDirs.data = [ "${pkgs.networkmanagerapplet}/share" ]; + xdg.systemDirs.data = [ "${cfg.package}/share" ]; systemd.user.services.network-manager-applet = { Unit = { @@ -46,7 +48,7 @@ in Service = { ExecStart = toString ( - [ "${pkgs.networkmanagerapplet}/bin/nm-applet" ] + [ (lib.getExe' cfg.package "nm-applet") ] ++ lib.optional config.xsession.preferStatusNotifierItems "--indicator" ); }; diff --git a/modules/services/pasystray.nix b/modules/services/pasystray.nix index 5f21aa23e..0dd8c7813 100644 --- a/modules/services/pasystray.nix +++ b/modules/services/pasystray.nix @@ -15,6 +15,8 @@ in services.pasystray = { enable = lib.mkEnableOption "PulseAudio system tray"; + package = lib.mkPackageOption pkgs "pasystray" { }; + extraOptions = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ ]; @@ -54,7 +56,7 @@ in ]; in [ "PATH=${toolPaths}" ]; - ExecStart = lib.escapeShellArgs ([ "${pkgs.pasystray}/bin/pasystray" ] ++ cfg.extraOptions); + ExecStart = lib.escapeShellArgs ([ (lib.getExe cfg.package) ] ++ cfg.extraOptions); }; }; }; diff --git a/modules/services/plan9port.nix b/modules/services/plan9port.nix index 3d4bf17ce..60c27300d 100644 --- a/modules/services/plan9port.nix +++ b/modules/services/plan9port.nix @@ -13,6 +13,8 @@ in meta.maintainers = [ lib.maintainers.ehmry ]; options.services.plan9port = { + package = lib.mkPackageOption pkgs "plan9port" { }; + fontsrv.enable = lib.mkEnableOption "the Plan 9 file system access to host fonts"; plumber.enable = lib.mkEnableOption "the Plan 9 file system for interprocess messaging"; }; @@ -25,13 +27,13 @@ in systemd.user.services.fontsrv = lib.mkIf cfg.fontsrv.enable { Unit.Description = "the Plan 9 file system access to host fonts"; Install.WantedBy = [ "default.target" ]; - Service.ExecStart = "${pkgs.plan9port}/bin/9 fontsrv"; + Service.ExecStart = "${lib.getExe' cfg.package "9"} fontsrv"; }; systemd.user.services.plumber = lib.mkIf cfg.plumber.enable { Unit.Description = "file system for interprocess messaging"; Install.WantedBy = [ "default.target" ]; - Service.ExecStart = "${pkgs.plan9port}/bin/9 plumber -f"; + Service.ExecStart = "${lib.getExe' cfg.package "9"} plumber -f"; }; }; diff --git a/modules/services/poweralertd.nix b/modules/services/poweralertd.nix index 92eac20c1..e4cdafdfe 100644 --- a/modules/services/poweralertd.nix +++ b/modules/services/poweralertd.nix @@ -31,6 +31,8 @@ in options.services.poweralertd = { enable = lib.mkEnableOption "the Upower-powered power alertd"; + package = lib.mkPackageOption pkgs "poweralertd" { }; + extraArgs = lib.mkOption { type = with types; listOf str; default = [ ]; @@ -61,7 +63,7 @@ in Service = { Type = "simple"; - ExecStart = "${pkgs.poweralertd}/bin/poweralertd ${escapeSystemdExecArgs cfg.extraArgs}"; + ExecStart = "${lib.getExe cfg.package} ${escapeSystemdExecArgs cfg.extraArgs}"; Restart = "always"; }; }; diff --git a/modules/services/psd.nix b/modules/services/psd.nix index cd2565945..9b7202468 100644 --- a/modules/services/psd.nix +++ b/modules/services/psd.nix @@ -24,6 +24,8 @@ in options.services.psd = { enable = lib.mkEnableOption "Profile-sync-daemon service"; + package = lib.mkPackageOption pkgs "profile-sync-daemon" { }; + resyncTimer = lib.mkOption { type = lib.types.str; default = "1h"; @@ -75,12 +77,12 @@ in (lib.hm.assertions.assertPlatform "services.psd" pkgs lib.platforms.linux) ]; - home.packages = [ pkgs.profile-sync-daemon ]; + home.packages = [ cfg.package ]; systemd.user = { services = let - exe = "${pkgs.profile-sync-daemon}/bin/profile-sync-daemon"; + exe = lib.getExe' cfg.package "profile-sync-daemon"; envPath = lib.makeBinPath ( with pkgs; [ @@ -93,7 +95,7 @@ in findutils nettools util-linux - profile-sync-daemon + cfg.package ] ); in diff --git a/modules/services/random-background.nix b/modules/services/random-background.nix index d08bf3b0a..41c53a473 100644 --- a/modules/services/random-background.nix +++ b/modules/services/random-background.nix @@ -37,6 +37,8 @@ in ''; }; + package = lib.mkPackageOption pkgs "feh" { }; + imageDirectory = mkOption { type = types.str; example = "%h/backgrounds"; @@ -98,7 +100,7 @@ in Service = { Type = "oneshot"; - ExecStart = "${pkgs.feh}/bin/feh ${flags} ${cfg.imageDirectory}"; + ExecStart = "${lib.getExe cfg.package} ${flags} ${cfg.imageDirectory}"; IOSchedulingClass = "idle"; }; diff --git a/modules/services/rsibreak.nix b/modules/services/rsibreak.nix index d8d3abbb6..c000e2e06 100644 --- a/modules/services/rsibreak.nix +++ b/modules/services/rsibreak.nix @@ -12,9 +12,9 @@ let in { options.services.rsibreak = { - enable = lib.mkEnableOption "rsibreak"; + package = lib.mkPackageOption pkgs "rsibreak" { }; }; config = lib.mkIf cfg.enable { @@ -22,7 +22,7 @@ in (lib.hm.assertions.assertPlatform "services.rsibreak" pkgs lib.platforms.linux) ]; - home.packages = [ pkgs.rsibreak ]; + home.packages = [ cfg.package ]; systemd.user.services.rsibreak = { Unit = { Description = "RSI break timer"; @@ -36,7 +36,7 @@ in Service = { Environment = [ "PATH=${config.home.profileDirectory}/bin" ]; - ExecStart = "${pkgs.rsibreak}/bin/rsibreak"; + ExecStart = lib.getExe cfg.package; }; }; }; diff --git a/modules/services/sctd.nix b/modules/services/sctd.nix index 3b70f339b..a216427c5 100644 --- a/modules/services/sctd.nix +++ b/modules/services/sctd.nix @@ -12,6 +12,8 @@ services.sctd = { enable = lib.mkEnableOption "sctd"; + package = lib.mkPackageOption pkgs "sct" { }; + baseTemperature = lib.mkOption { type = lib.types.ints.between 2500 9000; default = 4500; @@ -38,8 +40,8 @@ Install.WantedBy = [ "graphical-session.target" ]; Service = { - ExecStart = "${pkgs.sct}/bin/sctd ${toString config.services.sctd.baseTemperature}"; - ExecStopPost = "${pkgs.sct}/bin/sct"; + ExecStart = "${config.services.sctd.package}/bin/sctd ${toString config.services.sctd.baseTemperature}"; + ExecStopPost = "${config.services.sctd.package}/bin/sct"; Restart = "on-abnormal"; SuccessExitStatus = 1; @@ -61,7 +63,7 @@ pkgs.coreutils pkgs.gnused pkgs.which - pkgs.sct + config.services.sctd.package logger ] }" diff --git a/modules/services/ssh-agent.nix b/modules/services/ssh-agent.nix index 54a05ba59..7937db1b0 100644 --- a/modules/services/ssh-agent.nix +++ b/modules/services/ssh-agent.nix @@ -16,6 +16,8 @@ in options = { services.ssh-agent = { enable = lib.mkEnableOption "OpenSSH private key agent"; + + package = lib.mkPackageOption pkgs "openssh" { }; }; }; @@ -39,7 +41,7 @@ in }; Service = { - ExecStart = "${pkgs.openssh}/bin/ssh-agent -D -a %t/ssh-agent"; + ExecStart = "${lib.getExe' cfg.package "ssh-agent"} -D -a %t/ssh-agent"; }; }; }; diff --git a/modules/services/systembus-notify.nix b/modules/services/systembus-notify.nix index d73cd7828..99d4a8138 100644 --- a/modules/services/systembus-notify.nix +++ b/modules/services/systembus-notify.nix @@ -4,13 +4,17 @@ pkgs, ... }: - +let + cfg = config.services.systembus-notify; +in { meta.maintainers = [ lib.maintainers.asymmetric ]; options = { services.systembus-notify = { enable = lib.mkEnableOption "systembus-notify - system bus notification daemon"; + + package = lib.mkPackageOption pkgs "systembus-notify" { }; }; }; @@ -22,7 +26,7 @@ systemd.user.services.systembus-notify = { Unit.Description = "systembus-notify daemon"; Install.WantedBy = [ "graphical-session.target" ]; - Service.ExecStart = "${pkgs.systembus-notify}/bin/systembus-notify"; + Service.ExecStart = lib.getExe cfg.package; }; }; } diff --git a/modules/services/tahoe-lafs.nix b/modules/services/tahoe-lafs.nix index 24ade1bf5..e743797de 100644 --- a/modules/services/tahoe-lafs.nix +++ b/modules/services/tahoe-lafs.nix @@ -4,13 +4,17 @@ pkgs, ... }: - +let + cfg = config.services.tahoe-lafs; +in { meta.maintainers = [ lib.maintainers.rycee ]; options = { services.tahoe-lafs = { enable = lib.mkEnableOption "Tahoe-LAFS"; + + package = lib.mkPackageOption pkgs "tahoelafs" { }; }; }; @@ -25,7 +29,7 @@ }; Service = { - ExecStart = "${pkgs.tahoelafs}/bin/tahoe run -C %h/.tahoe"; + ExecStart = "${lib.getExe' cfg.package "tahoe"} run -C %h/.tahoe"; }; }; }; diff --git a/modules/services/udiskie.nix b/modules/services/udiskie.nix index ab775c450..0e8984b2c 100644 --- a/modules/services/udiskie.nix +++ b/modules/services/udiskie.nix @@ -44,6 +44,8 @@ in ''; }; + package = lib.mkPackageOption pkgs "udiskie" { }; + settings = mkOption { type = yaml.type; default = { }; @@ -133,7 +135,7 @@ in }; Service.ExecStart = toString ( - [ "${pkgs.udiskie}/bin/udiskie" ] + [ (lib.getExe cfg.package) ] ++ lib.optional config.xsession.preferStatusNotifierItems "--appindicator" ); diff --git a/modules/services/xcape.nix b/modules/services/xcape.nix index 8d1d20a36..e4cf16a6c 100644 --- a/modules/services/xcape.nix +++ b/modules/services/xcape.nix @@ -20,6 +20,8 @@ in services.xcape = { enable = lib.mkEnableOption "xcape"; + package = lib.mkPackageOption pkgs "xcape" { }; + timeout = lib.mkOption { type = types.nullOr types.int; default = null; @@ -80,7 +82,7 @@ in Service = { Type = "forking"; ExecStart = - "${pkgs.xcape}/bin/xcape" + "${lib.getExe cfg.package}" + lib.optionalString (cfg.timeout != null) " -t ${toString cfg.timeout}" + lib.optionalString (cfg.mapExpression != { }) diff --git a/modules/services/xsuspender.nix b/modules/services/xsuspender.nix index 50ff768b2..5b31a2524 100644 --- a/modules/services/xsuspender.nix +++ b/modules/services/xsuspender.nix @@ -119,6 +119,8 @@ in services.xsuspender = { enable = lib.mkEnableOption "XSuspender"; + package = lib.mkPackageOption pkgs "xsuspender" { }; + defaults = mkOption { description = "XSuspender defaults."; type = xsuspenderOptions; @@ -182,7 +184,7 @@ in // lib.mapAttrs (_: mkSection) cfg.rules; # To make the xsuspender tool available. - home.packages = [ pkgs.xsuspender ]; + home.packages = [ cfg.package ]; xdg.configFile."xsuspender.conf".source = iniFormat.generate "xsuspender.conf" cfg.iniContent; @@ -195,7 +197,7 @@ in }; Service = { - ExecStart = "${pkgs.xsuspender}/bin/xsuspender"; + ExecStart = lib.getExe cfg.package; Environment = lib.mkIf cfg.debug [ "G_MESSAGES_DEBUG=all" ]; };