kiro-cli: add module
This commit is contained in:
parent
6cf5b64c12
commit
74887eaee2
5 changed files with 113 additions and 0 deletions
11
modules/misc/news/2026/06/2026-06-09_12-00-00.nix
Normal file
11
modules/misc/news/2026/06/2026-06-09_12-00-00.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
time = "2026-06-09T12:00:00+00:00";
|
||||
condition = config.programs.kiro-cli.enable;
|
||||
message = ''
|
||||
A new module is available: `programs.kiro-cli`.
|
||||
|
||||
It installs the kiro-cli package and provides optional shell
|
||||
integration for Bash and Zsh.
|
||||
'';
|
||||
}
|
||||
50
modules/programs/kiro-cli.nix
Normal file
50
modules/programs/kiro-cli.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.programs.kiro-cli;
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ lib.hm.maintainers.superflash41 ];
|
||||
|
||||
options.programs.kiro-cli = {
|
||||
enable = lib.mkEnableOption "kiro-cli, the command-line interface for Kiro";
|
||||
|
||||
package = lib.mkPackageOption pkgs "kiro-cli" { };
|
||||
|
||||
enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { inherit config; };
|
||||
|
||||
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
programs = {
|
||||
bash.initExtra = lib.mkIf cfg.enableBashIntegration (
|
||||
lib.mkMerge [
|
||||
(lib.mkBefore ''
|
||||
eval "$(${lib.getExe cfg.package} init bash pre)"
|
||||
'')
|
||||
(lib.mkAfter ''
|
||||
eval "$(${lib.getExe cfg.package} init bash post)"
|
||||
'')
|
||||
]
|
||||
);
|
||||
|
||||
zsh.initContent = lib.mkIf cfg.enableZshIntegration (
|
||||
lib.mkMerge [
|
||||
(lib.mkBefore ''
|
||||
eval "$(${lib.getExe cfg.package} init zsh pre)"
|
||||
'')
|
||||
(lib.mkAfter ''
|
||||
eval "$(${lib.getExe cfg.package} init zsh post)"
|
||||
'')
|
||||
]
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
24
tests/modules/programs/kiro-cli/bash.nix
Normal file
24
tests/modules/programs/kiro-cli/bash.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
programs = {
|
||||
kiro-cli.enable = true;
|
||||
bash.enable = true;
|
||||
};
|
||||
|
||||
test.stubs.kiro-cli = {
|
||||
name = "kiro-cli";
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.bashrc
|
||||
assertFileContains home-files/.bashrc \
|
||||
'eval "$(@kiro-cli@/bin/kiro-cli init bash pre)"'
|
||||
assertFileContains home-files/.bashrc \
|
||||
'eval "$(@kiro-cli@/bin/kiro-cli init bash post)"'
|
||||
|
||||
preLine=$(grep -n 'init bash pre' $TESTED/home-files/.bashrc | head -n1 | cut -d: -f1)
|
||||
postLine=$(grep -n 'init bash post' $TESTED/home-files/.bashrc | head -n1 | cut -d: -f1)
|
||||
if [[ "$preLine" -ge "$postLine" ]]; then
|
||||
fail "kiro-cli 'pre' snippet (line $preLine) must appear before 'post' snippet (line $postLine) in .bashrc"
|
||||
fi
|
||||
'';
|
||||
}
|
||||
4
tests/modules/programs/kiro-cli/default.nix
Normal file
4
tests/modules/programs/kiro-cli/default.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
kiro-cli-bash = ./bash.nix;
|
||||
kiro-cli-zsh = ./zsh.nix;
|
||||
}
|
||||
24
tests/modules/programs/kiro-cli/zsh.nix
Normal file
24
tests/modules/programs/kiro-cli/zsh.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
programs = {
|
||||
kiro-cli.enable = true;
|
||||
zsh.enable = true;
|
||||
};
|
||||
|
||||
test.stubs.kiro-cli = {
|
||||
name = "kiro-cli";
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.zshrc
|
||||
assertFileContains home-files/.zshrc \
|
||||
'eval "$(@kiro-cli@/bin/kiro-cli init zsh pre)"'
|
||||
assertFileContains home-files/.zshrc \
|
||||
'eval "$(@kiro-cli@/bin/kiro-cli init zsh post)"'
|
||||
|
||||
preLine=$(grep -n 'init zsh pre' $TESTED/home-files/.zshrc | head -n1 | cut -d: -f1)
|
||||
postLine=$(grep -n 'init zsh post' $TESTED/home-files/.zshrc | head -n1 | cut -d: -f1)
|
||||
if [[ "$preLine" -ge "$postLine" ]]; then
|
||||
fail "kiro-cli 'pre' snippet (line $preLine) must appear before 'post' snippet (line $postLine) in .zshrc"
|
||||
fi
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue