fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Anthony Rousselawscli: add modulef1b7775d

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