|
1 | 1 | { |
2 | | - description = "Spacebar server, written in Typescript."; |
| 2 | + description = "A macro to host element call on a Cisco WebEx device."; |
3 | 3 |
|
4 | 4 | inputs = { |
5 | | - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; |
| 5 | + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
6 | 6 | flake-utils.url = "github:numtide/flake-utils"; |
7 | 7 | }; |
8 | 8 |
|
|
18 | 18 | pkgs = import nixpkgs { |
19 | 19 | inherit system; |
20 | 20 | }; |
21 | | - hashesFile = builtins.fromJSON (builtins.readFile ./hashes.json); |
22 | 21 | lib = pkgs.lib; |
23 | 22 | in |
24 | 23 | { |
25 | 24 | packages = { |
26 | | - default = pkgs.buildNpmPackage { |
27 | | - pname = "cisco-element-call"; |
28 | | - name = "cisco-element-call"; |
| 25 | + default = |
| 26 | + let |
| 27 | + filteredSrc = lib.fileset.toSource { |
| 28 | + root = ./.; |
| 29 | + fileset = ( |
| 30 | + lib.fileset.intersection ./. ( |
| 31 | + lib.fileset.unions [ |
| 32 | + ./src |
| 33 | + ./package.json |
| 34 | + ./package-lock.json |
| 35 | + ./tsconfig.json |
| 36 | + ] |
| 37 | + ) |
| 38 | + ); |
| 39 | + }; |
| 40 | + in |
| 41 | + pkgs.buildNpmPackage { |
| 42 | + pname = "cisco-element-call"; |
| 43 | + name = "cisco-element-call"; |
29 | 44 |
|
30 | | - meta = with lib; { |
31 | | - description = "A call to host element call on a Cisco WebEx device."; |
32 | | - homepage = "https://github.com/TheArcaneBrony/cisco-element-call"; |
33 | | - #license = licenses.agpl3Plus; |
34 | | - platforms = platforms.all; |
35 | | - mainProgram = "start-macro"; |
36 | | - }; |
| 45 | + meta = with lib; { |
| 46 | + description = "A maco to host element call on a Cisco WebEx device."; |
| 47 | + homepage = "https://github.com/TheArcaneBrony/cisco-element-call"; |
| 48 | + #license = licenses.agpl3Plus; |
| 49 | + platforms = platforms.all; |
| 50 | + mainProgram = "start-macro"; |
| 51 | + }; |
37 | 52 |
|
38 | | - src = ./.; |
39 | | - nativeBuildInputs = with pkgs; [ python3 ]; |
40 | | - npmDepsHash = hashesFile.npmDepsHash; |
41 | | - makeCacheWritable = true; |
42 | | - postPatch = '' |
43 | | - substituteInPlace package.json --replace 'npx patch-package' '${pkgs.nodePackages.patch-package}/bin/patch-package' |
44 | | - ''; |
45 | | - installPhase = '' |
46 | | - runHook preInstall |
47 | | - set -x |
48 | | - #remove packages not needed for production, or at least try to... |
49 | | - npm prune --omit dev --no-save $npmInstallFlags "''${npmInstallFlagsArray[@]}" $npmFlags "''${npmFlagsArray[@]}" |
50 | | - find node_modules -maxdepth 1 -type d -empty -delete |
| 53 | + src = filteredSrc; |
| 54 | + nativeBuildInputs = with pkgs; [ python3 ]; |
| 55 | + npmDeps = pkgs.importNpmLock { npmRoot = filteredSrc; }; |
| 56 | + npmConfigHook = pkgs.importNpmLock.npmConfigHook; |
51 | 57 |
|
52 | | - mkdir -p $out |
53 | | - cp -r dist node_modules package.json $out/ |
54 | | - makeWrapper ${pkgs.nodejs}/bin/node $out/bin/start-macro --prefix NODE_PATH : $out/node_modules --add-flags $out/dist/index.js |
| 58 | + makeCacheWritable = true; |
| 59 | + postPatch = '' |
| 60 | + substituteInPlace package.json --replace 'npx patch-package' '${pkgs.nodePackages.patch-package}/bin/patch-package' |
| 61 | + ''; |
| 62 | + installPhase = '' |
| 63 | + runHook preInstall |
| 64 | + set -x |
| 65 | + #remove packages not needed for production, or at least try to... |
| 66 | + npm prune --omit dev --no-save $npmInstallFlags "''${npmInstallFlagsArray[@]}" $npmFlags "''${npmFlagsArray[@]}" |
| 67 | + find node_modules -maxdepth 1 -type d -empty -delete |
55 | 68 |
|
56 | | - set +x |
57 | | - runHook postInstall |
58 | | - ''; |
59 | | - }; |
| 69 | + mkdir -p $out |
| 70 | + cp -r dist node_modules package.json $out/ |
| 71 | + makeWrapper ${pkgs.nodejs}/bin/node $out/bin/start-macro --prefix NODE_PATH : $out/node_modules --add-flags $out/dist/index.js |
60 | 72 |
|
61 | | - update-nix = pkgs.writeShellApplication { |
62 | | - name = "update-nix"; |
63 | | - runtimeInputs = with pkgs; [ |
64 | | - prefetch-npm-deps |
65 | | - nix |
66 | | - jq |
67 | | - ]; |
68 | | - text = '' |
69 | | - nix flake update --extra-experimental-features 'nix-command flakes' |
70 | | - DEPS_HASH=$(prefetch-npm-deps package-lock.json) |
71 | | - TMPFILE=$(mktemp) |
72 | | - jq '.npmDepsHash = "'"$DEPS_HASH"'"' hashes.json > "$TMPFILE" |
73 | | - mv -- "$TMPFILE" hashes.json |
74 | | - ''; |
75 | | - }; |
| 73 | + set +x |
| 74 | + runHook postInstall |
| 75 | + ''; |
| 76 | + }; |
76 | 77 | }; |
77 | 78 |
|
78 | 79 | devShell = pkgs.mkShell { |
|
0 commit comments