added some utilities and going to nh
This commit is contained in:
1 parent
3fb55bb091
commit
8ac7fd4862
8 files changed
+90
-54
No files matched your search
Generated
+13
-13
@@ -7,11 +7,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1790955005,
|
||||
"narHash": "sha256-EEQKUylD8zuRTmDFX4rbwsHQ+iZhqqOldYcFN8SLcE0=",
|
||||
"lastModified": 1791306979,
|
||||
"narHash": "sha256-KuLePuhwJM9NLt/gTLHzXaOoSZKGoB3m7NfXjiQ98HY=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "0560d64401a6d5370732a69d08bc4a6b135962d9",
|
||||
"rev": "fae6e9e42c3b762ab47635cddcfaf6f52374a61b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -22,11 +22,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1790822859,
|
||||
"narHash": "sha256-VBA0QerzzmL+4wxgtwiCdiLwLpJg2/9xOxhgO3BRJQA=",
|
||||
"rev": "c59305bab2065cfecc4944690d9eedbb56f3a9fa",
|
||||
"lastModified": 1791260994,
|
||||
"narHash": "sha256-MFBjw66d4h06MvpW6lIl7RwarLteD0sk859CncGwb1Q=",
|
||||
"rev": "151fa4e8ddfdd8dd25d945ad94ed54a13de9f6e4",
|
||||
"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": {
|
||||
"id": "nixpkgs",
|
||||
@@ -71,11 +71,11 @@
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1790770493,
|
||||
"narHash": "sha256-sNWVkfOVelr60lWHvEgCWx7Mr/2PcoAN8oOrOk7Yp/g=",
|
||||
"lastModified": 1791203262,
|
||||
"narHash": "sha256-+RlIyHipr7BOLsIC9jnpzbkLBsY6XbLhuPinAwJsYjo=",
|
||||
"owner": "Supreeeme",
|
||||
"repo": "xwayland-satellite",
|
||||
"rev": "b5690b56d749526a05db9b9268d58bf8f700957f",
|
||||
"rev": "ae88928f7334556d298b8d9552abdf395931931b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -94,11 +94,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1790940304,
|
||||
"narHash": "sha256-i1W4IdG9PVdSRN1rvTHaqiVqvnRS3+OXgaQa7z5iRDc=",
|
||||
"lastModified": 1791266850,
|
||||
"narHash": "sha256-F/scdmE9Y03TfSQWrBHaJWTRTr3rRQBqvJSDgF48g1c=",
|
||||
"owner": "0xc000022070",
|
||||
"repo": "zen-browser-flake",
|
||||
"rev": "b12abb753335dd3b9ba5ea90d3be799bd9b2dc29",
|
||||
"rev": "d9e4e25d6ade5d541074045d332d887c044e11f5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
just
|
||||
nil
|
||||
nixd
|
||||
scrcpy
|
||||
];
|
||||
|
||||
programs.zed-editor = {
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
btop
|
||||
gparted
|
||||
yazi
|
||||
unzip
|
||||
];
|
||||
}
|
||||
@@ -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 = {
|
||||
enable = true;
|
||||
bashrcExtra = "eval \"$(devenv hook bash)\"\n";
|
||||
|
||||
@@ -1,63 +1,75 @@
|
||||
# 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.
|
||||
help:
|
||||
@echo "NixOS Profile Cleanup Utility"
|
||||
@echo "============================="
|
||||
@echo "nh: {{ if nh != "" { "found (" + nh + ")" } else { "not found, using plain nix commands" } }}"
|
||||
@echo "Available recipes:"
|
||||
@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-user - Clean current user's profile generations"
|
||||
@echo " just clean-home-manager - Clean Home Manager generations (if applicable)"
|
||||
@echo " just clean-all - Clean everything (System, User, and Home Manager)"
|
||||
@echo " just clean-all - Clean System, User and Home Manager generations (requires sudo)"
|
||||
@echo " just build - Rebuild and switch the system"
|
||||
@echo " just update - Update flake inputs"
|
||||
|
||||
# Dry run to preview changes without deleting anything.
|
||||
dry-run:
|
||||
@echo "=== [DRY RUN] System Profile ==="
|
||||
sudo nix-env --profile /nix/var/nix/profiles/system --delete-generations +3 --dry-run
|
||||
@echo "\n=== [DRY RUN] User Profile ==="
|
||||
nix-env --delete-generations +3 --dry-run
|
||||
@echo "\n=== [DRY RUN] 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 --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."; \
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if [ -n "{{ nh }}" ]; then
|
||||
echo "=== [DRY RUN] All profiles (nh) ==="
|
||||
nh clean all --keep {{ keep }} --dry
|
||||
exit 0
|
||||
fi
|
||||
echo "=== [DRY RUN] System Profile ==="
|
||||
sudo nix-env --profile /nix/var/nix/profiles/system --delete-generations +{{ keep }} --dry-run
|
||||
echo -e "\n=== [DRY RUN] User Profile ==="
|
||||
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
|
||||
|
||||
# Clean system generations (requires sudo).
|
||||
clean-system:
|
||||
@echo "--- Cleaning System Profile (SUDO) ---"
|
||||
sudo nix-env --profile /nix/var/nix/profiles/system --delete-generations +3
|
||||
# Clean system, user and Home Manager generations, then update the bootloader (requires sudo).
|
||||
clean-all:
|
||||
#!/usr/bin/env bash
|
||||
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
|
||||
@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
|
||||
|
||||
# Clean Home Manager generations (no sudo).
|
||||
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."; \
|
||||
echo "--- Updating Bootloader Menu ---"
|
||||
sudo nixos-rebuild boot --flake .#{{ host }}
|
||||
fi
|
||||
|
||||
# Clean everything in one go.
|
||||
clean-all: clean-system clean-user clean-home-manager
|
||||
@echo "All cleanups successfully completed!"
|
||||
echo "All cleanups successfully completed!"
|
||||
|
||||
# Build.
|
||||
build:
|
||||
@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:
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
# Programs
|
||||
./programs/gaming.nix
|
||||
./programs/obs.nix
|
||||
./programs/nh.nix
|
||||
];
|
||||
|
||||
# NO TOUCHY
|
||||
|
||||
@@ -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";
|
||||
};
|
||||
}
|
||||
@@ -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 = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" ];
|
||||
shell = pkgs.fish;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user