mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 04:58:01 +00:00
wrapper-manager-fds/modules: add global pathAdd and env variables
This commit is contained in:
parent
6b7b2ee9cd
commit
b2c33db951
@ -1,13 +1,9 @@
|
||||
{ config, lib, ... }:
|
||||
{ config, lib, options, ... }:
|
||||
|
||||
let
|
||||
envConfig = config;
|
||||
|
||||
wrapperType = { name, lib, config, pkgs, ... }:
|
||||
let
|
||||
toStringType = with lib.types; coercedTo anything (x: builtins.toString x) str;
|
||||
flagType = with lib.types; listOf toStringType;
|
||||
|
||||
envSubmodule = { config, lib, name, ... }: {
|
||||
options = {
|
||||
action = lib.mkOption {
|
||||
@ -37,6 +33,10 @@ let
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
wrapperType = { name, lib, config, pkgs, ... }:
|
||||
let
|
||||
flagType = with lib.types; listOf toStringType;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
@ -84,36 +84,8 @@ let
|
||||
example = "custom-name";
|
||||
};
|
||||
|
||||
env = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule envSubmodule);
|
||||
description = ''
|
||||
A set of environment variables to be declared in the wrapper
|
||||
script.
|
||||
'';
|
||||
default = { };
|
||||
example = {
|
||||
"FOO_TYPE".value = "custom";
|
||||
"FOO_LOG_STYLE" = {
|
||||
action = "set-default";
|
||||
value = "systemd";
|
||||
};
|
||||
"USELESS_VAR".action = "unset";
|
||||
};
|
||||
};
|
||||
|
||||
pathAdd = lib.mkOption {
|
||||
type = with lib.types; listOf path;
|
||||
description = ''
|
||||
A list of paths to be added as part of the `PATH` environment variable.
|
||||
'';
|
||||
default = [ ];
|
||||
example = lib.literalExpression ''
|
||||
wrapperManagerLib.getBin (with pkgs; [
|
||||
yt-dlp
|
||||
gallery-dl
|
||||
])
|
||||
'';
|
||||
};
|
||||
env = options.environment.variables;
|
||||
pathAdd = options.environment.pathAdd;
|
||||
|
||||
preScript = lib.mkOption {
|
||||
type = lib.types.lines;
|
||||
@ -143,6 +115,9 @@ let
|
||||
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
env = envConfig.environment.variables;
|
||||
pathAdd = envConfig.environment.pathAdd;
|
||||
|
||||
makeWrapperArgs = [
|
||||
"--argv0" config.arg0
|
||||
]
|
||||
@ -164,9 +139,7 @@ let
|
||||
|
||||
(lib.mkIf (config.pathAdd != [ ]) {
|
||||
env.PATH.value = lib.concatStringsSep ":" config.pathAdd;
|
||||
|
||||
})
|
||||
|
||||
];
|
||||
};
|
||||
in
|
||||
@ -208,5 +181,37 @@ in
|
||||
]
|
||||
'';
|
||||
};
|
||||
|
||||
environment.variables = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule envSubmodule);
|
||||
description = ''
|
||||
A global set of environment variables and their actions to be applied
|
||||
per-wrapper.
|
||||
'';
|
||||
default = { };
|
||||
example = {
|
||||
"FOO_TYPE".value = "custom";
|
||||
"FOO_LOG_STYLE" = {
|
||||
action = "set-default";
|
||||
value = "systemd";
|
||||
};
|
||||
"USELESS_VAR".action = "unset";
|
||||
};
|
||||
};
|
||||
|
||||
environment.pathAdd = lib.mkOption {
|
||||
type = with lib.types; listOf path;
|
||||
description = ''
|
||||
A global list of paths to be added per-wrapper as part of the `PATH`
|
||||
environment variable.
|
||||
'';
|
||||
default = [ ];
|
||||
example = lib.literalExpression ''
|
||||
wrapperManagerLib.getBin (with pkgs; [
|
||||
yt-dlp
|
||||
gallery-dl
|
||||
])
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user