diff options
author | Michele Guerini Rocco <rnhmjoj@users.noreply.github.com> | 2020-11-10 00:04:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-10 00:04:47 +0100 |
commit | e6b8587b25a19528695c5c270e6ff1c209705c31 (patch) | |
tree | 6cb559b59415cec2c36ddd9f6f6024e88262dcd6 /nixos | |
parent | 50957910fc3e03dc0c2e55b037051ae4e2b2a950 (diff) | |
parent | bc3556546341f70801d6bba652b3955f312e0bad (diff) | |
download | nixpkgs-e6b8587b25a19528695c5c270e6ff1c209705c31.tar nixpkgs-e6b8587b25a19528695c5c270e6ff1c209705c31.tar.gz nixpkgs-e6b8587b25a19528695c5c270e6ff1c209705c31.tar.bz2 nixpkgs-e6b8587b25a19528695c5c270e6ff1c209705c31.tar.lz nixpkgs-e6b8587b25a19528695c5c270e6ff1c209705c31.tar.xz nixpkgs-e6b8587b25a19528695c5c270e6ff1c209705c31.tar.zst nixpkgs-e6b8587b25a19528695c5c270e6ff1c209705c31.zip |
Merge pull request #101755 from rnhmjoj/activation-type
nixos/activation-script: make scripts well-typed
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/system/activation/activation-script.nix | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/nixos/modules/system/activation/activation-script.nix b/nixos/modules/system/activation/activation-script.nix index ddfd1af4a31..18c77948cb9 100644 --- a/nixos/modules/system/activation/activation-script.nix +++ b/nixos/modules/system/activation/activation-script.nix @@ -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 { @@ -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 + '''; } ''; @@ -62,7 +74,7 @@ in idempotent and fast. ''; - type = types.attrsOf types.unspecified; # FIXME + type = types.attrsOf scriptType; apply = set: { script = @@ -125,7 +137,7 @@ in idempotent and fast. ''; - type = types.attrsOf types.unspecified; + type = with types; attrsOf scriptType; apply = set: { script = '' |