Skip to content

Commit c837b88

Browse files
committed
Allow 'environment' to be attrset
1 parent 7f624ce commit c837b88

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

example/flake.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
# This adds a `self.packages.default`
2020
process-compose."default" = {
2121
settings = {
22-
environment = [
23-
"DATAFILE=data.sqlite"
24-
];
25-
processes = {
22+
environment = {
23+
DATAFILE = "data.sqlite";
24+
};
2625

26+
processes = {
2727
# Print a pony every 2 seconds, because why not.
2828
ponysay.command = ''
2929
while true; do
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
{ lib, ... }:
2+
let
3+
inherit (lib) types;
4+
inherit (types) nullOr either listOf str attrsOf;
5+
in
26
lib.mkOption {
3-
type = lib.types.nullOr (lib.types.listOf lib.types.str);
7+
type =
8+
nullOr
9+
(either (listOf str) (attrsOf str));
410
default = null;
5-
example = [ "ABC=2221" "PRINT_ERR=111" ];
11+
example = { ABC="2221"; PRINT_ERR="111"; };
12+
description = ''
13+
Attrset of environment variables.
14+
15+
List of strings is also allowed.
16+
'';
17+
apply = attrs:
18+
if ! builtins.isAttrs attrs then attrs else
19+
lib.mapAttrsToList (name: value: "${name}=${value}") attrs;
620
}

0 commit comments

Comments
 (0)