aboutsummaryrefslogtreecommitdiffstats
path: root/modules/scripts/lib.nix
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar+git@gmail.com>2026-08-21 04:06:34 +0530
committerArpit Chakladar <arpitchakladar+git@gmail.com>2026-08-29 03:50:28 +0530
commit58cd82c184b5f321930eed614462f69b0a0d9fa3 (patch)
tree8cebcc1ec3ebedab3be16873aa694c3006c3f4c8 /modules/scripts/lib.nix
parent9096fc6607a196f48df1da1dbe9b3f2b0908d76d (diff)
downloadhome-manager-config-58cd82c184b5f321930eed614462f69b0a0d9fa3.tar.gz
home-manager-config-58cd82c184b5f321930eed614462f69b0a0d9fa3.zip
scripts: added completions for nix-update script, updated completions
- added zsh completions for nix-update - updated completions options to allow multiple shells
Diffstat (limited to 'modules/scripts/lib.nix')
-rw-r--r--modules/scripts/lib.nix26
1 files changed, 18 insertions, 8 deletions
diff --git a/modules/scripts/lib.nix b/modules/scripts/lib.nix
index 76e453e..31d7e5b 100644
--- a/modules/scripts/lib.nix
+++ b/modules/scripts/lib.nix
@@ -1,5 +1,10 @@
{ lib, pkgs }:
let
+ shellArgs = {
+ zsh = name: file: "--zsh --name _${name} ${file}";
+ bash = name: file: "--bash --name ${name}.bash ${file}";
+ };
+
mkScript =
name: path: description: env: deps: completion:
let
@@ -22,11 +27,16 @@ let
{
nativeBuildInputs = [ pkgs.installShellFiles ];
}
- ''
- installShellCompletion --zsh --name _${name} ${pkgs.writeText "_${name}" completion}
- '';
+ (
+ "mkdir -p $out\n"
+ + lib.concatStringsSep "\n" (
+ lib.mapAttrsToList (shell: content: ''
+ installShellCompletion ${shellArgs.${shell} name (pkgs.writeText "_${name}.${shell}" content)}
+ '') completion
+ )
+ );
in
- if completion == null then
+ if completion == { } then
base
else
pkgs.symlinkJoin {
@@ -47,7 +57,7 @@ let
extraLinks ? [ ],
config,
description ? "",
- completion ? null,
+ completion ? { },
}:
let
scriptDrv = mkScript name path description env deps completion;
@@ -67,8 +77,8 @@ let
completion = {
enable = lib.mkOption {
type = lib.types.bool;
- default = completion != null;
- description = "Whether to install a zsh completion for the ${name} script.";
+ default = completion != { };
+ description = "Whether to install completions for the ${name} script.";
};
};
desktop = {
@@ -115,7 +125,7 @@ let
message = "scripts.${name}.desktop.enable requires terminal.kitty.enable because desktop entries launch scripts in kitty.";
}
{
- assertion = !config.scripts.${name}.completion.enable || completion != null;
+ assertion = !config.scripts.${name}.completion.enable || completion != { };
message = "scripts.${name}.completion.enable is true but no completion text was provided to mkScriptModule.";
}
];