From 85c8292f9a55ea743e137df23b5782ee074a149a Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 17 May 2023 23:17:24 +0000 Subject: [PATCH] pkgs/default.nix: simplify (no need for the scope) --- overlays/pkgs.nix | 3 +-- pkgs/default.nix | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/overlays/pkgs.nix b/overlays/pkgs.nix index 124f14bd..cffa3a70 100644 --- a/overlays/pkgs.nix +++ b/overlays/pkgs.nix @@ -3,6 +3,5 @@ # - `additional` packages # - `patched` versions of nixpkgs (which necessarily shadow their nixpkgs version) # - `pythonPackagesExtensions` - import ../pkgs - { pkgs = next; lib = prev.lib; unpatched = prev; } + import ../pkgs { pkgs = prev; final = next; } ) diff --git a/pkgs/default.nix b/pkgs/default.nix index e7ae126f..94cd803d 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,14 +1,22 @@ -{ pkgs ? import {}, lib ? pkgs.lib, unpatched ? pkgs }: +# this supports being used as an overlay or in a standalone context +# - if overlay, invoke as `(final: prev: import ./. { inherit final; pkgs = prev; })` +# - if standalone: `import ./. { inherit pkgs; }` +# +# using the correct invocation is critical if any packages mentioned here are +# additionally patched elsewhere +# +{ pkgs ? import {}, final ? null }: let + lib = pkgs.lib; + unpatched = pkgs; pythonPackagesOverlay = py-final: py-prev: import ./python-packages { inherit (py-final) callPackage; }; - # this scope ensures that my packages can all take each other as inputs, - # even when evaluated bare (i.e. outside of an overlay) - sane = lib.makeScope pkgs.newScope (self: with self; { + final' = if final != null then final else (pkgs // sane); + sane = with final'; { sane-data = import ../modules/data { inherit lib; }; - sane-lib = import ../modules/lib pkgs; + sane-lib = import ../modules/lib final'; ### ADDITIONAL PACKAGES bootpart-uefi-x86_64 = callPackage ./additional/bootpart-uefi-x86_64 { }; @@ -80,5 +88,5 @@ let python3 = unpatched.python3.override { packageOverrides = pythonPackagesOverlay; }; - }); -in sane.packages sane + }; +in sane