feat: add nix-update+nvd script
This commit is contained in:
parent
307ae1bac9
commit
d3150b5a5a
7 changed files with 56 additions and 11 deletions
5
users/gandalf/modules/scripts/default.nix
Normal file
5
users/gandalf/modules/scripts/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{ pkgs, nixosConfig, ... }: {
|
||||
home.packages = [
|
||||
(import ./nix-update.nix { inherit pkgs nixosConfig; })
|
||||
];
|
||||
}
|
||||
35
users/gandalf/modules/scripts/nix-update.nix
Normal file
35
users/gandalf/modules/scripts/nix-update.nix
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{ pkgs, nixosConfig }:
|
||||
|
||||
pkgs.writeShellScriptBin "nuf" ''
|
||||
reset="\e[0m"
|
||||
red="\e[31m"
|
||||
green="\e[32m"
|
||||
yellow="\e[33m"
|
||||
white_bold="\e[1;37m"
|
||||
|
||||
function error {
|
||||
echo ""
|
||||
echo -e "''${red}>>>Error: $1''${reset}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
FLAKE=$(readlink -f /etc/nixos)
|
||||
|
||||
echo -e "''${green}>>> Updating flake $FLAKE ...''${reset}"
|
||||
${nixosConfig.nix.package}/bin/nix flake update --flake "$FLAKE" || error "Updating failed"
|
||||
|
||||
cd $(mktemp -d)
|
||||
echo ""
|
||||
echo -e "''${green}>>> Building configuration ...''${reset}"
|
||||
nixos-rebuild build --flake "$FLAKE" || error "Building failed"
|
||||
|
||||
echo ""
|
||||
echo -e "''${green}>>> Running diff ...''${reset}";
|
||||
${pkgs.nvd}/bin/nvd diff /run/current-system result || error "Diff failed"
|
||||
|
||||
cd - > /dev/null
|
||||
|
||||
echo ""
|
||||
echo -e "''${yellow}>>> The new configuration has not been activated.''${reset}"
|
||||
echo -e "''${yellow}>>> Use ''${white_bold}nixos-rebuild switch''${reset}''${yellow} to activate.''${reset}"
|
||||
''
|
||||
Loading…
Add table
Add a link
Reference in a new issue