at 25.11-pre 192 lines 5.5 kB view raw
1{ 2 lib, 3 stdenv, 4 buildGoModule, 5 rustPlatform, 6 fetchFromGitHub, 7 fetchYarnDeps, 8 9 cargo-tauri, 10 desktop-file-utils, 11 installShellFiles, 12 jq, 13 makeBinaryWrapper, 14 moreutils, 15 nodejs, 16 pkg-config, 17 yarnConfigHook, 18 wrapGAppsHook3, 19 20 glib-networking, 21 libayatana-appindicator, 22 openssl, 23 webkitgtk_4_1, 24 25 testers, 26}: 27 28let 29 version = "0.6.15"; 30 31 src = fetchFromGitHub { 32 owner = "loft-sh"; 33 repo = "devpod"; 34 tag = "v${version}"; 35 hash = "sha256-fLUJeEwNDyzMYUEYVQL9XGQv/VAxjH4IZ1SJa6jx4Mw="; 36 }; 37 38 meta = { 39 description = "Codespaces but open-source, client-only and unopinionated: Works with any IDE and lets you use any cloud, kubernetes or just localhost docker"; 40 mainProgram = "devpod"; 41 homepage = "https://devpod.sh"; 42 license = lib.licenses.mpl20; 43 maintainers = with lib.maintainers; [ 44 maxbrunet 45 tomasajt 46 ]; 47 }; 48 49 devpod = buildGoModule (finalAttrs: { 50 pname = "devpod"; 51 inherit version src meta; 52 53 vendorHash = null; 54 55 env.CGO_ENABLED = 0; 56 57 ldflags = [ 58 "-X github.com/loft-sh/devpod/pkg/version.version=v${version}" 59 ]; 60 61 excludedPackages = [ "./e2e" ]; 62 63 nativeBuildInputs = [ installShellFiles ]; 64 65 postInstall = '' 66 $out/bin/devpod completion bash >devpod.bash 67 $out/bin/devpod completion fish >devpod.fish 68 $out/bin/devpod completion zsh >devpod.zsh 69 installShellCompletion devpod.{bash,fish,zsh} 70 ''; 71 72 passthru.tests.version = testers.testVersion { 73 package = finalAttrs.finalPackage; 74 command = "devpod version"; 75 version = "v${version}"; 76 }; 77 }); 78 79 devpod-desktop = rustPlatform.buildRustPackage { 80 pname = "devpod-desktop"; 81 inherit version src; 82 83 sourceRoot = "${src.name}/desktop"; 84 85 offlineCache = fetchYarnDeps { 86 yarnLock = "${src}/desktop/yarn.lock"; 87 hash = "sha256-0Ov+Ik+th2IiuuqJyiO9t8vTyMqxDa9juEwbwHFaoi4="; 88 }; 89 90 cargoRoot = "src-tauri"; 91 buildAndTestSubdir = "src-tauri"; 92 93 useFetchCargoVendor = true; 94 cargoHash = "sha256-BwuV5nAQcTAtdfK4+NKEt8Cj7gqnatRwHh/BYJJrIPo="; 95 96 patches = [ 97 # don't create a .desktop file automatically registered to open the devpod:// URI scheme 98 # we edit the in-store .desktop file in postInstall to support opening the scheme, 99 # but users will have to configure the default handler manually 100 ./dont-auto-register-scheme.patch 101 102 # disable the button that symlinks the `devpod-cli` binary to ~/.local/bin/devpod 103 # and don't show popup where it prompts you to press the above mentioned button 104 # we'll symlink it manually to $out/bin/devpod in postInstall 105 ./dont-copy-sidecar-out-of-store.patch 106 107 # otherwise it's going to get stuck in an endless error cycle, quickly increasing the log file size 108 ./exit-update-checker-loop.patch 109 ]; 110 111 postPatch = 112 '' 113 ln -s ${lib.getExe devpod} src-tauri/bin/devpod-cli-${stdenv.hostPlatform.rust.rustcTarget} 114 115 # disable upstream updater 116 jq '.plugins.updater.endpoints = [ ] | .bundle.createUpdaterArtifacts = false' src-tauri/tauri.conf.json \ 117 | sponge src-tauri/tauri.conf.json 118 '' 119 + lib.optionalString stdenv.hostPlatform.isLinux '' 120 substituteInPlace $cargoDepsCopy/libappindicator-sys-*/src/lib.rs \ 121 --replace-fail "libayatana-appindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1" 122 ''; 123 124 nativeBuildInputs = 125 [ 126 cargo-tauri.hook 127 jq 128 moreutils 129 nodejs 130 yarnConfigHook 131 ] 132 ++ lib.optionals stdenv.hostPlatform.isLinux [ 133 desktop-file-utils 134 pkg-config 135 wrapGAppsHook3 136 ] 137 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 138 makeBinaryWrapper 139 ]; 140 141 buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ 142 glib-networking 143 libayatana-appindicator 144 openssl 145 webkitgtk_4_1 146 ]; 147 148 postInstall = 149 lib.optionalString stdenv.hostPlatform.isDarwin '' 150 # replace sidecar binary with symlink 151 ln -sf ${lib.getExe devpod} "$out/Applications/DevPod.app/Contents/MacOS/devpod-cli" 152 153 makeWrapper "$out/Applications/DevPod.app/Contents/MacOS/DevPod Desktop" "$out/bin/DevPod Desktop" 154 '' 155 + lib.optionalString stdenv.hostPlatform.isLinux '' 156 # replace sidecar binary with symlink 157 ln -sf ${lib.getExe devpod} "$out/bin/devpod-cli" 158 159 # set up scheme handling 160 desktop-file-edit "$out/share/applications/DevPod.desktop" \ 161 --set-key="Exec" --set-value="\"DevPod Desktop\" %u" \ 162 --set-key="MimeType" --set-value="x-scheme-handler/devpod" 163 164 # whitespace in the icon name causes gtk-update-icon-cache to fail 165 desktop-file-edit "$out/share/applications/DevPod.desktop" \ 166 --set-key="Icon" --set-value="DevPod-Desktop" 167 168 for dir in "$out"/share/icons/hicolor/*/apps; do 169 mv "$dir/DevPod Desktop.png" "$dir/DevPod-Desktop.png" 170 done 171 '' 172 + '' 173 # propagate the `devpod` command 174 ln -s ${lib.getExe devpod} "$out/bin/devpod" 175 ''; 176 177 # we only want to wrap the main binary 178 dontWrapGApps = true; 179 180 postFixup = lib.optionalString stdenv.hostPlatform.isLinux '' 181 wrapGApp "$out/bin/DevPod Desktop" 182 ''; 183 184 meta = meta // { 185 mainProgram = "DevPod Desktop"; 186 platforms = lib.platforms.linux ++ lib.platforms.darwin; 187 }; 188 }; 189in 190{ 191 inherit devpod devpod-desktop; 192}