mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
granted: add module
Signed-off-by: Willi Carlsen <carlsenwilli@gmail.com>
This commit is contained in:
parent
a421804890
commit
48b0a30202
8 changed files with 108 additions and 0 deletions
|
@ -448,4 +448,10 @@
|
|||
github = "liyangau";
|
||||
githubId = 71299093;
|
||||
};
|
||||
wcarlsen = {
|
||||
name = "Willi Carlsen";
|
||||
email = "carlsenwilli+nix@gmail.com";
|
||||
github = "wcarlsen";
|
||||
githubId = 17003032;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1288,6 +1288,13 @@ in
|
|||
A new module is available: 'programs.cava'.
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2023-11-01T21:18:20+00:00";
|
||||
message = ''
|
||||
A new module is available: 'programs.granted'.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ let
|
|||
./programs/gnome-terminal.nix
|
||||
./programs/go.nix
|
||||
./programs/gpg.nix
|
||||
./programs/granted.nix
|
||||
./programs/havoc.nix
|
||||
./programs/helix.nix
|
||||
./programs/hexchat.nix
|
||||
|
|
36
modules/programs/granted.nix
Normal file
36
modules/programs/granted.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.granted;
|
||||
package = pkgs.granted;
|
||||
|
||||
in {
|
||||
meta.maintainers = [ hm.maintainers.wcarlsen ];
|
||||
|
||||
options.programs.granted = {
|
||||
enable = mkEnableOption "granted";
|
||||
|
||||
enableZshIntegration = mkOption {
|
||||
default = true;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Whether to enable Zsh integration.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ package ];
|
||||
|
||||
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
||||
function assume() {
|
||||
export GRANTED_ALIAS_CONFIGURED="true"
|
||||
source ${package}/bin/.assume-wrapped "$@"
|
||||
unset GRANTED_ALIAS_CONFIGURED
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -84,6 +84,7 @@ import nmt {
|
|||
./modules/programs/git
|
||||
./modules/programs/git-cliff
|
||||
./modules/programs/gpg
|
||||
./modules/programs/granted
|
||||
./modules/programs/helix
|
||||
./modules/programs/himalaya
|
||||
./modules/programs/htop
|
||||
|
|
4
tests/modules/programs/granted/default.nix
Normal file
4
tests/modules/programs/granted/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
granted-integration-enabled = ./integration-enabled.nix;
|
||||
granted-integration-disabled = ./integration-disabled.nix;
|
||||
}
|
27
tests/modules/programs/granted/integration-disabled.nix
Normal file
27
tests/modules/programs/granted/integration-disabled.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs = {
|
||||
granted.enable = true;
|
||||
granted.enableZshIntegration = false;
|
||||
zsh.enable = true;
|
||||
};
|
||||
|
||||
test.stubs.granted = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.zshrc
|
||||
assertFileNotRegex \
|
||||
home-files/.zshrc \
|
||||
'function assume()'
|
||||
assertFileNotRegex \
|
||||
home-files/.zshrc \
|
||||
'export GRANTED_ALIAS_CONFIGURED="true"'
|
||||
assertFileNotRegex \
|
||||
home-files/.zshrc \
|
||||
'source @granted@/bin/.assume-wrapped "$@"'
|
||||
assertFileNotRegex \
|
||||
home-files/.zshrc \
|
||||
'unset GRANTED_ALIAS_CONFIGURED'
|
||||
'';
|
||||
}
|
26
tests/modules/programs/granted/integration-enabled.nix
Normal file
26
tests/modules/programs/granted/integration-enabled.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs = {
|
||||
granted.enable = true;
|
||||
zsh.enable = true;
|
||||
};
|
||||
|
||||
test.stubs.granted = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.zshrc
|
||||
assertFileContains \
|
||||
home-files/.zshrc \
|
||||
'function assume()'
|
||||
assertFileContains \
|
||||
home-files/.zshrc \
|
||||
'export GRANTED_ALIAS_CONFIGURED="true"'
|
||||
assertFileContains \
|
||||
home-files/.zshrc \
|
||||
'source @granted@/bin/.assume-wrapped "$@"'
|
||||
assertFileContains \
|
||||
home-files/.zshrc \
|
||||
'unset GRANTED_ALIAS_CONFIGURED'
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue