1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

granted: add module

Signed-off-by: Willi Carlsen <carlsenwilli@gmail.com>
This commit is contained in:
Willi Carlsen 2023-10-24 15:49:09 +02:00 committed by Robert Helgesson
parent a421804890
commit 48b0a30202
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
8 changed files with 108 additions and 0 deletions

View file

@ -448,4 +448,10 @@
github = "liyangau";
githubId = 71299093;
};
wcarlsen = {
name = "Willi Carlsen";
email = "carlsenwilli+nix@gmail.com";
github = "wcarlsen";
githubId = 17003032;
};
}

View file

@ -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'.
'';
}
];
};
}

View file

@ -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

View 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
}
'';
};
}

View file

@ -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

View file

@ -0,0 +1,4 @@
{
granted-integration-enabled = ./integration-enabled.nix;
granted-integration-disabled = ./integration-disabled.nix;
}

View 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'
'';
}

View 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'
'';
}