Serenity/home/scripts/nix-utils.nix
2024-12-27 01:31:27 +10:00

36 lines
857 B
Nix
Executable file

{ pkgs, config, flakePath, ... }:
let
hostname = config.system.nixos.distroId;
nixsyu = pkgs.writeShellScriptBin "nixsyu" ''
cd ${flakePath} && sudo nix flake update && sudo nixos-rebuild switch --upgrade-all --flake .#${hostname} --show-trace && sudo nix-collect-garbage -d && sudo nix-store --optimise
'';
nixrb = pkgs.writeShellScriptBin "nixrb" ''
cd ${flakePath} && sudo nixos-rebuild switch --flake .#${hostname} --show-trace
'';
nixcb = pkgs.writeShellScriptBin "nixcb" ''
sudo /run/current-system/bin/switch-to-configuration boot
'';
nixgc = pkgs.writeShellScriptBin "nixgc" ''
cd ${flakePath} && sudo nix-collect-garbage -d
'';
nixu = pkgs.writeShellScriptBin "nixu" ''
cd ${flakePath} && sudo nix flake update
'';
in {
home.packages = [
nixsyu
nixrb
nixcb
nixgc
nixu
];
}