Skip to content

Commit

Permalink
pkgs: make package sets extensible
Browse files Browse the repository at this point in the history
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 ];
          });
        });
      })
    ];
  • Loading branch information
minijackson committed Oct 6, 2023
1 parent 7c24e24 commit c83adb5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
{
Expand Down
20 changes: 12 additions & 8 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 {};
Expand All @@ -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

Expand Down Expand Up @@ -61,5 +65,5 @@ with prev;
# EPNix specific packages
book = callPackage ./book {};
manpages = callPackage ./manpages {};
};
});
}

0 comments on commit c83adb5

Please sign in to comment.