From e2e3f9d95165677c549b51eb74420de450647c16 Mon Sep 17 00:00:00 2001 From: Anton Desyatov Date: Thu, 12 Oct 2023 19:37:48 +0400 Subject: tilt: fix missing assets --- .../networking/cluster/tilt/assets.nix | 53 ++++++++++++++++++++++ .../networking/cluster/tilt/binary.nix | 31 +++++++++++++ .../networking/cluster/tilt/default.nix | 44 +++++++----------- 3 files changed, 100 insertions(+), 28 deletions(-) create mode 100644 pkgs/applications/networking/cluster/tilt/assets.nix create mode 100644 pkgs/applications/networking/cluster/tilt/binary.nix (limited to 'pkgs/applications') 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 dd95c6d939e..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.6"; + 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-WtE8ExUKFRtdYeg0+My/DB+L/qT+J1EaKHKChNjC5oI="; - }; + 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 ]; - }; -} -- cgit 1.4.1