mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-26 01:51:37 +00:00
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.
40 lines
934 B
Nix
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
|
|
'';
|
|
};
|
|
}
|