From b02c67961f4ee429b264da049f116a74d1984996 Mon Sep 17 00:00:00 2001 From: NullBite Date: Mon, 3 Mar 2025 16:25:16 -0500 Subject: [PATCH] flake: add config specialisation attrset This contains each host's individual specialisations as separate derivations, as well as a modified top-level config containing no specialisations. Evaluating specialisations as separate derivations takes significantly less memory (especially since nix-fast-build doesn't support eval caching) and should stop CI from crashing. --- flake.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/flake.nix b/flake.nix index d71d325..26c1253 100644 --- a/flake.nix +++ b/flake.nix @@ -150,6 +150,7 @@ perSystem = { config, + system, pkgs, self', ... @@ -160,6 +161,46 @@ }; }; + legacyPackages.specialisedNixosConfigurations = let + attrs = lib.pipe self.nixosConfigurations [ + (lib.filterAttrs (n: v: !(builtins.elem n ["iso" "rpi4-x86_64"]))) + (lib.filterAttrs (n: v: v.pkgs.system or "" == system)) + (lib.mapAttrs' (configName: v: let + nospec = + (v.extendModules { + modules = [ + ({lib, ...}: { + # this should NEVER be overridden, hence mkOrder 5 + config.specialisation = lib.mkOrder 5 {}; + }) + ]; + }) + .config; + configs = + ( + lib.mapAttrs' + (n: v: lib.nameValuePair "specialisation-${n}" v.configuration) + v.config.specialisation + ) + // {inherit nospec;}; + in + lib.nameValuePair configName configs)) + ( + lib.concatMapAttrs ( + configName: v: + ( + lib.mapAttrs' ( + specName: v: lib.nameValuePair "${configName}--${specName}" v + ) + ) + v + ) + ) + (lib.mapAttrs (_: v: v.system.build.toplevel)) + ]; + in + attrs; + devShells = { ci = pkgs.mkShell { buildInputs = with pkgs; [