diff options
| author | Michael Hoang <enzime@users.noreply.github.com> | 2024-11-11 20:23:06 +1100 |
|---|---|---|
| committer | Michael Hoang <enzime@users.noreply.github.com> | 2024-11-16 23:19:11 +1100 |
| commit | 6d794390fa48afbe5d8b0020392f55bc1d800cb6 (patch) | |
| tree | fdd977ab2764b962feaca811727fde000be715e3 | |
| parent | 5d1b7ac696c2c9cf4206d7fbd3ebe3daa3b9bbd2 (diff) | |
checks: check single user installs don't have the `nix-daemon` enabled
Remove suggestion to set `nix.useDaemon` as it came without an
explanation of how the `nix-daemon` would be unmanaged and would most
likely lead to most users running an old version of Nix as the daemon.
| -rw-r--r-- | modules/system/checks.nix | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/modules/system/checks.nix b/modules/system/checks.nix index ab6ea19..949a28e 100644 --- a/modules/system/checks.nix +++ b/modules/system/checks.nix @@ -129,18 +129,26 @@ let fi ''; - singleUser = '' - if grep -q 'build-users-group =' /etc/nix/nix.conf; then - echo "[1;31merror: The daemon is not enabled but this is a multi-user install, aborting activation[0m" >&2 - echo "Enable the nix-daemon service:" >&2 - echo >&2 - echo " services.nix-daemon.enable = true;" >&2 - echo >&2 - echo "or set" >&2 - echo >&2 - echo " nix.useDaemon = true;" >&2 - echo >&2 - exit 2 + nixDaemon = if config.nix.useDaemon then '' + if ! dscl . -read /Groups/nixbld PrimaryGroupID &> /dev/null; then + printf >&2 '[1;31merror: The daemon should not be enabled for single-user installs, aborting activation[0m\n' + printf >&2 'Disable the nix-daemon service:\n' + printf >&2 '\n' + printf >&2 ' services.nix-daemon.enable = false;\n' + printf >&2 '\n' + # shellcheck disable=SC2016 + printf >&2 'and remove `nix.useDaemon` from your configuration if it is present.\n' + printf >&2 '\n' + exit 2 + fi + '' else '' + if dscl . -read /Groups/nixbld PrimaryGroupID &> /dev/null; then + printf >&2 '[1;31merror: The daemon should be enabled for multi-user installs, aborting activation[0m\n' + printf >&2 'Enable the nix-daemon service:\n' + printf >&2 '\n' + printf >&2 ' services.nix-daemon.enable = true;\n' + printf >&2 '\n' + exit 2 fi ''; @@ -337,7 +345,7 @@ in (mkIf cfg.verifyBuildUsers buildUsers) (mkIf cfg.verifyBuildUsers preSequoiaBuildUsers) (mkIf config.nix.configureBuildUsers buildGroupID) - (mkIf (!config.nix.useDaemon) singleUser) + nixDaemon nixStore (mkIf (config.nix.gc.automatic && config.nix.gc.user == null) nixGarbageCollector) (mkIf (config.nix.optimise.automatic && config.nix.optimise.user == null) nixStoreOptimiser) |
