address suggestions and implement a backwards compatible way to introduce this change
This commit is contained in:
parent
90388be582
commit
908c854859
|
@ -2,14 +2,16 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.programs.awscli;
|
cfg = config.programs.awscli;
|
||||||
|
|
||||||
iniFormat = pkgs.formats.ini { };
|
iniFormat = pkgs.formats.ini { };
|
||||||
|
|
||||||
settingsPath =
|
settingsPath =
|
||||||
if config.programs.awscli.settings.path != ""
|
if config.programs.awscli.settingsPath != ""
|
||||||
then config.programs.awscli.settings.path
|
then config.programs.awscli.settingsPath
|
||||||
else "${config.home.homeDirectory}/.aws/config";
|
else "${config.home.homeDirectory}/.aws/config";
|
||||||
credentialsPath =
|
credentialsPath =
|
||||||
if config.programs.awscli.credentials.path != ""
|
if config.programs.awscli.credentialsPath != ""
|
||||||
then config.programs.awscli.credentials.path
|
then config.programs.awscli.credentialsPath
|
||||||
else "${config.home.homeDirectory}/.aws/credentials";
|
else "${config.home.homeDirectory}/.aws/credentials";
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [ lib.maintainers.anthonyroussel ];
|
meta.maintainers = [ lib.maintainers.anthonyroussel ];
|
||||||
|
@ -24,6 +26,15 @@ in {
|
||||||
description = "Package providing {command}`aws`.";
|
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 {
|
settings = lib.mkOption {
|
||||||
type = lib.types.submodule { freeformType = iniFormat.type; };
|
type = lib.types.submodule { freeformType = iniFormat.type; };
|
||||||
default = { };
|
default = { };
|
||||||
|
@ -38,6 +49,15 @@ in {
|
||||||
description = "Configuration written to {file}`$HOME/.aws/config`.";
|
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 {
|
credentials = lib.mkOption {
|
||||||
type = lib.types.submodule { freeformType = iniFormat.type; };
|
type = lib.types.submodule { freeformType = iniFormat.type; };
|
||||||
default = { };
|
default = { };
|
||||||
|
@ -64,21 +84,22 @@ in {
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
home.sessionVariables =
|
home.sessionVariables = mkMerge [
|
||||||
(lib.mkIf (cfg.settings.path != "") {
|
(lib.mkIf (cfg.settingsPath != "") {
|
||||||
AWS_CONFIG_FILE = cfg.settings.path;
|
AWS_CONFIG_FILE = cfg.settingsPath;
|
||||||
}) //
|
})
|
||||||
(lib.mkIf (cfg.credentials.path != "") {
|
(lib.mkIf (cfg.credentialsPath != "") {
|
||||||
AWS_SHARED_CREDENTIALS_FILE = cfg.credentials.path;
|
AWS_SHARED_CREDENTIALS_FILE = cfg.credentialsPath;
|
||||||
});
|
})
|
||||||
|
];
|
||||||
|
|
||||||
home.file.(settingsPath) =
|
home.file.${settingsPath} =
|
||||||
lib.mkIf (cfg.settings != { }) {
|
lib.mkIf (cfg.settings != { }) {
|
||||||
source = iniFormat.generate "aws-config-${config.home.username}"
|
source = iniFormat.generate "aws-config-${config.home.username}"
|
||||||
cfg.settings;
|
cfg.settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
home.file.(credentialsPath) =
|
home.file.${credentialsPath} =
|
||||||
lib.mkIf (cfg.credentials != { }) {
|
lib.mkIf (cfg.credentials != { }) {
|
||||||
source = iniFormat.generate "aws-credentials-${config.home.username}"
|
source = iniFormat.generate "aws-credentials-${config.home.username}"
|
||||||
cfg.credentials;
|
cfg.credentials;
|
||||||
|
|
Loading…
Reference in a new issue