1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00
home-manager/modules/programs/granted.nix
Austin Horstman 0b491b460f
treewide: remove with lib (#6735)
Continuation of `with lib;` cleanup.
2025-03-31 22:32:16 -05:00

35 lines
981 B
Nix

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