############################################################################### # ๐Ÿ› ๏ธ NixOS & System Management Commands # # These commands help manage the system configuration using Nix flakes. ############################################################################### .PHONY: copy-config deploy home upgrade debug up upp test history repl clean gc-sudo gc gcboot # ๐Ÿ›‘ Utility function: copy ~/nixos to /etc/nixos copy-config: sudo rm -rf /etc/nixos/* sudo cp -r ~/nixos/* /etc/nixos/ # ๐Ÿš€ Deploy the current system configuration and make it the default on boot. # Usage: make deploy deploy: copy-config sudo nixos-rebuild switch --flake .#nixos # ๐Ÿก Same as `deploy`, but with a custom flake target (e.g., for home-manager). # Usage: make home home: copy-config sudo nixos-rebuild switch --flake /etc/nixos#nixos # โฌ†๏ธ Upgrade system packages and apply the latest flake changes. # Usage: make upgrade upgrade: copy-config sudo nixos-rebuild switch --upgrade --flake /etc/nixos # ๐Ÿ› Like `deploy`, but with verbose logs and error traces for debugging. # Usage: make debug debug: copy-config sudo nixos-rebuild switch --flake /etc/nixos --show-trace --verbose # ๐ŸŒ Update all flake inputs to their latest versions. # Usage: make up up: sudo nix flake update --flake /etc/nixos # ๐Ÿ” Update a specific flake input (e.g., `make upp i=home-manager`) # Usage: make upp i=home-manager upp: nix flake update ~/nixos/${i} # ๐Ÿงช Test the configuration without setting it as the default boot entry. # Usage: make test test: copy-config sudo nixos-rebuild test --flake /etc/nixos # ๐Ÿ•“ Show system profile history. # Usage: make history history: nix profile history --profile /nix/var/nix/profiles/system # ๐Ÿ’ป Launch the Nix REPL with nixpkgs from the flake. # Usage: make repl repl: nix repl -f flake:nixpkgs # ๐Ÿงน Clean up system profile history older than 1 day. # Usage: make clean clean: sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 1d # ๐Ÿงผ Collect and delete old garbage as root. # Usage: make gc-sudo gc-sudo: sudo nix-collect-garbage -d # ๐Ÿงฝ Same as above, but for the current user. # Usage: make gc gc: nix-collect-garbage -d # ๐Ÿฅพ Boot into a specific configuration without switching immediately. # Usage: make gcboot gcboot: sudo /run/current-system/bin/switch-to-configuration boot