1{
2 buildNpmPackage,
3 fetchFromGitHub,
4 vips,
5 lib,
6 pkg-config,
7 jq,
8 makeWrapper,
9 nix-update-script,
10}:
11buildNpmPackage rec {
12 pname = "factoriolab";
13 version = "3.17.5";
14
15 src = fetchFromGitHub {
16 owner = "factoriolab";
17 repo = "factoriolab";
18 tag = "v${version}";
19 hash = "sha256-Ra3xnOCIzx5oCeMU8kARcup+wsxknePBO/w1xGbwgT8=";
20 fetchLFS = true;
21 };
22 buildInputs = [ vips ];
23 nativeBuildInputs = [
24 pkg-config
25 makeWrapper
26 ];
27
28 npmDepsHash = "sha256-FX9zxq3kIQ5nxEPW57X53novtCFBPV5w9jg882EC2Lo=";
29 # By default angular tries to optimize fonts by inlining them
30 # which needs internet access during building to download said fonts.
31 # Internet access during build would necessitate turning this into a fixed output derivation
32 # which is difficult as said fonts are not actually stable.
33 # This disables font inlining completely in which case the fonts will be loaded on demand by your browser
34 postPatch = ''
35 ${lib.getExe jq} '.projects.factoriolab.architect.build.options += { "optimization": {"fonts": false } }' ./angular.json > angular.json.new
36 mv -f angular.json.new angular.json
37 '';
38
39 installPhase = ''
40 runHook preInstall
41
42 mkdir -p $out/share
43
44 cp -r dist/browser $out/share/factoriolab
45
46 runHook postInstall
47 '';
48 passthru.updateScript = nix-update-script { };
49
50 meta = {
51 homepage = "https://github.com/factoriolab/factoriolab";
52 changelog = "https://github.com/factoriolab/factoriolab/releases/tag/${version}";
53 description = "Angular-based calculator for factory games like Factorio and Dyson Sphere Program";
54 license = lib.licenses.mit;
55 maintainers = with lib.maintainers; [ patrickdag ];
56 };
57}