summary refs log tree commit diff
path: root/pkgs/applications/networking/cluster/tilt
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/networking/cluster/tilt')
-rw-r--r--pkgs/applications/networking/cluster/tilt/assets.nix53
-rw-r--r--pkgs/applications/networking/cluster/tilt/binary.nix31
-rw-r--r--pkgs/applications/networking/cluster/tilt/default.nix44
3 files changed, 100 insertions, 28 deletions
diff --git a/pkgs/applications/networking/cluster/tilt/assets.nix b/pkgs/applications/networking/cluster/tilt/assets.nix
new file mode 100644
index 00000000000..85645c2849d
--- /dev/null
+++ b/pkgs/applications/networking/cluster/tilt/assets.nix
@@ -0,0 +1,53 @@
+{ lib
+, stdenvNoCC
+, version, src
+, fetchYarnDeps
+, fixup_yarn_lock, yarn, nodejs
+}:
+
+stdenvNoCC.mkDerivation rec {
+  pname = "tilt-assets";
+
+  inherit src version;
+
+  nativeBuildInputs = [ fixup_yarn_lock yarn nodejs ];
+
+  yarnOfflineCache = fetchYarnDeps {
+    yarnLock = "${src}/web/yarn.lock";
+    hash = "sha256-UTxglGn3eIgahZg4kxolg2f2MTReCL4r/GyWNg4105E=";
+  };
+
+  configurePhase = ''
+    export HOME=$(mktemp -d)/yarn_home
+  '';
+
+  buildPhase = ''
+    runHook preBuild
+
+    yarn config --offline set yarn-offline-mirror $yarnOfflineCache
+
+    cd web
+    fixup_yarn_lock yarn.lock
+    yarn install --offline --frozen-lockfile --ignore-engines
+    patchShebangs node_modules
+    export PATH=$PWD/node_modules/.bin:$PATH
+    ./node_modules/.bin/react-scripts build
+
+    mkdir -p $out
+    cd ..
+
+    runHook postBuild
+  '';
+
+  installPhase = ''
+    cp -r web/build/* $out
+  '';
+
+  meta = with lib; {
+    description = "Assets needed for Tilt";
+    homepage = "https://tilt.dev/";
+    license = lib.licenses.asl20;
+    maintainers = with lib.maintainers; [ anton-dessiatov ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/applications/networking/cluster/tilt/binary.nix b/pkgs/applications/networking/cluster/tilt/binary.nix
new file mode 100644
index 00000000000..d326f0f92e8
--- /dev/null
+++ b/pkgs/applications/networking/cluster/tilt/binary.nix
@@ -0,0 +1,31 @@
+{ lib
+, buildGoModule
+, src, version
+, tilt-assets
+}:
+
+buildGoModule rec {
+  pname = "tilt";
+  /* Do not use "dev" as a version. If you do, Tilt will consider itself
+    running in development environment and try to serve assets from the
+    source tree, which is not there once build completes.  */
+  inherit src version;
+
+  vendorHash = null;
+
+  subPackages = [ "cmd/tilt" ];
+
+  ldflags = [ "-X main.version=${version}" ];
+
+  preBuild = ''
+    mkdir -p pkg/assets/build
+    cp -r ${tilt-assets}/* pkg/assets/build/
+  '';
+
+  meta = {
+    description = "Local development tool to manage your developer instance when your team deploys to Kubernetes in production";
+    homepage = "https://tilt.dev/";
+    license = lib.licenses.asl20;
+    maintainers = with lib.maintainers; [ anton-dessiatov ];
+  };
+}
diff --git a/pkgs/applications/networking/cluster/tilt/default.nix b/pkgs/applications/networking/cluster/tilt/default.nix
index ba870fea761..646f0c9a0a3 100644
--- a/pkgs/applications/networking/cluster/tilt/default.nix
+++ b/pkgs/applications/networking/cluster/tilt/default.nix
@@ -1,32 +1,20 @@
-{ lib
-, buildGoModule
-, fetchFromGitHub
+{ fetchFromGitHub
+, callPackage
 }:
+let args = rec {
+      /* Do not use "dev" as a version. If you do, Tilt will consider itself
+        running in development environment and try to serve assets from the
+        source tree, which is not there once build completes.  */
+      version = "0.33.6";
 
-buildGoModule rec {
-  pname = "tilt";
-  /* Do not use "dev" as a version. If you do, Tilt will consider itself
-    running in development environment and try to serve assets from the
-    source tree, which is not there once build completes.  */
-  version = "0.33.5";
+      src = fetchFromGitHub {
+        owner = "tilt-dev";
+        repo = "tilt";
+        rev = "v${version}";
+        hash = "sha256-WtE8ExUKFRtdYeg0+My/DB+L/qT+J1EaKHKChNjC5oI=";
+      };
+    };
 
-  src = fetchFromGitHub {
-    owner = "tilt-dev";
-    repo = "tilt";
-    rev = "v${version}";
-    hash = "sha256-o78PoIKj+0FvZRpm0AqtUq3N9a9/LDYc7DIPZgSZe4s=";
-  };
+  tilt-assets = callPackage ./assets.nix args;
+in callPackage ./binary.nix (args // { inherit tilt-assets; })
 
-  vendorHash = null;
-
-  subPackages = [ "cmd/tilt" ];
-
-  ldflags = [ "-X main.version=${version}" ];
-
-  meta = {
-    description = "Local development tool to manage your developer instance when your team deploys to Kubernetes in production";
-    homepage = "https://tilt.dev/";
-    license = lib.licenses.asl20;
-    maintainers = with lib.maintainers; [ anton-dessiatov ];
-  };
-}