treewide: implement auto importing for modules
Reduce maintenance burden and increase efficiency by automatically importing modules following a specific convention. Co-authored-by: awwpotato <awwpotato@voidq.com> Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
fefeb0e928
commit
4fca600cb1
461 changed files with 72 additions and 474 deletions
72
modules/programs/awscli/default.nix
Normal file
72
modules/programs/awscli/default.nix
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.programs.awscli;
|
||||
iniFormat = pkgs.formats.ini { };
|
||||
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ lib.maintainers.anthonyroussel ];
|
||||
|
||||
options.programs.awscli = {
|
||||
enable = lib.mkEnableOption "AWS CLI tool";
|
||||
|
||||
package = lib.mkPackageOption pkgs "aws" {
|
||||
default = "awscli2";
|
||||
nullable = true;
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.submodule { freeformType = iniFormat.type; };
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
"default" = {
|
||||
region = "eu-west-3";
|
||||
output = "json";
|
||||
};
|
||||
};
|
||||
'';
|
||||
description = "Configuration written to {file}`$HOME/.aws/config`.";
|
||||
};
|
||||
|
||||
credentials = lib.mkOption {
|
||||
type = lib.types.submodule { freeformType = iniFormat.type; };
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
"default" = {
|
||||
"credential_process" = "${pkgs.pass}/bin/pass show aws";
|
||||
};
|
||||
};
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to {file}`$HOME/.aws/credentials`.
|
||||
|
||||
For security reasons, never store cleartext passwords here.
|
||||
We recommend that you use `credential_process` option to retrieve
|
||||
the IAM credentials from your favorite password manager during runtime,
|
||||
or use AWS IAM Identity Center to get short-term credentials.
|
||||
|
||||
See <https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-authentication.html>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
home.file."${config.home.homeDirectory}/.aws/config" = lib.mkIf (cfg.settings != { }) {
|
||||
source = iniFormat.generate "aws-config-${config.home.username}" cfg.settings;
|
||||
};
|
||||
|
||||
home.file."${config.home.homeDirectory}/.aws/credentials" = lib.mkIf (cfg.credentials != { }) {
|
||||
source = iniFormat.generate "aws-credentials-${config.home.username}" cfg.credentials;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue