1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-26 01:51:37 +00:00
home-manager/modules/programs/granted.nix
Raine Godmaire 7fd6dc2b94
granted: fix fish shell integration (#6602)
Without `$argv` the function will not pass any flags or arguments to the
`assume.fish` script.  These are necessary to use assume to access the
AWS console or use IAM role chaining.
2025-03-11 08:28:43 -05:00

40 lines
934 B
Nix

{ 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 =
lib.hm.shell.mkZshIntegrationOption { inherit config; };
enableFishIntegration =
lib.hm.shell.mkFishIntegrationOption { inherit config; };
};
config = mkIf cfg.enable {
home.packages = [ package ];
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
function assume() {
export GRANTED_ALIAS_CONFIGURED="true"
source ${package}/bin/assume "$@"
unset GRANTED_ALIAS_CONFIGURED
}
'';
programs.fish.functions.assume = mkIf cfg.enableFishIntegration ''
set -x GRANTED_ALIAS_CONFIGURED "true"
source ${package}/share/assume.fish $argv
set -e GRANTED_ALIAS_CONFIGURED
'';
};
}