6 lib.mapAttrsToList (name: text: ''
7 # pre-switch check ${name}
11 if [[ $? != 0 ]]; then
12 echo "Pre-switch check '${name}' failed"
19 options.system.preSwitchChecks = lib.mkOption {
21 example = lib.literalExpression ''
30 A set of shell script fragments that are executed before the switch to a
31 new NixOS system configuration. A failure in any of these fragments will
32 cause the switch to fail and exit early.
35 type = lib.types.attrsOf lib.types.str;
41 script = pkgs.writeShellScript "pre-switch-checks" (preSwitchCheckScript set);