wrapper-manager-fds/modules: fix makeWrapper arguments

Welp, we escape the arguments properly this time since it doesn't work
anymore for some reason but at least it is consistent for both binary-
and shell-based wrappers.
This commit is contained in:
Gabriel Arazas 2024-07-27 20:00:36 +08:00
parent f04b1179d8
commit 5714c1b8c6
4 changed files with 60 additions and 50 deletions

View File

@ -96,9 +96,8 @@ let
Script fragments to run before the main executable. Script fragments to run before the main executable.
::: {.note} ::: {.note}
This option is only used when the wrapper script is not compiled This option is only used when {option}`build.isBinary` is set to
into a binary (that is, when {option}`build.isBinary` is set to `false`.
`false`).
::: :::
''; '';
default = ""; default = "";
@ -117,23 +116,29 @@ let
}; };
}; };
config = { config = lib.mkMerge [
env.PATH = lib.concatStringsSep ":" config.pathAdd; {
makeWrapperArgs = [
"--argv0" config.arg0
]
++ (builtins.map (v: "--unset ${lib.escapeShellArg v}") config.unset)
++ (lib.mapAttrsToList (n: v: "--set ${lib.escapeShellArg n} ${lib.escapeShellArg v}") 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 != "") (
let
preScript =
pkgs.runCommand "wrapper-script-prescript-${config.executableName}" { } config.preScript;
in
[ "--run" preScript ]));
}
makeWrapperArgs = [ (lib.mkIf (config.pathAdd != [ ]) {
"--argv0" config.arg0 env.PATH = lib.concatStringsSep ":" config.pathAdd;
]
++ (builtins.map (v: "--unset ${v}") config.unset) })
++ (lib.mapAttrsToList (n: v: "--set ${n} ${v}") config.env)
++ (builtins.map (v: "--add-flags ${v}") config.prependArgs) ];
++ (builtins.map (v: "--append-flags ${v}") config.appendArgs)
++ (lib.optionals (!envConfig.build.isBinary && config.preScript != "") (
let
preScript =
pkgs.runCommand "wrapper-script-prescript-${config.executableName}" { } config.preScript;
in
[ "--run" preScript ]));
};
}; };
in in
{ {

View File

@ -4,29 +4,27 @@ let
cfg = config.locale; cfg = config.locale;
localeModuleFactory = { isGlobal ? false }: { localeModuleFactory = { isGlobal ? false }: {
locale = { enable = lib.mkOption {
enable = lib.mkOption { type = lib.types.bool;
type = lib.types.bool; default = if isGlobal then true else cfg.enable;
default = if isGlobal then true else cfg.enable; description = if isGlobal then ''
description = if isGlobal then '' Whether to enable explicit glibc locale support. This is recommended
Whether to enable explicit glibc locale support. This is recommended for Nix-built applications.
for Nix-built applications. '' else ''
'' else '' Whether to enable locale support for this wrapper. Recommended for
Whether to enable locale support for this wrapper. Recommended for Nix-built applications.
Nix-built applications. '';
''; };
};
package = lib.mkOption { package = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = default =
if isGlobal if isGlobal
then (pkgs.glibcLocales.override { allLocales = true; }) then (pkgs.glibcLocales.override { allLocales = true; })
else cfg.package; else cfg.package;
description = '' description = ''
The package containing glibc locales. The package containing glibc locales.
''; '';
};
}; };
}; };
in in

View File

@ -114,8 +114,8 @@ in
# Welp, we could set it to the absolute location of the wrapper # Welp, we could set it to the absolute location of the wrapper
# executable in the final output but it's a big pain the ass to do # executable in the final output but it's a big pain the ass to do
# so but we're opting to the executable name instead. This current # so we're opting to the executable name instead. This current
# way of doing it is simply the next (and the simplest) best thing. # way of doing it is simply the next best (and the simplest) thing.
# We just have to make sure the build step for the wrapper script # We just have to make sure the build step for the wrapper script
# is consistent throughout the entire module environment. # is consistent throughout the entire module environment.
# #

View File

@ -44,14 +44,21 @@ in
xdgDirsType = { name, lib, config, ... }: { xdgDirsType = { name, lib, config, ... }: {
options.xdg = xdgDirsOption; options.xdg = xdgDirsOption;
# When set this way, we could allow the user to override everything. config = lib.mkMerge [
config.xdg.configDirs = cfg.configDirs; {
config.xdg.dataDirs = cfg.dataDirs; # When set this way, we could allow the user to override everything.
xdg.configDirs = cfg.configDirs;
xdg.dataDirs = cfg.dataDirs;
}
config.env = { (lib.mkIf (config.xdg.configDirs != [ ]) {
XDG_CONFIG_DIRS = lib.concatStringsSep ":" config.xdg.configDirs; env.XDG_CONFIG_DIRS = lib.concatStringsSep ":" config.xdg.configDirs;
XDG_DATA_DIRS = lib.concatStringsSep ":" config.xdg.dataDirs; })
};
(lib.mkIf (config.xdg.dataDirs != [ ]) {
env.XDG_DATA_DIRS = lib.concatStringsSep ":" config.xdg.dataDirs;
})
];
}; };
in in
with lib.types; attrsOf (submodule xdgDirsType); with lib.types; attrsOf (submodule xdgDirsType);