1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-21 15:50:14 +00:00
nix-darwin/pkgs/darwin-uninstaller/configuration.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.3 KiB
Nix
Raw Normal View History

{ lib, pkgs, ... }:
2018-01-15 01:12:26 +01:00
with lib;
{
# We are uninstalling, disable sanity checks.
assertions = mkForce [];
system.activationScripts.checks.text = mkForce "";
environment.etc = mkForce {};
launchd.agents = mkForce {};
launchd.daemons = mkForce {};
launchd.user.agents = mkForce {};
# Restore any unmanaged `nix-daemon`.
nix.enable = false;
2018-01-15 01:12:26 +01:00
system.activationScripts.postUserActivation.text = mkAfter ''
nix-channel --remove darwin || true
2018-01-15 01:12:26 +01:00
'';
system.activationScripts.postActivation.text = mkAfter ''
nix-channel --remove darwin || true
if [[ -L /Applications/Nix\ Apps ]]; then
rm /Applications/Nix\ Apps
fi
if [[ -L /etc/static ]]; then
2018-01-15 22:31:50 +01:00
rm /etc/static
2018-01-15 01:12:26 +01:00
fi
# grep will return 1 when no lines matched which makes this line fail with `set -eo pipefail`
dscl . -list /Users UserShell | { grep "\s/run/" || true; } | awk '{print $1}' | while read -r user; do
shell=$(dscl . -read /Users/"$user" UserShell)
if [[ "$shell" != */bin/zsh ]]; then
echo >&2 "warning: changing $user's shell from $shell to /bin/zsh"
fi
dscl . -create /Users/"$user" UserShell /bin/zsh
done
while IFS= read -r -d "" file; do
mv "$file" "''${file%.*}"
done < <(find /etc -name '*.before-nix-darwin' -follow -print0)
2018-01-15 01:12:26 +01:00
'';
}