From 90388be5822a169bb568ab9219656253b86c4f2b Mon Sep 17 00:00:00 2001 From: obvionaoe Date: Mon, 20 May 2024 23:51:08 +0100 Subject: [PATCH] add logic, missing options --- modules/programs/awscli.nix | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/modules/programs/awscli.nix b/modules/programs/awscli.nix index a4cfc108f..6130984d1 100644 --- a/modules/programs/awscli.nix +++ b/modules/programs/awscli.nix @@ -3,7 +3,14 @@ let cfg = config.programs.awscli; iniFormat = pkgs.formats.ini { }; - + settingsPath = + if config.programs.awscli.settings.path != "" + then config.programs.awscli.settings.path + else "${config.home.homeDirectory}/.aws/config"; + credentialsPath = + if config.programs.awscli.credentials.path != "" + then config.programs.awscli.credentials.path + else "${config.home.homeDirectory}/.aws/credentials"; in { meta.maintainers = [ lib.maintainers.anthonyroussel ]; @@ -57,13 +64,21 @@ in { config = lib.mkIf cfg.enable { home.packages = [ cfg.package ]; - home.file."${config.home.homeDirectory}/.aws/config" = + home.sessionVariables = + (lib.mkIf (cfg.settings.path != "") { + AWS_CONFIG_FILE = cfg.settings.path; + }) // + (lib.mkIf (cfg.credentials.path != "") { + AWS_SHARED_CREDENTIALS_FILE = cfg.credentials.path; + }); + + 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;