Created
March 1, 2023 20:19
-
-
Save J-Swift/a4dad59843f1a1f512a72308031b5a44 to your computer and use it in GitHub Desktop.
nix auto-updating system with flakes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
readonly flake_name='u3macbook' | |
readonly real_script_dir=$( dirname $(readlink $HOME/.config/nixpkgs/flake.nix) ) | |
header() { | |
local -r msg="${1:-}" | |
echo '--------------------------------------------------------------------------------' | |
echo "> ${msg}" | |
echo '--------------------------------------------------------------------------------' | |
} | |
footer() { | |
echo | |
} | |
main() { | |
header 'brew upgrade' | |
brew upgrade | |
footer | |
header 'home-manager switch' | |
nix flake update "${real_script_dir}" | |
home-manager switch --flake path:$real_script_dir#$flake_name | |
footer | |
header 'home-manager expire-generations "-30 days"' | |
home-manager expire-generations '-30 days' | |
footer | |
echo '> Done.' | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment