summary refs log tree commit diff
path: root/node-modules.nix
blob: b064ee0a038d4dd16bb93d03937c41666da07ffa (plain) (blame)
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
56
{
  pkgs,
  lib,
  ...
}:

let
  filteredSrc = lib.fileset.toSource {
    root = ./.;
    fileset = (
      lib.fileset.intersection ./. (
        lib.fileset.unions [
          ./package.json
          ./package-lock.json
          ./patches
        ]
      )
    );
  };
in
pkgs.buildNpmPackage {
  pname = "spacebar-server-ts-node_modules";
  nodejs = pkgs.nodejs_24;
  version = builtins.hashFile "sha256" ./package.json;

  meta = with lib; {
    description = "Node modules for the spacebar-server-ts package.";
    homepage = "https://github.com/spacebarchat/server";
    license = licenses.agpl3Plus;
    platforms = platforms.all;
    maintainers = with maintainers; [ RorySys ];
  };

  src = filteredSrc;
  npmDeps = pkgs.importNpmLock { npmRoot = filteredSrc; };
  npmConfigHook = pkgs.importNpmLock.npmConfigHook;

  dontNpmBuild = true;
  makeCacheWritable = true;

  nativeBuildInputs = with pkgs; [
    (pkgs.python3.withPackages (ps: with ps; [ setuptools ]))
  ];

  installPhase = ''
    runHook preInstall

    # Copy outputs
    echo "Copying node_modules as $out"
    cp -r node_modules $out
    echo -n 'Disk usage: '
    du -sh node_modules/

    runHook postInstall
  '';
}