{ config, lib, pkgs, ... }: with lib; let darwinChanges = '' if test -e /run/current-system/darwin-changes; then darwinChanges=$(diff --changed-group-format='%>' --unchanged-group-format= /run/current-system/darwin-changes $systemConfig/darwin-changes 2> /dev/null) || true if test -n "$darwinChanges"; then echo >&2 echo "CHANGELOG" >&2 echo >&2 echo "$darwinChanges" >&2 echo >&2 fi fi ''; buildUsers = optionalString config.services.nix-daemon.enable '' 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 echo "Create the build users or disable the daemon:" >&2 echo "$ ./bootstrap -u" >&2 echo >&2 echo "or set" >&2 echo >&2 echo " services.nix-daemon.enable = false;" >&2 echo >&2 exit 2 fi ''; nixPath = '' darwinConfig=$(NIX_PATH=${concatStringsSep ":" config.nix.nixPath} nix-instantiate --eval -E '') || true if ! test -e "$darwinConfig"; then echo "error: Changed but target does not exist, aborting activation" >&2 echo "Move you configuration.nix or set NIX_PATH:" >&2 echo >&2 echo " nix.nixPath = [ \"darwin-config=$(nix-instantiate --eval -E '')\" ];" >&2 echo >&2 exit 2 fi darwinPath=$(NIX_PATH=${concatStringsSep ":" config.nix.nixPath} nix-instantiate --eval -E '') || true if ! test -e "$darwinPath"; then echo "error: Changed but target does not exist, aborting activation" >&2 echo "Add the darwin repo as a channel or set NIX_PATH:" >&2 echo "$ sudo nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin" >&2 echo "$ sudo nix-channel --update" >&2 echo >&2 echo "or set" >&2 echo >&2 echo " nix.nixPath = [ \"darwin=$(nix-instantiate --eval -E '')\" ];" >&2 echo >&2 exit 2 fi nixpkgsPath=$(NIX_PATH=${concatStringsSep ":" config.nix.nixPath} nix-instantiate --eval -E '') || true if ! test -e "$nixpkgsPath"; then echo "error: Changed but target does not exist, aborting activation" >&2 echo "Add a nixpkgs channel or set NIX_PATH:" >&2 echo "$ sudo nix-channel --add http://nixos.org/channels/nixpkgs-unstable nixpkgs" >&2 echo "$ sudo nix-channel --update" >&2 echo >&2 echo "or set" >&2 echo >&2 echo " nix.nixPath = [ \"nixpkgs=$(nix-instantiate --eval -E '')\" ];" >&2 echo >&2 exit 2 fi ''; in { options = { }; config = { system.activationScripts.checks.text = '' ${darwinChanges} ${buildUsers} ${nixPath} if test ''${checkActivation:-0} -eq 1; then echo "ok" >&2 exit 0 fi ''; }; }