treewide: implement auto importing for modules
Reduce maintenance burden and increase efficiency by automatically importing modules following a specific convention. Co-authored-by: awwpotato <awwpotato@voidq.com> Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
fefeb0e928
commit
4fca600cb1
461 changed files with 72 additions and 474 deletions
40
modules/programs/granted/default.nix
Normal file
40
modules/programs/granted/default.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.programs.granted;
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ lib.hm.maintainers.wcarlsen ];
|
||||
|
||||
options.programs.granted = {
|
||||
enable = lib.mkEnableOption "granted";
|
||||
|
||||
package = lib.mkPackageOption pkgs "granted" { };
|
||||
|
||||
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
||||
|
||||
enableFishIntegration = lib.hm.shell.mkFishIntegrationOption { inherit config; };
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
programs.zsh.initContent = lib.mkIf cfg.enableZshIntegration ''
|
||||
function assume() {
|
||||
export GRANTED_ALIAS_CONFIGURED="true"
|
||||
source ${cfg.package}/bin/assume "$@"
|
||||
unset GRANTED_ALIAS_CONFIGURED
|
||||
}
|
||||
'';
|
||||
|
||||
programs.fish.functions.assume = lib.mkIf cfg.enableFishIntegration ''
|
||||
set -x GRANTED_ALIAS_CONFIGURED "true"
|
||||
source ${cfg.package}/share/assume.fish $argv
|
||||
set -e GRANTED_ALIAS_CONFIGURED
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue