Skip to content

Commit

Permalink
Merge pull request #101755 from rnhmjoj/activation-type
Browse files Browse the repository at this point in the history
nixos/activation-script: make scripts well-typed
  • Loading branch information
rnhmjoj authored Nov 9, 2020
2 parents 5095791 + bc35565 commit e6b8587
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions nixos/modules/system/activation/activation-script.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ let
utillinux # needed for mount and mountpoint
];

scriptType = with types;
let scriptOptions =
{ deps = mkOption
{ type = types.listOf types.str;
default = [ ];
description = "List of dependencies. The script will run after these.";
};
text = mkOption
{ type = types.lines;
description = "The content of the script.";
};
};
in either str (submodule { options = scriptOptions; });

in

{
Expand All @@ -40,16 +54,14 @@ in
default = {};

example = literalExample ''
{ stdio = {
text = '''
# Needed by some programs.
ln -sfn /proc/self/fd /dev/fd
ln -sfn /proc/self/fd/0 /dev/stdin
ln -sfn /proc/self/fd/1 /dev/stdout
ln -sfn /proc/self/fd/2 /dev/stderr
''';
deps = [];
};
{ stdio.text =
'''
# Needed by some programs.
ln -sfn /proc/self/fd /dev/fd
ln -sfn /proc/self/fd/0 /dev/stdin
ln -sfn /proc/self/fd/1 /dev/stdout
ln -sfn /proc/self/fd/2 /dev/stderr
''';
}
'';

Expand All @@ -62,7 +74,7 @@ in
idempotent and fast.
'';

type = types.attrsOf types.unspecified; # FIXME
type = types.attrsOf scriptType;

apply = set: {
script =
Expand Down Expand Up @@ -125,7 +137,7 @@ in
idempotent and fast.
'';

type = types.attrsOf types.unspecified;
type = with types; attrsOf scriptType;

apply = set: {
script = ''
Expand Down

0 comments on commit e6b8587

Please sign in to comment.