From c83adb541edc7eb4729096a73ba3fae08dbb756e Mon Sep 17 00:00:00 2001 From: Minijackson Date: Fri, 6 Oct 2023 13:35:18 +0200 Subject: [PATCH] pkgs: make package sets extensible this enables easier overriding of packages, like this: nixpkgs.overlays = [ (final: prev: { epnix = prev.epnix.extend (final: prev: { epics-base7 = prev.epics-base7.overrideAttrs (oldAttrs: { patches = oldAttrs.patches ++ [ ./my.patch ]; }); }); }) ]; --- flake.nix | 2 +- pkgs/default.nix | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/flake.nix b/flake.nix index 47ed831b..88cc7953 100644 --- a/flake.nix +++ b/flake.nix @@ -22,7 +22,7 @@ overlays = [overlay inputs.bash-lib.overlay]; }; in { - packages = flake-utils.lib.flattenTree (pkgs.recurseIntoAttrs pkgs.epnix); + packages = flake-utils.lib.flattenTree pkgs.epnix; checks = { diff --git a/pkgs/default.nix b/pkgs/default.nix index 09777425..b062816d 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,11 +1,15 @@ -epnixLib: final: prev: -with prev; - recurseIntoAttrs rec { +epnixLib: final: prev: let + inherit (final) callPackage; + # From prev, else it somehow causes an infinite recursion + inherit (prev) recurseIntoAttrs; + recurseExtensible = f: recurseIntoAttrs (final.lib.makeExtensible f); +in + recurseIntoAttrs { inherit epnixLib; mkEpicsPackage = callPackage ./build-support/mk-epics-package.nix {}; - epnix = recurseIntoAttrs rec { + epnix = recurseExtensible (self: { # EPICS base epics-base7 = callPackage ./epnix/epics-base { @@ -16,11 +20,11 @@ with prev; version = "3.15.9"; hash = "sha256-QWScmCEaG0F6OW6LPCaFur4W57oRl822p7wpzbYhOuA="; }; - epics-base = epics-base7; + epics-base = self.epics-base7; # EPICS support modules - support = recurseIntoAttrs { + support = recurseExtensible (_self: { asyn = callPackage ./epnix/support/asyn {}; autosave = callPackage ./epnix/support/autosave {}; calc = callPackage ./epnix/support/calc {}; @@ -31,7 +35,7 @@ with prev; snmp = callPackage ./epnix/support/snmp {}; sscan = callPackage ./epnix/support/sscan {}; StreamDevice = callPackage ./epnix/support/StreamDevice {}; - }; + }); # EPICS related tools and extensions @@ -61,5 +65,5 @@ with prev; # EPNix specific packages book = callPackage ./book {}; manpages = callPackage ./manpages {}; - }; + }); }