profiles/system: add auto-upgrade option

This commit is contained in:
Gabriel Arazas 2022-04-17 00:17:19 +08:00
parent 99050bc806
commit 9f6cef56f8
3 changed files with 21 additions and 4 deletions

View File

@ -98,6 +98,7 @@
specialArgs = { specialArgs = {
inherit system inputs self; inherit system inputs self;
lib = nixpkgs.lib.extend (final: prev: import ./lib { lib = prev; }); lib = nixpkgs.lib.extend (final: prev: import ./lib { lib = prev; });
selfPath = ./.;
}; };
config = { config = {
@ -164,9 +165,8 @@
in { in {
inherit system; inherit system;
specialArgs = { extraSpecialArgs = {
inherit system self; inherit system self;
lib = nixpkgs.lib.extend (final: prev: import ./lib { lib = prev; });
}; };
extraModules = [{ extraModules = [{

View File

@ -18,6 +18,7 @@
fonts.enable = true; fonts.enable = true;
hardware.enable = true; hardware.enable = true;
cleanup.enable = true; cleanup.enable = true;
autoUpgrade.enable = true;
wine.enable = true; wine.enable = true;
}; };
dev = { dev = {

View File

@ -1,7 +1,7 @@
# This is where extra desktop goodies can be found. # This is where extra desktop goodies can be found.
# As a note, this is not where you set the aesthetics of your graphical sessions. # As a note, this is not where you set the aesthetics of your graphical sessions.
# That can be found in the `themes` module. # That can be found in the `themes` module.
{ inputs, config, options, lib, pkgs, ... }: { inputs, config, options, lib, pkgs, selfPath, ... }:
let cfg = config.profiles.system; let cfg = config.profiles.system;
in { in {
@ -14,6 +14,7 @@ in {
hardware.enable = hardware.enable =
lib.mkEnableOption "the common hardware-related configuration"; lib.mkEnableOption "the common hardware-related configuration";
cleanup.enable = lib.mkEnableOption "activation of cleanup services"; cleanup.enable = lib.mkEnableOption "activation of cleanup services";
autoUpgrade.enable = lib.mkEnableOption "auto-upgrade service with this system";
wine = { wine = {
enable = lib.mkEnableOption "Wine and Wine-related tools"; enable = lib.mkEnableOption "Wine and Wine-related tools";
package = lib.mkOption { package = lib.mkOption {
@ -36,7 +37,7 @@ in {
}; };
# Enable font-related options for more smoother and consistent experience. # Enable font-related options for more smoother and consistent experience.
fonts.enableDefaultFonts = true; fonts.fontconfig.enable = true;
# Run unpatched binaries with these! # Run unpatched binaries with these!
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
@ -147,6 +148,21 @@ in {
}; };
}) })
(lib.mkIf cfg.autoUpgrade.enable {
system.autoUpgrade = {
enable = true;
flake = builtins.toString selfPath;
allowReboot = true;
rebootWindow = {
lower = "22:00";
upper = "00:00";
};
dates = "weekly";
flags = [ "--update-input" "nixpkgs" "--commit-lock-file" ];
randomizedDelaySec = "30min";
};
})
# I try to avoid using Wine on NixOS because most of them uses FHS or something and I just want it to work but here goes. # I try to avoid using Wine on NixOS because most of them uses FHS or something and I just want it to work but here goes.
(lib.mkIf cfg.wine.enable { (lib.mkIf cfg.wine.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [