From fe59fcdaef977630959c2f26eb86221a5b8b6d88 Mon Sep 17 00:00:00 2001 From: Emmet Date: Fri, 19 May 2023 21:03:38 -0500 Subject: [PATCH] Added phoenix gc and updated readme for flakes --- README.org | 17 ++++++++++++++--- user/bin/phoenix.nix | 8 ++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index f341fe6..6527d2a 100644 --- a/README.org +++ b/README.org @@ -14,14 +14,15 @@ To get this running on a NixOS system, I will start by cloning the repo: git clone https://gitlab.com/librephoenix/nixos-config.git /path/to/my/config/folder #+END_SRC -To get the hardware configuration, I can other copy from =/etc/nixos/hardware-configuration.nix= or run: +To get the hardware configuration on a new system, I can other copy from =/etc/nixos/hardware-configuration.nix= or run: #+BEGIN_SRC sh :noeval sudo nixos-generate-config --dir /dotfiles/path/system #+END_SRC Then, I can switch into the system configuration by running: #+BEGIN_SRC sh :noeval -sudo nixos-rebuild switch -I nixos-config=nixos-config=/dotfiles/path/system/configuration.nix +cd /dotfiles/path +sudo nixos-rebuild switch --flake .#snowfire #+END_SRC Home manager can be installed with: @@ -33,5 +34,15 @@ nix-shell '' -A install Then, my home-manager configuration can be installed with: #+BEGIN_SRC sh :noeval -home-manager switch -f /dotfiles/path/user/home.nix +home-manager switch --flake #.emmet #+END_SRC + +This loads in my convenience script =phoenix=, which replaces frequently used nix and nixos commands with more user friendly ones, namely: +- =phoenix sync= to build and switch system and home configuration + - =phoenix sync system= to build and switch only system configuration + - =phoenix sync user= to build and switch only home configuration +- =phoenix update= to update flake inputs +- =phoenix gc= to garbage collect + - If no argument is given, it cleans anything older than 30 days + - If a time argument is supplied (i.e. 10d), it cleans stuff older than that (10 days in this example) + - If the argument =full= is given, it deletes /all/ previous generations diff --git a/user/bin/phoenix.nix b/user/bin/phoenix.nix index f20d1e7..e6fcbce 100644 --- a/user/bin/phoenix.nix +++ b/user/bin/phoenix.nix @@ -26,6 +26,14 @@ let pushd ''+myDotfilesDir+''; nix flake update; popd; + elif [ "$1" = "gc" ]; then + if [ "$2" = "full" ]; then + sudo nix-collect-garbage --delete-old; + elif [ "$2" ]; then + sudo nix-collect-garbage --delete-older-than $2; + else + sudo nix-collect-garbage --delete-older-than 30d; + fi fi ''; in