From e2e2c2a7573ae83456529742a42304ad96076896 Mon Sep 17 00:00:00 2001 From: oddlama Date: Mon, 1 May 2023 14:42:36 +0200 Subject: [PATCH] chore: auto optimize biweekly; delete generations older than 90d; use single-definition for stateVersion --- flake.nix | 2 ++ hosts/common/core/nix.nix | 11 +++++++---- hosts/common/dev/default.nix | 5 ++++- hosts/common/dev/nix.nix | 6 ++++++ hosts/common/dev/virt-manager.nix | 18 ------------------ nix/generate-installer.nix | 2 +- nix/generate-node.nix | 2 +- users/common/default.nix | 2 +- 8 files changed, 22 insertions(+), 26 deletions(-) create mode 100644 hosts/common/dev/nix.nix delete mode 100644 hosts/common/dev/virt-manager.nix diff --git a/flake.nix b/flake.nix index 189d14d..8cf7358 100644 --- a/flake.nix +++ b/flake.nix @@ -86,6 +86,8 @@ content = import ./nix/secrets.nix inputs; }; + stateVersion = "23.05"; + hosts = { nom = { type = "nixos"; diff --git a/hosts/common/core/nix.nix b/hosts/common/core/nix.nix index 1b097a4..f21905e 100644 --- a/hosts/common/core/nix.nix +++ b/hosts/common/core/nix.nix @@ -1,6 +1,7 @@ { inputs, pkgs, + stateVersion, ... }: { environment.etc."nixos/configuration.nix".source = pkgs.writeText "configuration.nix" '' @@ -32,12 +33,14 @@ builders-use-substitutes = true experimental-features = nix-command flakes recursive-nix flake-registry = /etc/nix/registry.json - plugin-files = ${pkgs.nix-plugins}/lib/nix/plugins - extra-builtins-file = ${../../../nix/extra-builtins.nix} ''; nixPath = ["nixpkgs=/run/current-system/nixpkgs"]; optimise.automatic = true; - gc.automatic = true; + gc = { + automatic = true; + dates = "biweekly"; + options = "--delete-older-than 90d"; + }; # Define global flakes for this system registry = { nixpkgs.flake = inputs.nixpkgs; @@ -51,6 +54,6 @@ extraSystemBuilderCmds = '' ln -sv ${pkgs.path} $out/nixpkgs ''; - stateVersion = "23.05"; + inherit stateVersion; }; } diff --git a/hosts/common/dev/default.nix b/hosts/common/dev/default.nix index 232ddf4..292096a 100644 --- a/hosts/common/dev/default.nix +++ b/hosts/common/dev/default.nix @@ -1,5 +1,8 @@ { - imports = [./documentation.nix]; + imports = [ + ./documentation.nix + ./nix.nix + ]; environment.enableDebugInfo = true; } diff --git a/hosts/common/dev/nix.nix b/hosts/common/dev/nix.nix new file mode 100644 index 0000000..4798628 --- /dev/null +++ b/hosts/common/dev/nix.nix @@ -0,0 +1,6 @@ +{pkgs, ...}: { + nix.extraOptions = '' + plugin-files = ${pkgs.nix-plugins}/lib/nix/plugins + extra-builtins-file = ${../../../nix/extra-builtins.nix} + ''; +} diff --git a/hosts/common/dev/virt-manager.nix b/hosts/common/dev/virt-manager.nix deleted file mode 100644 index cc25471..0000000 --- a/hosts/common/dev/virt-manager.nix +++ /dev/null @@ -1,18 +0,0 @@ -{pkgs, ...}: { - environment.systemPackages = with pkgs; [virt-manager spice-gtk swtpm]; - security.polkit.enable = true; - virtualisation = { - libvirtd = { - enable = true; - qemu = { - package = pkgs.qemu_kvm; - ovmf = { - enable = true; - packages = with pkgs; [OVMFFull.fd]; - }; - swtpm.enable = true; - }; - }; - spiceUSBRedirection.enable = true; - }; -} diff --git a/nix/generate-installer.nix b/nix/generate-installer.nix index 18a66bb..8fe3ef0 100644 --- a/nix/generate-installer.nix +++ b/nix/generate-installer.nix @@ -26,7 +26,7 @@ ''; in { isoImage.isoName = lib.mkForce "nixos-image-${nodeName}.iso"; - system.stateVersion = "23.05"; + system.stateVersion = self.stateVersion; nix.extraOptions = '' experimental-features = nix-command flakes recursive-nix ''; diff --git a/nix/generate-node.nix b/nix/generate-node.nix index 271c660..7b4e763 100644 --- a/nix/generate-node.nix +++ b/nix/generate-node.nix @@ -19,7 +19,7 @@ in pkgs = self.pkgs.${nodeMeta.system}; specialArgs = { inherit (nixpkgs) lib; - inherit (self) extraLib nodes; + inherit (self) extraLib nodes stateVersion; inherit inputs; inherit nodeName; secrets = self.secrets.content; diff --git a/users/common/default.nix b/users/common/default.nix index 66fa51a..0874f08 100644 --- a/users/common/default.nix +++ b/users/common/default.nix @@ -16,7 +16,7 @@ ]; home = { - stateVersion = "23.05"; + inherit stateVersion; packages = with pkgs; [ bandwhich btop