1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-31 04:04:32 +00:00
This commit is contained in:
Luís Guimarães 2025-03-20 09:10:55 +00:00 committed by GitHub
commit dcdfd61b20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,8 +2,17 @@
let
cfg = config.programs.awscli;
iniFormat = pkgs.formats.ini { };
settingsPath =
if cfg.settingsPath != ""
then cfg.settingsPath
else "${config.home.homeDirectory}/.aws/config";
credentialsPath =
if cfg.credentialsPath != ""
then cfg.credentialsPath
else "${config.home.homeDirectory}/.aws/credentials";
in {
meta.maintainers = [ lib.maintainers.anthonyroussel ];
@ -17,6 +26,15 @@ in {
description = "Package providing {command}`aws`.";
};
settingsPath = lib.mkOption {
type = lib.types.path;
defaultText = "~/.config/aws/config";
apply = builtins.toString;
description = ''
Absolute path to where the settings file should be placed.
'';
};
settings = lib.mkOption {
type = lib.types.submodule { freeformType = iniFormat.type; };
default = { };
@ -31,6 +49,15 @@ in {
description = "Configuration written to {file}`$HOME/.aws/config`.";
};
credentialsPath = lib.mkOption {
type = lib.types.path;
defaultText = "~/.config/aws/credentials";
apply = builtins.toString;
description = ''
Absolute path to where the credentials file should be placed.
'';
};
credentials = lib.mkOption {
type = lib.types.submodule { freeformType = iniFormat.type; };
default = { };
@ -57,16 +84,25 @@ in {
config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
home.file."${config.home.homeDirectory}/.aws/config" =
home.sessionVariables = mkMerge [
(lib.mkIf (cfg.settingsPath != "") {
AWS_CONFIG_FILE = cfg.settingsPath;
})
(lib.mkIf (cfg.credentialsPath != "") {
AWS_SHARED_CREDENTIALS_FILE = cfg.credentialsPath;
})
];
home.file.${settingsPath} =
lib.mkIf (cfg.settings != { }) {
source =
iniFormat.generate "aws-config-${config.home.username}" cfg.settings;
source = iniFormat.generate "aws-config-${config.home.username}"
cfg.settings;
};
home.file."${config.home.homeDirectory}/.aws/credentials" =
home.file.${credentialsPath} =
lib.mkIf (cfg.credentials != { }) {
source = iniFormat.generate "aws-credentials-${config.home.username}"
cfg.credentials;
cfg.credentials;
};
};
}