From 9ffeb42e142b8367d077bd1c022cac9a04cdd19d Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:17:40 +0100 Subject: [PATCH] init nh --- home/programs/nh/default.nix | 8 ++++++++ home/scripts/nixy/default.nix | 24 +++++++++++++++++++----- hosts/laptop/home.nix | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 home/programs/nh/default.nix diff --git a/home/programs/nh/default.nix b/home/programs/nh/default.nix new file mode 100644 index 0000000..ba16dde --- /dev/null +++ b/home/programs/nh/default.nix @@ -0,0 +1,8 @@ +{ config, ... }: { + programs.nh = { + enable = true; + flake = config.var.configDirectory; + clean.enable = config.var.autoGarbageCollector; + clean.extraArgs = "--keep-since 4d --keep 3"; + }; +} diff --git a/home/scripts/nixy/default.nix b/home/scripts/nixy/default.nix index 8de1099..1007e51 100644 --- a/home/scripts/nixy/default.nix +++ b/home/scripts/nixy/default.nix @@ -25,7 +25,9 @@ let apps=( "󰑓;Rebuild;nixy rebuild" "󰦗;Upgrade;nixy upgrade" - "󰍜;Clean;nixy clean" + "󰚰;Update;nixy update" + ";Collect Garbage;nixy gc" + "󰍜;Clean Boot Menu;nixy cb" "󰌌;Hyprland Keybindings;nvim ${configDirectory}/docs/KEYBINDINGS-HYPRLAND.md" "󰋩;Wallpapers;nvim ${inputs.nixy-wallpapers}/docs/MOBILE-VIEW.md" ) @@ -48,14 +50,26 @@ let [[ $1 == "" ]] && ui if [[ $1 == "rebuild" ]];then - ${pkgs.nh}/bin/nh os switch ${configDirectory} --hostname ${hostname} + sudo nixos-rebuild switch --flake ${configDirectory}#${hostname} elif [[ $1 == "upgrade" ]];then - ${pkgs.nh}/bin/nh os switch ${configDirectory} --hostname ${hostname} --update - elif [[ $1 == "clean" ]];then - cd ${configDirectory} && ${pkgs.nh}/bin/nh clean all + sudo nixos-rebuild switch --upgrade --flake '${configDirectory}#${hostname}' + elif [[ $1 == "update" ]];then + cd ${configDirectory} && nix flake update + elif [[ $1 == "gc" ]];then + cd ${configDirectory} && sudo nix-collect-garbage -d + elif [[ $1 == "cb" ]];then + sudo /run/current-system/bin/switch-to-configuration boot elif [[ $1 == "remote" ]];then cd ~/.config/nixos && git add . && git commit -m "update" && git push ssh jack -S -C "cd /home/hadi/.config/nixos && git pull && sudo -S nixos-rebuild switch --flake ~/.config/nixos#jack" + elif [[ $1 == "loop" ]];then + while true; do + nixy + echo "Press enter to continue, e to exit" + read -n 1 REPLY + clear + [[ $REPLY == "e" ]] && exit 0 + done else echo "Unknown argument" fi diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index b461110..89fbb51 100644 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -16,6 +16,7 @@ ../../home/programs/markdown ../../home/programs/thunar ../../home/programs/lazygit + ../../home/programs/nh # Scripts ../../home/scripts # All scripts