diff --git a/subprojects/wrapper-manager-fds/modules/wrapper-manager/base.nix b/subprojects/wrapper-manager-fds/modules/wrapper-manager/base.nix index 5c9a2557..7b63a87a 100644 --- a/subprojects/wrapper-manager-fds/modules/wrapper-manager/base.nix +++ b/subprojects/wrapper-manager-fds/modules/wrapper-manager/base.nix @@ -8,7 +8,7 @@ let envConfig = config; - toStringType = with lib.types; coercedTo anything (x: builtins.toString x) str; + toStringType = with lib.types; coercedTo str (x: "${x}") str; envSubmodule = { config, @@ -23,6 +23,8 @@ let "unset" "set" "set-default" + "prefix" + "suffix" ]; description = '' Sets the appropriate action for the environment variable. @@ -37,15 +39,29 @@ let }; value = lib.mkOption { - type = toStringType; + type = with lib.types; either toStringType (listOf toStringType); description = '' The value of the variable that is holding. + + ::: {.note} + It accepts a list of values only for `prefix` and `suffix` action. + ::: ''; example = "HELLO THERE"; }; - isEscaped = lib.mkEnableOption "escaping of the value" // { - default = true; + separator = lib.mkOption { + type = lib.types.str; + description = '' + Separator used to create a character-delimited list of the + environment variable holding a list of values. + + ::: {.note} + Only used for `prefix` and `suffix` action. + ::: + ''; + default = ":"; + example = ";"; }; }; }; @@ -142,19 +158,15 @@ let pathAdd = envConfig.environment.pathAdd; makeWrapperArgs = - [ - "--argv0" - config.arg0 - ] - ++ (lib.mapAttrsToList ( + lib.mapAttrsToList ( n: v: if v.action == "unset" then "--${v.action} ${lib.escapeShellArg n}" + else if lib.elem v.action [ "prefix" "suffix" ] then + "--${v.action} ${lib.escapeShellArg n} ${lib.escapeShellArg v.separator} ${lib.escapeShellArg (lib.concatStringsSep v.separator v.value)}" else - "--${v.action} ${lib.escapeShellArg n} ${ - if v.isEscaped then lib.escapeShellArg v.value else v.value - }" - ) config.env) + "--${v.action} ${lib.escapeShellArg n} ${lib.escapeShellArg v.value}" + ) config.env ++ (builtins.map (v: "--add-flags ${lib.escapeShellArg v}") config.prependArgs) ++ (builtins.map (v: "--append-flags ${lib.escapeShellArg v}") config.appendArgs) ++ (lib.optionals (!envConfig.build.isBinary && config.preScript != "") ( @@ -167,10 +179,14 @@ let "--run" preScript ] - )); + )) + ++ [ "--inherit-argv0" ]; } - (lib.mkIf (config.pathAdd != [ ]) { env.PATH.value = lib.concatStringsSep ":" config.pathAdd; }) + (lib.mkIf (config.pathAdd != [ ]) { + env.PATH.value = lib.lists.map builtins.toString config.pathAdd; + env.PATH.action = "prefix"; + }) ]; }; in diff --git a/subprojects/wrapper-manager-fds/modules/wrapper-manager/xdg-dirs.nix b/subprojects/wrapper-manager-fds/modules/wrapper-manager/xdg-dirs.nix index 3557533f..80913d98 100644 --- a/subprojects/wrapper-manager-fds/modules/wrapper-manager/xdg-dirs.nix +++ b/subprojects/wrapper-manager-fds/modules/wrapper-manager/xdg-dirs.nix @@ -59,11 +59,13 @@ in } (lib.mkIf (config.xdg.configDirs != [ ]) { - env.XDG_CONFIG_DIRS.value = lib.concatStringsSep ":" config.xdg.configDirs; + env.XDG_CONFIG_DIRS.value = lib.lists.map builtins.toString config.xdg.configDirs; + env.XDG_CONFIG_DIRS.action = "prefix"; }) (lib.mkIf (config.xdg.dataDirs != [ ]) { - env.XDG_DATA_DIRS.value = lib.concatStringsSep ":" config.xdg.dataDirs; + env.XDG_DATA_DIRS.value = lib.lists.map builtins.toString config.xdg.dataDirs; + env.XDG_DATA_DIRS.action = "prefix"; }) ]; };