mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 12:19:07 +00:00
wrapper-manager-fds/modules: add global pathAdd and env variables
This commit is contained in:
parent
6b7b2ee9cd
commit
b2c33db951
@ -1,42 +1,42 @@
|
|||||||
{ config, lib, ... }:
|
{ config, lib, options, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
envConfig = config;
|
envConfig = config;
|
||||||
|
|
||||||
|
toStringType = with lib.types; coercedTo anything (x: builtins.toString x) str;
|
||||||
|
envSubmodule = { config, lib, name, ... }: {
|
||||||
|
options = {
|
||||||
|
action = lib.mkOption {
|
||||||
|
type = lib.types.enum [ "unset" "set" "set-default" ];
|
||||||
|
description = ''
|
||||||
|
Sets the appropriate action for the environment variable.
|
||||||
|
|
||||||
|
* `unset`... unsets the given variable.
|
||||||
|
* `set-default` only sets the variable with the given value if
|
||||||
|
not already set.
|
||||||
|
* `set` forcibly sets the variable with given value.
|
||||||
|
'';
|
||||||
|
default = "set";
|
||||||
|
example = "unset";
|
||||||
|
};
|
||||||
|
|
||||||
|
value = lib.mkOption {
|
||||||
|
type = toStringType;
|
||||||
|
description = ''
|
||||||
|
The value of the variable that is holding.
|
||||||
|
'';
|
||||||
|
example = "HELLO THERE";
|
||||||
|
};
|
||||||
|
|
||||||
|
isEscaped = lib.mkEnableOption "escaping of the value" // {
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
wrapperType = { name, lib, config, pkgs, ... }:
|
wrapperType = { name, lib, config, pkgs, ... }:
|
||||||
let
|
let
|
||||||
toStringType = with lib.types; coercedTo anything (x: builtins.toString x) str;
|
|
||||||
flagType = with lib.types; listOf toStringType;
|
flagType = with lib.types; listOf toStringType;
|
||||||
|
|
||||||
envSubmodule = { config, lib, name, ... }: {
|
|
||||||
options = {
|
|
||||||
action = lib.mkOption {
|
|
||||||
type = lib.types.enum [ "unset" "set" "set-default" ];
|
|
||||||
description = ''
|
|
||||||
Sets the appropriate action for the environment variable.
|
|
||||||
|
|
||||||
* `unset`... unsets the given variable.
|
|
||||||
* `set-default` only sets the variable with the given value if
|
|
||||||
not already set.
|
|
||||||
* `set` forcibly sets the variable with given value.
|
|
||||||
'';
|
|
||||||
default = "set";
|
|
||||||
example = "unset";
|
|
||||||
};
|
|
||||||
|
|
||||||
value = lib.mkOption {
|
|
||||||
type = toStringType;
|
|
||||||
description = ''
|
|
||||||
The value of the variable that is holding.
|
|
||||||
'';
|
|
||||||
example = "HELLO THERE";
|
|
||||||
};
|
|
||||||
|
|
||||||
isEscaped = lib.mkEnableOption "escaping of the value" // {
|
|
||||||
default = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
@ -84,36 +84,8 @@ let
|
|||||||
example = "custom-name";
|
example = "custom-name";
|
||||||
};
|
};
|
||||||
|
|
||||||
env = lib.mkOption {
|
env = options.environment.variables;
|
||||||
type = with lib.types; attrsOf (submodule envSubmodule);
|
pathAdd = options.environment.pathAdd;
|
||||||
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
|
|
||||||
])
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
preScript = lib.mkOption {
|
preScript = lib.mkOption {
|
||||||
type = lib.types.lines;
|
type = lib.types.lines;
|
||||||
@ -143,6 +115,9 @@ let
|
|||||||
|
|
||||||
config = lib.mkMerge [
|
config = lib.mkMerge [
|
||||||
{
|
{
|
||||||
|
env = envConfig.environment.variables;
|
||||||
|
pathAdd = envConfig.environment.pathAdd;
|
||||||
|
|
||||||
makeWrapperArgs = [
|
makeWrapperArgs = [
|
||||||
"--argv0" config.arg0
|
"--argv0" config.arg0
|
||||||
]
|
]
|
||||||
@ -164,9 +139,7 @@ let
|
|||||||
|
|
||||||
(lib.mkIf (config.pathAdd != [ ]) {
|
(lib.mkIf (config.pathAdd != [ ]) {
|
||||||
env.PATH.value = lib.concatStringsSep ":" config.pathAdd;
|
env.PATH.value = lib.concatStringsSep ":" config.pathAdd;
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
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