2018-01-13 15:57:10 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
imports = [ <user-darwin-config> ];
|
|
|
|
|
2018-01-14 17:18:10 +01:00
|
|
|
users.nix.configureBuildUsers = true;
|
|
|
|
users.knownGroups = [ "nixbld" ];
|
|
|
|
|
2018-01-13 15:57:10 +01:00
|
|
|
system.activationScripts.preUserActivation.text = mkBefore ''
|
2018-09-14 21:52:12 +02:00
|
|
|
PATH=/nix/var/nix/profiles/default/bin:$PATH
|
|
|
|
|
2018-10-27 00:14:38 +01:00
|
|
|
darwinPath=$(NIX_PATH=${concatStringsSep ":" config.nix.nixPath} nix-instantiate --eval -E '<darwin>' 2> /dev/null) || true
|
2020-03-28 16:03:48 +01:00
|
|
|
i=y
|
2018-01-13 15:57:10 +01:00
|
|
|
if ! test -e "$darwinPath"; then
|
|
|
|
if test -t 1; then
|
|
|
|
read -p "Would you like to manage <darwin> with nix-channel? [y/n] " i
|
|
|
|
fi
|
|
|
|
case "$i" in
|
|
|
|
y|Y)
|
|
|
|
nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin
|
|
|
|
nix-channel --update
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! test -L /etc/bashrc && ! grep -q /etc/static/bashrc /etc/bashrc; then
|
|
|
|
if test -t 1; then
|
|
|
|
read -p "Would you like to load darwin configuration in /etc/bashrc? [y/n] " i
|
|
|
|
fi
|
|
|
|
case "$i" in
|
|
|
|
y|Y)
|
|
|
|
echo 'if test -e /etc/static/bashrc; then . /etc/static/bashrc; fi' | sudo tee -a /etc/bashrc
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2020-06-17 19:00:55 +02:00
|
|
|
if ! test -L /etc/zshrc && ! grep -q /etc/static/zshrc /etc/zshrc; then
|
|
|
|
if test -t 1; then
|
|
|
|
read -p "Would you like to load darwin configuration in /etc/zshrc? [y/n] " i
|
|
|
|
fi
|
|
|
|
case "$i" in
|
|
|
|
y|Y)
|
|
|
|
echo 'if test -e /etc/static/zshrc; then . /etc/static/zshrc; fi' | sudo tee -a /etc/zshrc
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2018-01-13 15:57:10 +01:00
|
|
|
if ! test -L /etc/profile && grep -q 'etc/profile.d/nix-daemon.sh' /etc/profile; then
|
|
|
|
if test -t 1; then
|
|
|
|
read -p "Would you like to remove nix-daemon.sh configuration in /etc/profile? [y/n] " i
|
|
|
|
fi
|
|
|
|
case "$i" in
|
|
|
|
y|Y)
|
|
|
|
sudo patch -d /etc -p1 < '${./profile.patch}'
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2018-01-13 22:32:47 +01:00
|
|
|
|
|
|
|
if ! test -L /run; then
|
2018-01-14 12:44:50 +01:00
|
|
|
if test -t 1; then
|
|
|
|
read -p "Would you like to create /run? [y/n] " i
|
|
|
|
fi
|
|
|
|
case "$i" in
|
|
|
|
y|Y)
|
2020-03-28 16:03:48 +01:00
|
|
|
if ! grep -q '^run\b' /etc/synthetic.conf 2>/dev/null; then
|
|
|
|
echo "setting up /etc/synthetic.conf..."
|
|
|
|
echo -e "run\tprivate/var/run" | sudo tee -a /etc/synthetic.conf >/dev/null
|
|
|
|
/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B 2>/dev/null || true
|
|
|
|
fi
|
|
|
|
if ! test -L /run; then
|
|
|
|
echo "setting up /run..."
|
|
|
|
sudo ln -sfn private/var/run /run
|
|
|
|
fi
|
2018-01-14 12:44:50 +01:00
|
|
|
;;
|
|
|
|
esac
|
2018-01-13 22:32:47 +01:00
|
|
|
fi
|
|
|
|
'';
|
2018-01-13 15:57:10 +01:00
|
|
|
}
|