treewide: add missing package option

Provide more customization to the binary to be installed.
This commit is contained in:
Austin Horstman
2025-03-30 11:43:00 -05:00
parent fcdd04e0f9
commit 107352dde4
27 changed files with 111 additions and 48 deletions

View File

@@ -4,6 +4,8 @@ in {
options.programs.abook = {
enable = lib.mkEnableOption "Abook";
package = lib.mkPackageOption pkgs "abook" { nullable = true; };
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
@@ -21,7 +23,7 @@ in {
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.abook ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."abook/abookrc" = lib.mkIf (cfg.extraConfig != "") {
text = ''

View File

@@ -4,6 +4,8 @@ in {
options.programs.afew = {
enable = lib.mkEnableOption "the afew initial tagging script for Notmuch";
package = lib.mkPackageOption pkgs "afew" { nullable = true; };
extraConfig = lib.mkOption {
type = lib.types.lines;
default = ''
@@ -32,7 +34,7 @@ in {
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.afew ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."afew/config".text = ''
# Generated by Home Manager.

View File

@@ -16,6 +16,8 @@ in {
options.programs.aria2 = {
enable = lib.mkEnableOption "aria2";
package = lib.mkPackageOption pkgs "aria2" { nullable = true; };
settings = lib.mkOption {
type = with lib.types; attrsOf (oneOf [ bool float int str ]);
default = { };
@@ -46,7 +48,7 @@ in {
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.aria2 ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."aria2/aria2.conf".text = lib.concatStringsSep "\n" ([ ]
++ lib.mapAttrsToList formatLine cfg.settings

View File

@@ -54,6 +54,8 @@ in {
programs.astroid = {
enable = lib.mkEnableOption "Astroid";
package = lib.mkPackageOption pkgs "astroid" { nullable = true; };
pollScript = mkOption {
type = types.str;
default = "";
@@ -113,7 +115,7 @@ in {
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.astroid ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."astroid/config".source =
jsonFormat.generate "astroid-config" finalConfig;

View File

@@ -1,7 +1,6 @@
{ config, lib, pkgs, ... }:
let
cfg = config.programs.autojump;
package = pkgs.autojump;
inherit (lib) mkIf;
in {
@@ -10,6 +9,8 @@ in {
options.programs.autojump = {
enable = lib.mkEnableOption "autojump";
package = lib.mkPackageOption pkgs "autojump" { };
enableBashIntegration =
lib.hm.shell.mkBashIntegrationOption { inherit config; };
@@ -21,18 +22,18 @@ in {
};
config = mkIf cfg.enable {
home.packages = [ package ];
home.packages = [ cfg.package ];
programs.bash.initExtra = mkIf cfg.enableBashIntegration (lib.mkBefore ''
. ${package}/share/autojump/autojump.bash
. ${cfg.package}/share/autojump/autojump.bash
'');
programs.zsh.initContent = mkIf cfg.enableZshIntegration ''
. ${package}/share/autojump/autojump.zsh
. ${cfg.package}/share/autojump/autojump.zsh
'';
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
. ${package}/share/autojump/autojump.fish
. ${cfg.package}/share/autojump/autojump.fish
'';
};
}

View File

@@ -291,6 +291,8 @@ in {
programs.autorandr = {
enable = lib.mkEnableOption "Autorandr";
package = lib.mkPackageOption pkgs "autorandr" { nullable = true; };
hooks = mkOption {
type = globalHooksModule;
description = "Global hook scripts";
@@ -366,7 +368,8 @@ in {
'';
}) config) cfg.profiles);
home.packages = [ pkgs.autorandr ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile = lib.mkMerge [
(mapAttrs' (hookToFile "postswitch.d") cfg.hooks.postswitch)
(mapAttrs' (hookToFile "preswitch.d") cfg.hooks.preswitch)

View File

@@ -6,6 +6,8 @@ in {
options.programs.bashmount = {
enable = lib.mkEnableOption "bashmount";
package = lib.mkPackageOption pkgs "bashmount" { nullable = true; };
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
@@ -20,7 +22,7 @@ in {
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.bashmount ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."bashmount/config" =
lib.mkIf (cfg.extraConfig != "") { text = cfg.extraConfig; };

View File

@@ -6,6 +6,8 @@ in {
options.programs.cmus = {
enable = lib.mkEnableOption "Enable cmus, the music player.";
package = lib.mkPackageOption pkgs "cmus" { nullable = true; };
theme = lib.mkOption {
type = lib.types.lines;
default = "";
@@ -28,7 +30,7 @@ in {
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.cmus ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
home.file.".config/cmus/rc".text = ''
${lib.optionalString (cfg.theme != "") "colorscheme ${cfg.theme}"}

View File

@@ -17,6 +17,8 @@ in {
'';
};
package = lib.mkPackageOption pkgs "dircolors" { default = "coreutils"; };
enableBashIntegration =
lib.hm.shell.mkBashIntegrationOption { inherit config; };
@@ -197,17 +199,17 @@ in {
};
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
eval $(${pkgs.coreutils}/bin/dircolors -b ${dircolorsPath})
eval $(${lib.getExe' cfg.package "dircolors"} -b ${dircolorsPath})
'';
programs.fish.shellInit = mkIf cfg.enableFishIntegration ''
eval (${pkgs.coreutils}/bin/dircolors -c ${dircolorsPath})
eval (${lib.getExe' cfg.package "dircolors"} -c ${dircolorsPath})
'';
# Set `LS_COLORS` before Oh My Zsh and `initExtra`.
programs.zsh.initContent = mkIf cfg.enableZshIntegration
(lib.mkOrder 550 ''
eval $(${pkgs.coreutils}/bin/dircolors -b ${dircolorsPath})
eval $(${lib.getExe' cfg.package "dircolors"} -b ${dircolorsPath})
'');
}
(mkIf (!config.home.preferXdgDirectories) {

View File

@@ -222,6 +222,8 @@ in {
options.programs.hexchat = {
enable = lib.mkEnableOption "HexChat, a graphical IRC client";
package = lib.mkPackageOption pkgs "hexchat" { nullable = true; };
channels = mkOption {
type = types.attrsOf modChannelOption;
default = { };
@@ -322,7 +324,7 @@ in {
lib.platforms.linux)
];
home.packages = [ pkgs.hexchat ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."hexchat" = mkIf (cfg.theme != null) {
source = cfg.theme;

View File

@@ -25,6 +25,8 @@ in {
programs.khard = {
enable = lib.mkEnableOption "Khard: an address book for the Unix console";
package = lib.mkPackageOption pkgs "khard" { };
settings = lib.mkOption {
type = with lib.types;
submodule {
@@ -78,7 +80,7 @@ in {
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.khard ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."khard/khard.conf".text = let
makePath = anAccount:

View File

@@ -7,6 +7,8 @@ in {
programs.less = {
enable = lib.mkEnableOption "less, opposite of more";
package = lib.mkPackageOption pkgs "less" { nullable = true; };
keys = lib.mkOption {
type = lib.types.lines;
default = "";
@@ -23,7 +25,8 @@ in {
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.less ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."lesskey".text = cfg.keys;
};
}

View File

@@ -12,24 +12,24 @@ let
# and https://github.com/bnprks/mcfly-fzf/issues/10
bashIntegration = ''
eval "$(${getExe pkgs.mcfly} init bash)"
eval "$(${getExe cfg.package} init bash)"
'' + optionalString cfg.fzf.enable ''
if [[ $- =~ i ]]; then
eval "$(${getExe pkgs.mcfly-fzf} init bash)"
eval "$(${getExe cfg.mcflyFzfPackage} init bash)"
fi
'';
fishIntegration = ''
${getExe pkgs.mcfly} init fish | source
${getExe cfg.package} init fish | source
'' + optionalString cfg.fzf.enable ''
eval "$(${getExe pkgs.mcfly-fzf} init fish)"
eval "$(${getExe cfg.mcflyFzfPackage} init fish)"
'';
zshIntegration = ''
eval "$(${getExe pkgs.mcfly} init zsh)"
eval "$(${getExe cfg.package} init zsh)"
'' + optionalString cfg.fzf.enable ''
if [[ -o interactive ]]; then
${getExe pkgs.mcfly-fzf} init zsh | source
${getExe cfg.mcflyFzfPackage} init zsh | source
fi
'';
@@ -50,6 +50,10 @@ in {
options.programs.mcfly = {
enable = lib.mkEnableOption "mcfly";
package = lib.mkPackageOption pkgs "mcfly" { };
mcflyFzfPackage = lib.mkPackageOption pkgs "mcfly-fzf" { };
settings = mkOption {
type = tomlFormat.type;
default = { };
@@ -129,8 +133,8 @@ in {
config = mkIf cfg.enable (lib.mkMerge [
{
home.packages = [ pkgs.mcfly ]
++ lib.optional cfg.fzf.enable pkgs.mcfly-fzf;
home.packages = [ cfg.package ]
++ lib.optional cfg.fzf.enable cfg.package;
# Oddly enough, McFly expects this in the data path, not in config.
xdg.dataFile."mcfly/config.toml" = mkIf (cfg.settings != { }) {

View File

@@ -22,6 +22,8 @@ in {
options.programs.ne = {
enable = lib.mkEnableOption "ne";
package = lib.mkPackageOption pkgs "ne" { nullable = true; };
keybindings = mkOption {
type = types.lines;
default = "";
@@ -81,7 +83,7 @@ in {
};
config = mkIf cfg.enable {
home.packages = [ pkgs.ne ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
home.file = {
".ne/.keys" = mkIf (cfg.keybindings != "") { text = cfg.keybindings; };

View File

@@ -6,6 +6,8 @@ in {
options.programs.noti = {
enable = lib.mkEnableOption "Noti";
package = lib.mkPackageOption pkgs "noti" { nullable = true; };
settings = lib.mkOption {
type = with lib.types; attrsOf (attrsOf str);
default = { };
@@ -32,7 +34,7 @@ in {
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.noti ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."noti/noti.yaml" = lib.mkIf (cfg.settings != { }) {
text = lib.generators.toYAML { } cfg.settings;

View File

@@ -10,6 +10,8 @@ in {
options.programs.pazi = {
enable = lib.mkEnableOption "pazi";
package = lib.mkPackageOption pkgs "pazi" { };
enableBashIntegration =
lib.hm.shell.mkBashIntegrationOption { inherit config; };
@@ -21,18 +23,18 @@ in {
};
config = mkIf cfg.enable {
home.packages = [ pkgs.pazi ];
home.packages = [ cfg.package ];
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
eval "$(${pkgs.pazi}/bin/pazi init bash)"
eval "$(${lib.getExe cfg.package} init bash)"
'';
programs.zsh.initContent = mkIf cfg.enableZshIntegration ''
eval "$(${pkgs.pazi}/bin/pazi init zsh)"
eval "$(${lib.getExe cfg.package} init zsh)"
'';
programs.fish.shellInit = mkIf cfg.enableFishIntegration ''
${pkgs.pazi}/bin/pazi init fish | source
${lib.getExe cfg.package} init fish | source
'';
};
}

View File

@@ -50,6 +50,8 @@ in {
options.programs.pet = {
enable = lib.mkEnableOption "pet";
package = lib.mkPackageOption pkgs "pet" { nullable = true; };
settings = mkOption {
type = format.type;
default = { };
@@ -60,6 +62,7 @@ in {
};
selectcmdPackage = lib.mkPackageOption pkgs "fzf" {
nullable = true;
extraDescription =
"The package needed for the {var}`settings.selectcmd`.";
};
@@ -84,7 +87,8 @@ in {
} else
defaultGeneral;
home.packages = [ pkgs.pet cfg.selectcmdPackage ];
home.packages = lib.optional (cfg.package != null) cfg.package
++ lib.optional (cfg.selectcmdPackage != null) cfg.selectcmdPackage;
xdg.configFile = {
"pet/config.toml".source = format.generate "config.toml"

View File

@@ -39,6 +39,8 @@ in {
options.programs.pistol = {
enable = lib.mkEnableOption "file previewer for terminal file managers";
package = lib.mkPackageOption pkgs "pistol" { nullable = true; };
associations = mkOption {
type = types.listOf association;
default = [ ];
@@ -69,7 +71,7 @@ in {
'';
}];
home.packages = [ pkgs.pistol ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
}
(mkIf (cfg.associations != [ ] && pkgs.stdenv.hostPlatform.isDarwin) {

View File

@@ -1,11 +1,17 @@
{ config, lib, pkgs, ... }:
let cfg = config.programs.pywal;
in {
options = { programs.pywal = { enable = lib.mkEnableOption "pywal"; }; };
options = {
programs.pywal = {
enable = lib.mkEnableOption "pywal";
package = lib.mkPackageOption pkgs "pywal" { };
};
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.pywal ];
home.packages = [ cfg.package ];
programs.zsh.initContent = ''
# Import colorscheme from 'wal' asynchronously

View File

@@ -31,6 +31,8 @@ in {
programs.qcal = {
enable = lib.mkEnableOption "qcal, a CLI calendar application";
package = lib.mkPackageOption pkgs "qcal" { nullable = true; };
timezone = lib.mkOption {
type = lib.types.singleLineStr;
default = "Local";
@@ -53,7 +55,7 @@ in {
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.qcal ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."qcal/config.json".source =
let jsonFormat = pkgs.formats.json { };

View File

@@ -12,6 +12,8 @@ in {
options.programs.rtorrent = {
enable = lib.mkEnableOption "rTorrent";
package = lib.mkPackageOption pkgs "rtorrent" { nullable = true; };
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
@@ -26,7 +28,7 @@ in {
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.rtorrent ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."rtorrent/rtorrent.rc" =
lib.mkIf (cfg.extraConfig != "") { text = cfg.extraConfig; };

View File

@@ -9,6 +9,8 @@ in {
options.programs.sqls = {
enable = lib.mkEnableOption "sqls, a SQL language server written in Go";
package = lib.mkPackageOption pkgs "sqls" { nullable = true; };
settings = lib.mkOption {
type = yamlFormat.type;
default = { };
@@ -33,7 +35,7 @@ in {
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.sqls ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."sqls/config.yml" = lib.mkIf (cfg.settings != { }) {
source = yamlFormat.generate "sqls-config" cfg.settings;

View File

@@ -59,6 +59,8 @@ in {
options.programs.tealdeer = {
enable = lib.mkEnableOption "Tealdeer";
package = lib.mkPackageOption pkgs "tealdeer" { };
settings = mkOption {
type = types.nullOr settingsFormat;
default = null;
@@ -88,7 +90,7 @@ in {
};
config = mkIf cfg.enable {
home.packages = [ pkgs.tealdeer ];
home.packages = [ cfg.package ];
home.file."${configDir}/tealdeer/config.toml" =
mkIf (cfg.settings != null && cfg.settings != { }) {
@@ -97,7 +99,7 @@ in {
services.tldr-update = mkIf cfg.enableAutoUpdates {
enable = true;
package = pkgs.tealdeer;
package = cfg.package;
};
};
}

View File

@@ -9,6 +9,8 @@ in {
programs.termite = {
enable = lib.mkEnableOption "Termite VTE-based terminal";
package = lib.mkPackageOption pkgs "termite" { nullable = true; };
allowBold = mkOption {
default = null;
type = types.nullOr types.bool;
@@ -322,7 +324,7 @@ in {
optionalString = name: val:
lib.optionalString (val != null) "${name} = ${val}";
in lib.mkIf cfg.enable {
home.packages = [ pkgs.termite ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."termite/config".text = ''
[options]
${optionalBoolean "allow_bold" cfg.allowBold}

View File

@@ -7,6 +7,8 @@ in {
options.programs.todoman = {
enable = lib.mkEnableOption "todoman";
package = lib.mkPackageOption pkgs "todoman" { nullable = true; };
glob = lib.mkOption {
type = lib.types.str;
default = "*";
@@ -44,7 +46,7 @@ in {
'';
}];
home.packages = [ pkgs.todoman ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."todoman/config.py".text = lib.concatLines [
''path = "${config.accounts.calendar.basePath}/${cfg.glob}"''

View File

@@ -23,6 +23,8 @@ in {
options.programs.translate-shell = {
enable = lib.mkEnableOption "translate-shell";
package = lib.mkPackageOption pkgs "translate-shell" { nullable = true; };
settings = lib.mkOption {
type = with lib.types; attrsOf (oneOf [ bool str (listOf str) ]);
default = { };
@@ -40,7 +42,7 @@ in {
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.translate-shell ];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."translate-shell/init.trans" =
lib.mkIf (cfg.settings != { }) { text = "{${toKeyValue cfg.settings}}"; };

View File

@@ -18,6 +18,8 @@ in {
options.programs.z-lua = {
enable = lib.mkEnableOption "z.lua";
package = lib.mkPackageOption pkgs "z-lua" { };
options = lib.mkOption {
type = types.listOf types.str;
default = [ ];
@@ -46,16 +48,16 @@ in {
};
config = mkIf cfg.enable {
home.packages = [ pkgs.z-lua ];
home.packages = [ cfg.package ];
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
eval "$(${pkgs.z-lua}/bin/z --init bash ${
eval "$(${cfg.package}/bin/z --init bash ${
lib.concatStringsSep " " cfg.options
})"
'';
programs.zsh.initContent = mkIf cfg.enableZshIntegration ''
eval "$(${pkgs.z-lua}/bin/z --init zsh ${
eval "$(${cfg.package}/bin/z --init zsh ${
lib.concatStringsSep " " cfg.options
})"
'';
@@ -67,7 +69,7 @@ in {
programs.fish = lib.mkMerge [
{
shellInit = mkIf cfg.enableFishIntegration ''
source (${pkgs.z-lua}/bin/z --init fish ${
source (${cfg.package}/bin/z --init fish ${
lib.concatStringsSep " " cfg.options
} | psub)
'';