added some utilities and going to nh

This commit is contained in:
Prouk committed 2026-10-10 23:58:13 +02:00
1 parent 3fb55bb091
commit 8ac7fd4862
8 files changed
+90 -54

No files matched your search

Generated
+13 -13
View File
@@ -7,11 +7,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1790955005, "lastModified": 1791306979,
"narHash": "sha256-EEQKUylD8zuRTmDFX4rbwsHQ+iZhqqOldYcFN8SLcE0=", "narHash": "sha256-KuLePuhwJM9NLt/gTLHzXaOoSZKGoB3m7NfXjiQ98HY=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "0560d64401a6d5370732a69d08bc4a6b135962d9", "rev": "fae6e9e42c3b762ab47635cddcfaf6f52374a61b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -22,11 +22,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1790822859, "lastModified": 1791260994,
"narHash": "sha256-VBA0QerzzmL+4wxgtwiCdiLwLpJg2/9xOxhgO3BRJQA=", "narHash": "sha256-MFBjw66d4h06MvpW6lIl7RwarLteD0sk859CncGwb1Q=",
"rev": "c59305bab2065cfecc4944690d9eedbb56f3a9fa", "rev": "151fa4e8ddfdd8dd25d945ad94ed54a13de9f6e4",
"type": "tarball", "type": "tarball",
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1083223.c59305bab206/nixexprs.tar.zst" "url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1086391.151fa4e8ddfd/nixexprs.tar.zst"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
@@ -71,11 +71,11 @@
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1790770493, "lastModified": 1791203262,
"narHash": "sha256-sNWVkfOVelr60lWHvEgCWx7Mr/2PcoAN8oOrOk7Yp/g=", "narHash": "sha256-+RlIyHipr7BOLsIC9jnpzbkLBsY6XbLhuPinAwJsYjo=",
"owner": "Supreeeme", "owner": "Supreeeme",
"repo": "xwayland-satellite", "repo": "xwayland-satellite",
"rev": "b5690b56d749526a05db9b9268d58bf8f700957f", "rev": "ae88928f7334556d298b8d9552abdf395931931b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -94,11 +94,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1790940304, "lastModified": 1791266850,
"narHash": "sha256-i1W4IdG9PVdSRN1rvTHaqiVqvnRS3+OXgaQa7z5iRDc=", "narHash": "sha256-F/scdmE9Y03TfSQWrBHaJWTRTr3rRQBqvJSDgF48g1c=",
"owner": "0xc000022070", "owner": "0xc000022070",
"repo": "zen-browser-flake", "repo": "zen-browser-flake",
"rev": "b12abb753335dd3b9ba5ea90d3be799bd9b2dc29", "rev": "d9e4e25d6ade5d541074045d332d887c044e11f5",
"type": "github" "type": "github"
}, },
"original": { "original": {
+1
View File
@@ -9,6 +9,7 @@
just just
nil nil
nixd nixd
scrcpy
]; ];
programs.zed-editor = { programs.zed-editor = {
+1
View File
@@ -4,5 +4,6 @@
btop btop
gparted gparted
yazi yazi
unzip
]; ];
} }
+8
View File
@@ -1,5 +1,13 @@
{ ... }: { ... }:
{ {
programs.fish = {
enable = true;
# nixpkgs' devenv only ships fish completions, not the auto-loaded hook.
interactiveShellInit = ''
devenv hook fish | source
'';
};
programs.bash = { programs.bash = {
enable = true; enable = true;
bashrcExtra = "eval \"$(devenv hook bash)\"\n"; bashrcExtra = "eval \"$(devenv hook bash)\"\n";
+52 -40
View File
@@ -1,63 +1,75 @@
# Justfile to safely clean up NixOS profiles, keeping only the last 3 generations. # Justfile to safely clean up NixOS profiles, keeping only the last 3 generations.
# Uses nh (https://github.com/nix-community/nh) when available, falling back to plain nix commands.
host := "prouk"
keep := "3"
nh := `command -v nh || true`
hm_profile := env("HOME") / ".local/state/nix/profiles/home-manager"
# Default recipe displays the help menu. # Default recipe displays the help menu.
help: help:
@echo "NixOS Profile Cleanup Utility" @echo "NixOS Profile Cleanup Utility"
@echo "=============================" @echo "============================="
@echo "nh: {{ if nh != "" { "found (" + nh + ")" } else { "not found, using plain nix commands" } }}"
@echo "Available recipes:" @echo "Available recipes:"
@echo " just dry-run - Safe preview of what will be deleted" @echo " just dry-run - Safe preview of what will be deleted"
@echo " just clean-system - Clean system generations and update bootloader (requires sudo)" @echo " just clean-all - Clean System, User and Home Manager generations (requires sudo)"
@echo " just clean-user - Clean current user's profile generations" @echo " just build - Rebuild and switch the system"
@echo " just clean-home-manager - Clean Home Manager generations (if applicable)" @echo " just update - Update flake inputs"
@echo " just clean-all - Clean everything (System, User, and Home Manager)"
# Dry run to preview changes without deleting anything. # Dry run to preview changes without deleting anything.
dry-run: dry-run:
@echo "=== [DRY RUN] System Profile ===" #!/usr/bin/env bash
sudo nix-env --profile /nix/var/nix/profiles/system --delete-generations +3 --dry-run set -euo pipefail
@echo "\n=== [DRY RUN] User Profile ===" if [ -n "{{ nh }}" ]; then
nix-env --delete-generations +3 --dry-run echo "=== [DRY RUN] All profiles (nh) ==="
@echo "\n=== [DRY RUN] Home Manager Profile ===" nh clean all --keep {{ keep }} --dry
@if [ -d "$HOME/.local/state/nix/profiles/home-manager" ]; then \ exit 0
nix-env --profile "$HOME/.local/state/nix/profiles/home-manager" --delete-generations +3 --dry-run; \ fi
elif [ -d "$HOME/.nix-profile" ]; then \ echo "=== [DRY RUN] System Profile ==="
echo "No Home Manager directory found, but user profile exists."; \ sudo nix-env --profile /nix/var/nix/profiles/system --delete-generations +{{ keep }} --dry-run
else \ echo -e "\n=== [DRY RUN] User Profile ==="
echo "No Home Manager profile detected."; \ nix-env --delete-generations +{{ keep }} --dry-run
echo -e "\n=== [DRY RUN] Home Manager Profile ==="
if [ -e "{{ hm_profile }}" ]; then
nix-env --profile "{{ hm_profile }}" --delete-generations +{{ keep }} --dry-run
elif [ -d "$HOME/.nix-profile" ]; then
echo "No Home Manager directory found, but user profile exists."
else
echo "No Home Manager profile detected."
fi fi
# Clean system generations (requires sudo). # Clean system, user and Home Manager generations, then update the bootloader (requires sudo).
clean-system: clean-all:
@echo "--- Cleaning System Profile (SUDO) ---" #!/usr/bin/env bash
sudo nix-env --profile /nix/var/nix/profiles/system --delete-generations +3 set -euo pipefail
if [ -n "{{ nh }}" ]; then
echo "--- Cleaning All Profiles (nh) ---"
nh clean all --keep {{ keep }}
echo "--- Updating Bootloader Menu ---"
nh os boot . --hostname {{ host }}
else
echo "--- Cleaning System Profile (SUDO) ---"
sudo nix-env --profile /nix/var/nix/profiles/system --delete-generations +{{ keep }}
echo "--- Cleaning User Profile ---"
nix-env --delete-generations +{{ keep }}
echo "--- Cleaning Home Manager Profile ---"
if [ -e "{{ hm_profile }}" ]; then
nix-env --profile "{{ hm_profile }}" --delete-generations +{{ keep }}
else
echo "No Home Manager profile found. Skipping."
fi
sudo nix-collect-garbage sudo nix-collect-garbage
@echo "--- Updating Bootloader Menu ---"
sudo nixos-rebuild boot --flake .#prouk
# Clean user generations (no sudo).
clean-user:
@echo "--- Cleaning User Profile ---"
nix-env --delete-generations +3
nix-collect-garbage nix-collect-garbage
echo "--- Updating Bootloader Menu ---"
# Clean Home Manager generations (no sudo). sudo nixos-rebuild boot --flake .#{{ host }}
clean-home-manager:
@echo "--- Cleaning Home Manager Profile ---"
@if [ -d "$HOME/.local/state/nix/profiles/home-manager" ]; then \
nix-env --profile "$HOME/.local/state/nix/profiles/home-manager" --delete-generations +3; \
nix-collect-garbage; \
else \
echo "No Home Manager profile found. Skipping."; \
fi fi
echo "All cleanups successfully completed!"
# Clean everything in one go.
clean-all: clean-system clean-user clean-home-manager
@echo "All cleanups successfully completed!"
# Build. # Build.
build: build:
@echo "--- Rebuilding System ---" @echo "--- Rebuilding System ---"
sudo nixos-rebuild switch --flake .#prouk {{ if nh != "" { "nh os switch . --hostname " + host } else { "sudo nixos-rebuild switch --flake .#" + host } }}
# Update flake. # Update flake.
update: update:
+1
View File
@@ -27,6 +27,7 @@
# Programs # Programs
./programs/gaming.nix ./programs/gaming.nix
./programs/obs.nix ./programs/obs.nix
./programs/nh.nix
]; ];
# NO TOUCHY # NO TOUCHY
+9
View File
@@ -0,0 +1,9 @@
{ ... }:
{
# nh: nicer frontend for nixos-rebuild / nix-collect-garbage.
# Cleanup stays on nix.gc (see system/nix.nix) to avoid two GC timers.
programs.nh = {
enable = true;
flake = "/home/prouk/flake";
};
}
+5 -1
View File
@@ -1,7 +1,11 @@
{ ... }: { pkgs, ... }:
{ {
# Required so fish is registered in /etc/shells and gets the NixOS environment.
programs.fish.enable = true;
users.users.prouk = { users.users.prouk = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
shell = pkgs.fish;
}; };
} }