feat: add nix-update+nvd script
This commit is contained in:
parent
307ae1bac9
commit
d3150b5a5a
7 changed files with 56 additions and 11 deletions
12
flake.lock
generated
12
flake.lock
generated
|
|
@ -7,11 +7,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1705408632,
|
"lastModified": 1705875991,
|
||||||
"narHash": "sha256-/AhkReVocTli5BLWA5WXxUlGYXn3Agi/uzX76TNrsbo=",
|
"narHash": "sha256-ssoo8WYXy4H0qQ81GhzOaMnvDmeXV02D4DdGOYRKCnU=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "37d6eeceee464adc03585404eebd68765b3c8615",
|
"rev": "0021558dba313b6f494cd16362dcd4071f407535",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -38,11 +38,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1705133751,
|
"lastModified": 1705677747,
|
||||||
"narHash": "sha256-rCIsyE80jgiOU78gCWN3A0wE0tR2GI5nH6MlS+HaaSQ=",
|
"narHash": "sha256-eyM3okYtMgYDgmYukoUzrmuoY4xl4FUujnsv/P6I/zI=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "9b19f5e77dd906cb52dade0b7bd280339d2a1f3d",
|
"rev": "bbe7d8f876fbbe7c959c90ba2ae2852220573261",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
nec = "nvim --cmd \"cd $(readlink -f /etc/nixos)\"";
|
nec = "nvim --cmd \"cd $(readlink -f /etc/nixos)\"";
|
||||||
ncc = "sudo nixos-rebuild switch --upgrade-all --flake \"$(readlink -f /etc/nixos)\"";
|
ncc = "sudo nixos-rebuild switch --upgrade-all --flake \"$(readlink -f /etc/nixos)\"";
|
||||||
nup = "sudo nix-channel --update";
|
nup = "sudo nix-channel --update";
|
||||||
nuf = "sudo nix flake update --nix-path /etc/nixos";
|
|
||||||
ngc = "sudo nix-collect-garbage -d";
|
ngc = "sudo nix-collect-garbage -d";
|
||||||
|
|
||||||
dcup = "docker-compose up --detach --remove-orphans";
|
dcup = "docker-compose up --detach --remove-orphans";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
{ ... }: {
|
{ pkgs, ... }: {
|
||||||
nix.settings = {
|
nix = {
|
||||||
experimental-features = [ "nix-command" "flakes" ];
|
# TODO remove once 24.05 is released
|
||||||
auto-optimise-store = true;
|
package = pkgs.nixVersions.unstable;
|
||||||
|
settings = {
|
||||||
|
experimental-features = [ "nix-command" "flakes" ];
|
||||||
|
auto-optimise-store = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
unzip
|
unzip
|
||||||
libsecret
|
libsecret
|
||||||
xidel # xml parser
|
xidel # xml parser
|
||||||
|
nvd # nix diff package versions between two store paths
|
||||||
] ++ lib.optionals (devenv.enable) [
|
] ++ lib.optionals (devenv.enable) [
|
||||||
# languages
|
# languages
|
||||||
gcc13
|
gcc13
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
./keyd.nix
|
./keyd.nix
|
||||||
./neovim
|
./neovim
|
||||||
./packages.nix
|
./packages.nix
|
||||||
|
./scripts
|
||||||
./ssh.nix
|
./ssh.nix
|
||||||
./tmux.nix
|
./tmux.nix
|
||||||
./xdg.nix
|
./xdg.nix
|
||||||
|
|
|
||||||
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