From 1ad01c35dad7e105fe76c675f66fad34607b77cb Mon Sep 17 00:00:00 2001 From: ulve Date: Sat, 4 Jul 2026 14:15:22 +0200 Subject: [PATCH] NH and herdr --- flake.lock | 37 ++++++++++++++++++++++++++++++++++++- flake.nix | 7 +++++-- home.nix | 14 ++++++++++---- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index 1ab584b..d601972 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "herdr": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1783165492, + "narHash": "sha256-xhaMqgcdK1xVBKg55r30xu80BlgLuQLUw//OKfG/swY=", + "owner": "ogulcancelik", + "repo": "herdr", + "rev": "c97e0986277e95144f79da3fce5b3fd443f3922f", + "type": "github" + }, + "original": { + "owner": "ogulcancelik", + "repo": "herdr", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -22,6 +40,22 @@ } }, "nixpkgs": { + "locked": { + "lastModified": 1779357205, + "narHash": "sha256-cCO8aTqss5x9Ky8GWkpY0Hy5fyTZEbtifSUV8QjSzic=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f83fc3c307e74bc5fd5adb7eb6b8b13ffd2a36e1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1782999065, "narHash": "sha256-68sbHaR2H5mXnLSjtAii1YESzudwgaiVIK5N1kC/As8=", @@ -37,8 +71,9 @@ }, "root": { "inputs": { + "herdr": "herdr", "home-manager": "home-manager", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs_2" } } }, diff --git a/flake.nix b/flake.nix index b71aded..5077ddf 100644 --- a/flake.nix +++ b/flake.nix @@ -7,9 +7,11 @@ url = "github:nix-community/home-manager/release-26.05"; inputs.nixpkgs.follows = "nixpkgs"; }; + + herdr.url = "github:ogulcancelik/herdr"; }; - - outputs = {self, home-manager, nixpkgs, ...}: { + + outputs = {self, home-manager, nixpkgs, herdr, ...}: { nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ @@ -21,6 +23,7 @@ useUserPackages = true; users.ulve = import ./home.nix; backupFileExtension = "backup"; + extraSpecialArgs = { inherit herdr; }; }; } ]; diff --git a/home.nix b/home.nix index 1b48435..69df2c8 100644 --- a/home.nix +++ b/home.nix @@ -1,4 +1,4 @@ -{config, pkgs, ...}: +{config, pkgs, herdr, ...}: { imports = [ ./niri.nix ]; @@ -15,7 +15,7 @@ shellAliases = { n = "nvim"; rebuild = "sudo nixos-rebuild switch --flake ~/nixos-dotfiles"; - upgrade = "nix flake update --flake ~/nixos-dotfiles && sudo nixos-rebuild switch --flake ~/nixos-dotfiles"; + upgrade = "nix flake update --flake ~/nixos-dotfiles && { command -v nh > /dev/null 2>&1 && nh os switch ~/nixos-dotfiles || sudo nixos-rebuild switch --flake ~/nixos-dotfiles; }"; }; }; @@ -31,7 +31,7 @@ shellAliases = { n = "nvim"; rebuild = "sudo nixos-rebuild switch --flake ~/nixos-dotfiles"; - upgrade = "nix flake update --flake ~/nixos-dotfiles && sudo nixos-rebuild switch --flake ~/nixos-dotfiles"; + upgrade = "nix flake update --flake ~/nixos-dotfiles && { command -v nh &>/dev/null && nh os switch ~/nixos-dotfiles || sudo nixos-rebuild switch --flake ~/nixos-dotfiles; }"; tree = "eza --tree --level=2"; ls = "eza --icons --all --header --long --git"; }; @@ -54,7 +54,11 @@ bindkey "^[OB" down-line-or-beginning-search function gc() { - sudo nix-collect-garbage --delete-older-than "''${1:-14}d" + if command -v nh &>/dev/null; then + nh clean all --keep-since "''${1:-14}d" + else + sudo nix-collect-garbage --delete-older-than "''${1:-14}d" + fi } function mkenv() { @@ -261,6 +265,7 @@ # ── Packages ───────────────────────────────────────────────────────────────── home.packages = with pkgs; [ # general + herdr.packages.${pkgs.system}.default # wallpaper manager claude-code # ai coding assistant azure-cli # az cli git-credential-manager # git credential helper (azure devops PAT) @@ -270,6 +275,7 @@ jq # json processor powershell # yes teams-for-linux # teams + nh # nix helper unzip # compression # terminal