fork/home-manager
git clone https://git.julia.blue/fork/home-manager
f1b7775d
master
1{ config , lib , pkgs , ...} : 2 3let 4cfg = config . programs . awscli ; 5iniFormat = pkgs . formats . ini { }; 6 7in { 8meta . maintainers = [ lib . maintainers . anthonyroussel ]; 9 10options . programs . awscli = { 11enable = lib . mkEnableOption "AWS CLI tool" ; 12 13package = lib . mkOption { 14type = lib . types . package ; 15default = pkgs . awscli2 ; 16defaultText = lib . literalExpression "pkgs.awscli2" ; 17description = "Package providing {command}`aws`." ; 18}; 19 20settings = lib . mkOption { 21type = lib . types . submodule { freeformType = iniFormat . type ; }; 22default = { }; 23example = lib . literalExpression '' 24{ 25"default" = { 26region = "eu-west-3"; 27output = "json"; 28}; 29}; 30'' ; 31description = "Configuration written to {file}`$HOME/.aws/config`." ; 32}; 33 34credentials = lib . mkOption { 35type = lib . types . submodule { freeformType = iniFormat . type ; }; 36default = { }; 37example = lib . literalExpression '' 38{ 39"default" = { 40"credential_process" = " ${ pkgs . pass } /bin/pass show aws"; 41}; 42}; 43'' ; 44description = '' 45Configuration written to {file}`$HOME/.aws/credentials`. 46 47For security reasons, never store cleartext passwords here. 48We recommend that you use `credential_process` option to retrieve 49the IAM credentials from your favorite password manager during runtime, 50or use AWS IAM Identity Center to get short-term credentials. 51 52See <https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-authentication.html>. 53'' ; 54}; 55}; 56 57config = lib . mkIf cfg . enable { 58home . packages = [ cfg . package ]; 59 60home . file . " ${ config . home . homeDirectory } /.aws/config" . source = 61iniFormat . generate "aws-config- ${ config . home . username } " cfg . settings ; 62 63home . file . " ${ config . home . homeDirectory } /.aws/credentials" . source = 64iniFormat . generate "aws-credentials- ${ config . home . username } " 65cfg . credentials ; 66}; 67}