-
Notifications
You must be signed in to change notification settings - Fork 2
/
apply
executable file
·33 lines (25 loc) · 1018 Bytes
/
apply
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
set -euo pipefail
main() {
# allow installing packages with "unfree" licenses
export NIXPKGS_ALLOW_UNFREE=1
local profile="${1:-$(uname | tr '[:upper:]' '[:lower:]')}"
local targetDir="${HOME}/.config/home-manager"
mkdir -p "${targetDir}"
ln -sf "${HOME}/dotfiles/profiles/${profile}.nix" "${targetDir}/home.nix"
# ensure nix things are available
if [ -f "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]; then
source $HOME/.nix-profile/etc/profile.d/nix.sh
export PATH="${HOME}/.nix-profile/bin:${PATH}"
fi
export NIX_PATH=$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels${NIX_PATH:+:$NIX_PATH}
# ensure packages installed by home manager are higher priority (0-6, 0 being highest) than nix defaults
nix-env --set-flag priority 0 home-manager-path
# for the first run, remove files known to conflict.
if [ ! -f ~/.config/git/config ]; then
rm -rf ~/.bashrc ~/.bash_profile
fi
home-manager switch
nix-store --gc
}
main "$@"