From ffdb88a79c57a8a527378e6dc6919425a0318520 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sun, 16 Aug 2026 09:11:46 -0400 Subject: [PATCH] perf(nix): share package sets across evaluations --- flake.nix | 29 ++++++++++++++++++++++++++--- nix/modules/nixos/nixpkgs.nix | 9 +++------ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/flake.nix b/flake.nix index 7a03dbc3..60618d2b 100644 --- a/flake.nix +++ b/flake.nix @@ -64,9 +64,32 @@ ]; }; - outputs = inputs @ {flake-parts, ...}: - flake-parts.lib.mkFlake {inherit inputs;} { - systems = ["aarch64-darwin" "x86_64-linux"]; + outputs = inputs @ { + flake-parts, + nixpkgs, + ... + }: let + sharedPackageSets = { + aarch64-darwin = import nixpkgs { + system = "aarch64-darwin"; + }; + + x86_64-linux = import nixpkgs { + system = "x86_64-linux"; + config.allowUnfree = true; + overlays = [inputs.self.overlays.default]; + }; + }; + in + flake-parts.lib.mkFlake { + inherit inputs; + specialArgs = {inherit sharedPackageSets;}; + } { + systems = builtins.attrNames sharedPackageSets; + + perSystem = {system, ...}: { + _module.args.pkgs = sharedPackageSets.${system}; + }; imports = [ (inputs.import-tree ./nix/modules) diff --git a/nix/modules/nixos/nixpkgs.nix b/nix/modules/nixos/nixpkgs.nix index 484fe4d5..682336c6 100644 --- a/nix/modules/nixos/nixpkgs.nix +++ b/nix/modules/nixos/nixpkgs.nix @@ -1,8 +1,5 @@ -_: { - flake.nixosModules.default = {self, ...}: { - nixpkgs = { - config.allowUnfree = true; - overlays = [self.overlays.default]; - }; +{sharedPackageSets, ...}: { + flake.nixosModules.default = { + nixpkgs.pkgs = sharedPackageSets.x86_64-linux; }; } -- 2.51.2