summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2019-01-02 21:13:45 +0100
committerDaiderd Jordan <daiderd@gmail.com>2019-01-02 21:13:45 +0100
commit8a6c78361625975de529f50e8e7e24798209a5fb (patch)
tree3146442c48a558f0645deb1a70be0468c3aff767 /modules/system
parent72b3648fa0e0a9ed165131381bab80fe51e72578 (diff)
checks: generalize and make them more configurable
All the checks are now aggregated in system.checks.text making it easy to allow certain checks to be disabled as well as disabling them alltogether if desired. eg. # Disable all checks. system.checks.text = mkForce ""; Fixes #117
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/checks.nix37
1 files changed, 27 insertions, 10 deletions
diff --git a/modules/system/checks.nix b/modules/system/checks.nix
index 9a3bdfc..af6cb6f 100644
--- a/modules/system/checks.nix
+++ b/modules/system/checks.nix
@@ -3,6 +3,8 @@
with lib;
let
+ cfg = config.system.checks;
+
darwinChanges = ''
darwinChanges=/dev/null
if test -e /run/current-system/darwin-changes; then
@@ -30,7 +32,7 @@ let
fi
'';
- buildUsers = optionalString config.services.nix-daemon.enable ''
+ buildUsers = ''
buildUser=$(dscl . -read /Groups/nixbld GroupMembership 2>&1 | awk '/^GroupMembership: / {print $2}') || true
if [ -z $buildUser ]; then
echo "error: Using the nix-daemon requires build users, aborting activation" >&2
@@ -135,7 +137,7 @@ let
fi
'';
- nixGarbageCollector = optionalString config.nix.gc.automatic ''
+ nixGarbageCollector = ''
if test -O /nix/store; then
echo "error: A single-user install can't run gc as root, aborting activation" >&2
echo "Configure the garbage collector to run as the current user:" >&2
@@ -149,19 +151,34 @@ in
{
options = {
+ system.checks.verifyNixPath = mkOption {
+ type = types.bool;
+ default = true;
+ description = "Whether to run the NIX_PATH validation checks.";
+ };
+
+ system.checks.text = mkOption {
+ internal = true;
+ type = types.lines;
+ default = "";
+ };
};
config = {
+ system.checks.text = mkMerge [
+ darwinChanges
+ runLink
+ (mkIf config.services.nix-daemon.enable buildUsers)
+ nixStore
+ (mkIf config.nix.gc.automatic nixGarbageCollector)
+ nixChannels
+ nixInstaller
+ (mkIf cfg.verifyNixPath nixPath)
+ ];
+
system.activationScripts.checks.text = ''
- ${darwinChanges}
- ${runLink}
- ${buildUsers}
- ${nixStore}
- ${nixGarbageCollector}
- ${nixChannels}
- ${nixInstaller}
- ${nixPath}
+ ${cfg.text}
if test ''${checkActivation:-0} -eq 1; then
echo "ok" >&2