From 5b13a132cc218fc16b059bfb1455814342e30178 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 4 Nov 2024 11:57:01 -0800 Subject: [PATCH] feat: add nh cli --- modules/linux/core/default.nix | 18 +++++++++++++----- users/youwen/linux/home.nix | 27 ++++++++++++++++++++------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/modules/linux/core/default.nix b/modules/linux/core/default.nix index 0c25828..24f93de 100644 --- a/modules/linux/core/default.nix +++ b/modules/linux/core/default.nix @@ -1,6 +1,7 @@ { inputs, pkgs, + config, ... }: { @@ -29,17 +30,24 @@ "flakes" ]; optimise.automatic = true; - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 14d"; - }; + # gc = { + # automatic = true; + # dates = "weekly"; + # options = "--delete-older-than 14d"; + # }; # Free up to 1GiB when there is less than 100MiB left extraOptions = '' min-free = ${toString (100 * 1024 * 1024)} max-free = ${toString (1024 * 1024 * 1024)} ''; }; + + programs.nh = { + enable = true; + clean.enable = true; + clean.extraArgs = "--keep-since 4d --keep 3"; + flake = "/home/youwen/.config/liminalOS"; + }; # Enable CUPS to print documents. services.printing.enable = true; diff --git a/users/youwen/linux/home.nix b/users/youwen/linux/home.nix index 7a4a61e..d4bef35 100755 --- a/users/youwen/linux/home.nix +++ b/users/youwen/linux/home.nix @@ -84,12 +84,25 @@ programs.home-manager.enable = true; programs.fish.functions = { - rebuild = ''doas nixos-rebuild --flake ~/.config/liminalOS\#${osConfig.networking.hostName} switch &| nom''; - os-test = ''doas nixos-rebuild --flake ~/.config/liminalOS\#${osConfig.networking.hostName} test &| nom''; - nixos-update = '' - cd ~/.config/liminalOS - nix flake update --commit-lock-file - doas nixos-rebuild --flake ~/.config/liminalOS\#${osConfig.networking.hostName} switch &| nom - ''; + # rebuild = ''doas nixos-rebuild --flake ~/.config/liminalOS\#${osConfig.networking.hostName} switch &| nom''; + # os-test = ''doas nixos-rebuild --flake ~/.config/liminalOS\#${osConfig.networking.hostName} test &| nom''; + # nixos-update = '' + # cd ~/.config/liminalOS + # nix flake update --commit-lock-file + # doas nixos-rebuild --flake ~/.config/liminalOS\#${osConfig.networking.hostName} switch &| nom + # ''; + nh = { + body = '' + if count $argv > /dev/null + if contains -- os $argv or contains -- clean $argv + doas ${pkgs.nh}/bin/nh $argv -R + else + ${pkgs.nh}/bin/nh $argv + end + else + ${pkgs.nh}/bin/nh + end + ''; + }; }; }