summaryrefslogtreecommitdiffstats
path: root/pkgs/development/web/nodejs/symlink.nix
blob: 34d919b20f46b34c9468377a9f746b69705d4470 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{
  lib,
  nodejs-slim,
  symlinkJoin,
}:
let
  hasDisallowedPrefix = lib.hasPrefix "__";
  allowedNames = [
    "override"
    "overrideAttrs"
    "overrideDerivation"
    "outputs"
    "outputName"
    "system"
    "type"

    # Filter out arguments of `getOutput`
    "bin"
    "dev"
    "include"
    "lib"
    "man"
    "out"
    "static"

    # Filter out outputs that didn't exist on 25.11
    "npm"
    "corepack"
  ];
in
(symlinkJoin {
  pname = "nodejs";
  inherit (nodejs-slim) version passthru meta;
  paths = [
    nodejs-slim
    nodejs-slim.npm
  ]
  ++ lib.optional (builtins.hasAttr "corepack" nodejs-slim) nodejs-slim.corepack;
}).overrideAttrs
  (nodejs: {
    passthru =
      (builtins.listToAttrs (
        map
          (name: {
            inherit name;
            value = lib.warn "Use nodejs-slim.${name} instead of nodejs.${name}" nodejs-slim.${name};
          })
          (
            builtins.filter (
              name: !hasDisallowedPrefix name && !(builtins.elem name allowedNames) && !(nodejs ? ${name})
            ) (builtins.attrNames nodejs-slim)
          )
      ))
      // nodejs.passthru;
  })