22 lines
671 B
Bash
Executable File
22 lines
671 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Install this repo's system nix.conf into place. Idempotent.
|
|
#
|
|
# sudo ./install.sh update /etc/nix/nix.conf (backs up the current one)
|
|
#
|
|
# The user-level ~/.config/nix/nix.conf is managed declaratively by Home
|
|
# Manager (see home/default.nix).
|
|
|
|
set -euo pipefail
|
|
|
|
repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
conf_file="$repo_dir/config/nix.conf"
|
|
target=/etc/nix/nix.conf
|
|
|
|
if [ ! -d "$(dirname "$target")" ]; then
|
|
sudo mkdir -p "$(dirname "$target")"
|
|
fi
|
|
if [ -f "$target" ] && ! cmp -s "$conf_file" "$target"; then
|
|
sudo cp -a "$target" "$target.bak.$(date +%Y%m%d%H%M%S)"
|
|
fi
|
|
sudo cp "$conf_file" "$target"
|
|
echo "installed $target" |