feat: use nh (yet another nix helper)

This commit is contained in:
2025-06-27 23:22:16 +08:00
parent 8fe373eeb5
commit 705f702535
2 changed files with 16 additions and 6 deletions

View File

@@ -2,15 +2,19 @@ all: fmt switch
switch: switch:
@echo "Rebuilding NixOS..." @echo "Rebuilding NixOS..."
@nixos-rebuild switch --flake . --sudo --json |& nom @nh os switch .
boot: boot:
@echo "Rebuilding NixOS..." @echo "Rebuilding NixOS..."
@nixos-rebuild boot --flake . --sudo --json |& nom @nh os boot .
test:
@echo "Rebuilding NixOS..."
@nh os test .
vm: vm:
@echo "Building NixOS VM..." @echo "Building NixOS VM..."
@nixos-rebuild build-vm --flake . --json |& nom @nh os build-vm .
update: update:
@echo "Updating flakes..." @echo "Updating flakes..."
@@ -23,17 +27,17 @@ replpkgs:
@nix repl -f flake:nixpkgs @nix repl -f flake:nixpkgs
repl: repl:
@nixos-rebuild repl --flake . @nh os repl .
cleandry: cleandry:
@echo "Listing all generations older than 15 days..." @echo "Listing all generations older than 15 days..."
@sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --dry-run --older-than 15d @sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --dry-run --older-than 15d
@nix run home-manager#home-manager -- expire-generations -15days --dry-run @nix profile wipe-history --profile ~/.local/state/nix/profiles/home-manager --dry-run --older-than 15d
clean: clean:
@echo "Removing all generations older than 15 days..." @echo "Removing all generations older than 15 days..."
@sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 15d @sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 15d
@nix run home-manager#home-manager -- expire-generations -15days @nix profile wipe-history --profile ~/.local/state/nix/profiles/home-manager --older-than 15d
gc: gc:
@nix store gc --debug @nix store gc --debug

View File

@@ -2,6 +2,7 @@
inputs, inputs,
config, config,
lib, lib,
pkgs,
... ...
}: }:
lib.my.makeSwitch { lib.my.makeSwitch {
@@ -20,6 +21,11 @@ lib.my.makeSwitch {
# Making legacy nix commands consistent as well, awesome! # Making legacy nix commands consistent as well, awesome!
nix.nixPath = [ "/etc/nix/path" ]; nix.nixPath = [ "/etc/nix/path" ];
environment.systemPackages = with pkgs; [
nix-output-monitor
nh
];
environment.etc = lib.mapAttrs' (name: value: { environment.etc = lib.mapAttrs' (name: value: {
name = "nix/path/${name}"; name = "nix/path/${name}";
value.source = value.flake; value.source = value.flake;