Allow 'environment' to be attrset

This commit is contained in:
Sridhar Ratnakumar 2023-06-09 17:07:40 -04:00
parent 7f624ce916
commit c837b8851f
2 changed files with 20 additions and 6 deletions

View File

@ -19,11 +19,11 @@
# This adds a `self.packages.default`
process-compose."default" = {
settings = {
environment = [
"DATAFILE=data.sqlite"
];
processes = {
environment = {
DATAFILE = "data.sqlite";
};
processes = {
# Print a pony every 2 seconds, because why not.
ponysay.command = ''
while true; do

View File

@ -1,6 +1,20 @@
{ lib, ... }:
let
inherit (lib) types;
inherit (types) nullOr either listOf str attrsOf;
in
lib.mkOption {
type = lib.types.nullOr (lib.types.listOf lib.types.str);
type =
nullOr
(either (listOf str) (attrsOf str));
default = null;
example = [ "ABC=2221" "PRINT_ERR=111" ];
example = { ABC="2221"; PRINT_ERR="111"; };
description = ''
Attrset of environment variables.
List of strings is also allowed.
'';
apply = attrs:
if ! builtins.isAttrs attrs then attrs else
lib.mapAttrsToList (name: value: "${name}=${value}") attrs;
}