nixpkgs-suyu/pkgs/development/node-packages/default.nix
Malo Bourgon 31673e9aee nodePackages: make it easy to add meta.mainProgram to packages
This was accomplish by moving the current overrides overlay out of
./default.nix into to a seperate file ./overrides.nix, and composing
that overlay an overlay ,`mainProgramOverrides`, (defined in
./default.nix) which uses the contents of a new file ./main-programs.nix
to create overrides that add `meta.mainProgram` to packages.

The following changes were also made to existing overrides:
* `self` and `super` where changed to `final` and `prev` respectively
* Existing additions of `mainProgram` were moved to ./main-programs.nix
* References to `pkgs.lib` were changed to `lib`
* References to `pkgs.nodejs` were changed to `nodejs`
* References to `nodePackages` were changed  to `final`
* References to `pkgs.callPackage` were changed to `callPackage`

Finally `meta.mainProgram` was added to all packages that provide a
single executable whose name differs from the package's name, for
packages available on `{aarch64,x86_64}-darwin` and `x86_64-linux`.
2022-05-14 11:30:15 -07:00

23 lines
630 B
Nix

{ pkgs, lib, nodejs, stdenv}:
let
inherit (lib) composeManyExtensions extends makeExtensible mapAttrs;
nodePackages = final: import ./composition.nix {
inherit pkgs nodejs;
inherit (stdenv.hostPlatform) system;
};
mainProgramOverrides = final: prev:
mapAttrs (pkgName: mainProgram:
prev.${pkgName}.override (oldAttrs: {
meta = oldAttrs.meta // { inherit mainProgram; };
})
) (import ./main-programs.nix);
extensions = composeManyExtensions [
mainProgramOverrides
(import ./overrides.nix { inherit pkgs nodejs; })
];
in
makeExtensible (extends extensions nodePackages)