Skip to content

Commit

Permalink
Add an auto upgrade module for flake-based sysems
Browse files Browse the repository at this point in the history
  • Loading branch information
arunoruto committed Oct 20, 2024
1 parent 38953b5 commit c0050fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
20 changes: 2 additions & 18 deletions modules/nixos/system/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@
./security.nix
# ./systemd.nix
./theming.nix
./upgrade.nix
];

nix-utils.enable = lib.mkDefault true;
secureboot.enable = lib.mkDefault false;
# theming = {
# # enable = lib.mkDefault true;
# inherit image;
# inherit scheme;
# };
upgrades.enable = lib.mkDefault false;

# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
Expand All @@ -31,19 +28,6 @@
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.11"; # Did you read the comment?

# Auto updates
# system.autoUpgrade = {
# enable = true;
# channel = "https://nixos.org/channels/nixos-${config.system.stateVersion}";
# };

# environment.systemPackages = with pkgs; [
# unstable.nh
# nix-tree
# nix-output-monitor
# nvd
# ];
#
# # Auto clean system
# nix = {
# settings = {
Expand Down
22 changes: 22 additions & 0 deletions modules/nixos/system/upgrade.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
config,
lib,
inputs,
...
}: {
options.upgrades.enable = lib.mkEnableOption "Automated upgrades of the flake-based system";

config = lib.mkIf config.upgrades.enable {
system.autoUpgrade = {
enable = true;
dates = "04:00";
randomizedDelaySec = "15min";
flake = inputs.self.outPath;
flags = [
"--update-input"
"nixpkgs"
"-L"
];
};
};
}

0 comments on commit c0050fa

Please sign in to comment.