1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-15 17:51:01 +00:00

activation-checks: add NIX_PATH check for darwin

This commit is contained in:
Daiderd Jordan 2017-07-23 17:23:09 +02:00
parent 8016f1e2fd
commit 05d8495ed8
No known key found for this signature in database
GPG key ID: D02435D05B810C96

View file

@ -6,7 +6,29 @@ let
buildUsers = optionalString config.services.nix-daemon.enable '' buildUsers = optionalString config.services.nix-daemon.enable ''
buildUser=$(dscl . -read /Groups/nixbld GroupMembership 2>&1 | awk '/^GroupMembership: / {print $2}') buildUser=$(dscl . -read /Groups/nixbld GroupMembership 2>&1 | awk '/^GroupMembership: / {print $2}')
if [ -z $buildUser ]; then if [ -z $buildUser ]; then
echo "Using the nix-daemon requires build users, aborting activation" >&2 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 = optionalString true ''
darwinPath=$(NIX_PATH=${concatStringsSep ":" config.nix.nixPath} nix-instantiate --eval -E '<darwin>')
if [ -z $darwinPath ]; then
echo "error: Changed <darwin> 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 >&2
echo "or set" >&2
echo >&2
echo " nix.nixPath = [ \"darwin=${builtins.toString <darwin>}\" ];" >&2
echo >&2
exit 2 exit 2
fi fi
''; '';
@ -21,6 +43,7 @@ in
system.activationScripts.checks.text = '' system.activationScripts.checks.text = ''
set +e set +e
${buildUsers} ${buildUsers}
${nixPath}
set -e set -e
''; '';