From 9ca280375287f708a0278fefdf9c1825ac06c275 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 5 Jan 2023 01:07:58 +0100 Subject: [PATCH] easyOverlay: Remove performance warning which is not relevant --- extras/easyOverlay.nix | 4 ++-- modules/perSystem.nix | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/extras/easyOverlay.nix b/extras/easyOverlay.nix index fbb1b03..a29c890 100644 --- a/extras/easyOverlay.nix +++ b/extras/easyOverlay.nix @@ -1,4 +1,4 @@ -toplevel@{ config, lib, flake-parts-lib, getSystem, ... }: +toplevel@{ config, lib, flake-parts-lib, getSystemIgnoreWarning, ... }: let inherit (flake-parts-lib) mkPerSystemOption; @@ -50,7 +50,7 @@ in throw "Could not determine the `hostPlatform` of Nixpkgs. Was this overlay loaded as a Nixpkgs overlay, or was it loaded into something else?" ) ); - perSys = (getSystem system).extendModules { + perSys = (getSystemIgnoreWarning system).extendModules { modules = [ { _file = "flake-parts#flakeModules.easyOverlay/overlay-overrides"; diff --git a/modules/perSystem.nix b/modules/perSystem.nix index 075a438..c46e3cf 100644 --- a/modules/perSystem.nix +++ b/modules/perSystem.nix @@ -110,6 +110,12 @@ in allSystems = genAttrs config.systems config.perSystem; # TODO: Sub-optimal error message. Get Nix to support a memoization primop, or get Nix Flakes to support systems properly or get Nix Flakes to add a name to flakes. _module.args.getSystem = system: config.allSystems.${system} or (builtins.trace "using non-memoized system ${system}" config.perSystem system); + + # The warning is there for a reason. Only use this in situations where the + # performance cost has already been incurred, such as in `flakeModules.easyOverlay`, + # where we run in the context of an overlay, and the performance cost of the + # extra `pkgs` makes the cost of running `perSystem` probably negligible. + _module.args.getSystemIgnoreWarning = system: config.allSystems.${system} or config.perSystem system; }; }