Replace update script with nh
This commit is contained in:
parent
99a2022185
commit
429017f601
18
flake.lock
18
flake.lock
|
@ -117,11 +117,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1713391096,
|
||||
"narHash": "sha256-5xkzsy+ILgQlmvDDipL5xqAehnjWBenAQXV4/NLg2dE=",
|
||||
"lastModified": 1713566308,
|
||||
"narHash": "sha256-7Y91t8pheIzjJveUMAPyeh5NOq5F49Nq4Hl2532QpJs=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "f46814ec7cbef9c2aef18ca1cbe89f2bb1e8c394",
|
||||
"rev": "057117a401a34259c9615ce62218aea7afdee4d3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -174,11 +174,11 @@
|
|||
},
|
||||
"nixos-hardware": {
|
||||
"locked": {
|
||||
"lastModified": 1713441075,
|
||||
"narHash": "sha256-3GGeFsEO8ivD+TcDEqe4s/d0VLvMYGNDGtx0ZnBxkUs=",
|
||||
"lastModified": 1713521961,
|
||||
"narHash": "sha256-EwR8wW9AqJhSIY+0oxWRybUZ32BVKuZ9bjlRh8SJvQ8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixos-hardware",
|
||||
"rev": "6f976e53752e5b9ab08f9a3b1b0b9c67815c9754",
|
||||
"rev": "5d48925b815fd202781bfae8fb6f45c07112fdb2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -222,11 +222,11 @@
|
|||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1713248628,
|
||||
"narHash": "sha256-NLznXB5AOnniUtZsyy/aPWOk8ussTuePp2acb9U+ISA=",
|
||||
"lastModified": 1713537308,
|
||||
"narHash": "sha256-XtTSSIB2DA6tOv+l0FhvfDMiyCmhoRbNB+0SeInZkbk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5672bc9dbf9d88246ddab5ac454e82318d094bb8",
|
||||
"rev": "5c24cf2f0a12ad855f444c30b2421d044120c66f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -7,17 +7,9 @@ let
|
|||
ref = "main";
|
||||
rev = "55fc814d477d956ab885e157f24c2d43f433dc7a";
|
||||
};
|
||||
|
||||
# Install upgrade script
|
||||
nixos-upgrade = pkgs.writeShellScriptBin "nixos-upgrade" (builtins.readFile ./nixos-upgrade.sh);
|
||||
in{
|
||||
imports = [
|
||||
../../modules
|
||||
"${nix-secrets}/default.nix"
|
||||
];
|
||||
|
||||
# Add upgrade script
|
||||
environment.systemPackages = [
|
||||
nixos-upgrade
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# Update NixOS system while printing out the different packages to install.
|
||||
# Inspiration: https://blog.tjll.net/previewing-nixos-system-updates/
|
||||
set -e
|
||||
OPERATION="boot" # Which update method to use. Defaults to "boot", which applies updates on reboot.
|
||||
AUTOACCEPT=false # Whether to automatically apply the update or ask for permission.
|
||||
|
||||
function usage() {
|
||||
echo "Usage: nixos-upgrade.sh [ -y | --auto-accept ] [-o | --operation]"
|
||||
echo "Options:"
|
||||
echo " -h | --help Show this help screen."
|
||||
echo " -y | --auto-accept Automatically approve pending changes."
|
||||
echo " -o | --operation Which update operation to perform (switch, boot, etc.). Defaults to boot."
|
||||
exit 2
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-y|-Y|--auto-accept)
|
||||
AUTOACCEPT=true
|
||||
shift
|
||||
;;
|
||||
-o|-O|--operation)
|
||||
OPERATION=$2
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
#echo "Unknown argument $1"
|
||||
#exit 1
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "Using installation mode: $OPERATION"
|
||||
|
||||
cd ~/Development/nix-configuration
|
||||
nix flake update
|
||||
nixos-rebuild build --flake .
|
||||
PACKAGE_UPDATES=$(nix store diff-closures /run/current-system ./result | awk '/[0-9] →|→ [0-9]/ && !/nixos/' || echo)
|
||||
|
||||
if [ "$PACKAGE_UPDATES" ]; then
|
||||
echo "Packages to update: "
|
||||
echo $PACKAGE_UPDATES
|
||||
fi
|
||||
|
||||
if [ $AUTOACCEPT == false ]; then
|
||||
read -p "Continue with upgrade (y/n) ? " choice
|
||||
case "$choice" in
|
||||
y|Y|yes ) echo "Running nixos-rebuild $OPERATION :";;
|
||||
n|N|no ) echo "Upgrade cancelled." && exit;;
|
||||
* ) echo "Invalid option. Upgrade cancelled." && exit;;
|
||||
esac
|
||||
fi
|
||||
|
||||
sudo nixos-rebuild $OPERATION --flake .
|
||||
|
||||
echo "Updating Flatpaks:"
|
||||
flatpak update
|
|
@ -18,10 +18,12 @@ with lib;
|
|||
nano
|
||||
p7zip
|
||||
fastfetch
|
||||
nh # Nix Helper: https://github.com/viperML/nh
|
||||
];
|
||||
|
||||
# Set default editor to nano
|
||||
variables.EDITOR = "nano";
|
||||
variables = {
|
||||
EDITOR = "nano"; # Set default editor to nano
|
||||
};
|
||||
|
||||
# System configuration file overrides
|
||||
etc = {
|
||||
|
@ -78,13 +80,6 @@ with lib;
|
|||
# Enable periodic nix store optimization
|
||||
optimise.automatic = true;
|
||||
|
||||
# Enable garbage collection
|
||||
gc = {
|
||||
automatic = true;
|
||||
dates = "daily";
|
||||
options = "--delete-older-than 7d";
|
||||
};
|
||||
|
||||
# Configure NixOS to use the same software channel as Flakes
|
||||
registry = lib.mapAttrs (_: value: { flake = value; }) inputs;
|
||||
nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry;
|
||||
|
@ -103,6 +98,18 @@ with lib;
|
|||
set softwrap
|
||||
'';
|
||||
};
|
||||
|
||||
nh = {
|
||||
enable = true;
|
||||
flake = "/home/aires/Development/nix-configuration";
|
||||
|
||||
# Alternative garbage collection system to nix.gc.automatic
|
||||
clean = {
|
||||
enable = true;
|
||||
dates = "daily";
|
||||
extraArgs = "--keep-since 7d --keep 10"; # Keep the last 10 entries
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
|
|
|
@ -86,9 +86,8 @@ with lib;
|
|||
theme = "gentoo";
|
||||
};
|
||||
shellAliases = {
|
||||
dry-build = "cd ~/Development/nix-configuration && nix flake update && nixos-rebuild dry-build --flake .";
|
||||
update = "upgrade";
|
||||
upgrade = "cd ~/Development/nix-configuration && nixos-upgrade";
|
||||
upgrade = "nh os boot --update --ask";
|
||||
protontricks = "flatpak run com.github.Matoking.protontricks";
|
||||
please = "sudo";
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue