diff --git a/modules/wrapper-manager/base.nix b/modules/wrapper-manager/base.nix index a292c51..95ef795 100644 --- a/modules/wrapper-manager/base.nix +++ b/modules/wrapper-manager/base.nix @@ -96,9 +96,8 @@ let Script fragments to run before the main executable. ::: {.note} - This option is only used when the wrapper script is not compiled - into a binary (that is, when {option}`build.isBinary` is set to - `false`). + This option is only used when {option}`build.isBinary` is set to + `false`. ::: ''; default = ""; @@ -117,23 +116,29 @@ let }; }; - config = { - env.PATH = lib.concatStringsSep ":" config.pathAdd; + config = lib.mkMerge [ + { + 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 = [ - "--argv0" config.arg0 - ] - ++ (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 ])); - }; + (lib.mkIf (config.pathAdd != [ ]) { + env.PATH = lib.concatStringsSep ":" config.pathAdd; + + }) + + ]; }; in { diff --git a/modules/wrapper-manager/locale.nix b/modules/wrapper-manager/locale.nix index 617c54a..41a3ef5 100644 --- a/modules/wrapper-manager/locale.nix +++ b/modules/wrapper-manager/locale.nix @@ -4,29 +4,27 @@ let cfg = config.locale; localeModuleFactory = { isGlobal ? false }: { - locale = { - enable = lib.mkOption { - type = lib.types.bool; - default = if isGlobal then true else cfg.enable; - description = if isGlobal then '' - Whether to enable explicit glibc locale support. This is recommended - for Nix-built applications. - '' else '' - Whether to enable locale support for this wrapper. Recommended for - Nix-built applications. - ''; - }; + enable = lib.mkOption { + type = lib.types.bool; + default = if isGlobal then true else cfg.enable; + description = if isGlobal then '' + Whether to enable explicit glibc locale support. This is recommended + for Nix-built applications. + '' else '' + Whether to enable locale support for this wrapper. Recommended for + Nix-built applications. + ''; + }; - package = lib.mkOption { - type = lib.types.package; - default = - if isGlobal - then (pkgs.glibcLocales.override { allLocales = true; }) - else cfg.package; - description = '' - The package containing glibc locales. - ''; - }; + package = lib.mkOption { + type = lib.types.package; + default = + if isGlobal + then (pkgs.glibcLocales.override { allLocales = true; }) + else cfg.package; + description = '' + The package containing glibc locales. + ''; }; }; in diff --git a/modules/wrapper-manager/xdg-desktop-entries.nix b/modules/wrapper-manager/xdg-desktop-entries.nix index 8461663..2d42462 100644 --- a/modules/wrapper-manager/xdg-desktop-entries.nix +++ b/modules/wrapper-manager/xdg-desktop-entries.nix @@ -114,8 +114,8 @@ in # 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 - # so but we're opting to the executable name instead. This current - # way of doing it is simply the next (and the simplest) best thing. + # so we're opting to the executable name instead. This current + # 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 # is consistent throughout the entire module environment. # diff --git a/modules/wrapper-manager/xdg-dirs.nix b/modules/wrapper-manager/xdg-dirs.nix index 5602716..ff448ea 100644 --- a/modules/wrapper-manager/xdg-dirs.nix +++ b/modules/wrapper-manager/xdg-dirs.nix @@ -44,14 +44,21 @@ in xdgDirsType = { name, lib, config, ... }: { options.xdg = xdgDirsOption; - # When set this way, we could allow the user to override everything. - config.xdg.configDirs = cfg.configDirs; - config.xdg.dataDirs = cfg.dataDirs; + config = lib.mkMerge [ + { + # When set this way, we could allow the user to override everything. + xdg.configDirs = cfg.configDirs; + xdg.dataDirs = cfg.dataDirs; + } - config.env = { - XDG_CONFIG_DIRS = lib.concatStringsSep ":" config.xdg.configDirs; - XDG_DATA_DIRS = lib.concatStringsSep ":" config.xdg.dataDirs; - }; + (lib.mkIf (config.xdg.configDirs != [ ]) { + env.XDG_CONFIG_DIRS = lib.concatStringsSep ":" config.xdg.configDirs; + }) + + (lib.mkIf (config.xdg.dataDirs != [ ]) { + env.XDG_DATA_DIRS = lib.concatStringsSep ":" config.xdg.dataDirs; + }) + ]; }; in with lib.types; attrsOf (submodule xdgDirsType);