1{
2 rustPlatform,
3 fetchFromGitHub,
4 lib,
5 stdenvNoCC,
6 bun,
7 nodejs-slim_latest,
8 nix-update-script,
9 withServer ? true,
10}:
11let
12 pname = "cup-docker";
13 version = "3.4.0";
14 src = fetchFromGitHub {
15 owner = "sergi0g";
16 repo = "cup";
17 tag = "v${version}";
18 hash = "sha256-ciH3t2L2eJhk1+JXTqEJSuHve8OuVod7AuQ3iFWmKRE=";
19 };
20 web = stdenvNoCC.mkDerivation (finalAttrs: {
21 pname = "${pname}-web";
22 inherit version src;
23 impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
24 "GIT_PROXY_COMMAND"
25 "SOCKS_SERVER"
26 ];
27 sourceRoot = "${finalAttrs.src.name}/web";
28 nativeBuildInputs = [
29 bun
30 nodejs-slim_latest
31 ];
32 configurePhase = ''
33 runHook preConfigure
34 bun install --no-progress --frozen-lockfile
35 substituteInPlace node_modules/.bin/{vite,tsc} \
36 --replace-fail "/usr/bin/env node" "${nodejs-slim_latest}/bin/node"
37 runHook postConfigure
38 '';
39 buildPhase = ''
40 runHook preBuild
41 bun run build
42 runHook postBuild
43 '';
44 installPhase = ''
45 runHook preInstall
46 mkdir -p $out/dist
47 cp -R ./dist $out
48 runHook postInstall
49 '';
50 outputHash = "sha256-Ac1PJYmTQv9XrmhmF1p77vdXh8252hz0CUKxJA+VQR4=";
51 outputHashAlgo = "sha256";
52 outputHashMode = "recursive";
53 });
54in
55rustPlatform.buildRustPackage {
56 inherit
57 src
58 version
59 pname
60 ;
61
62 cargoHash = "sha256-L9zugOwlPwpdtjV87dT1PH7FAMJYHYFuvfyOfPe5b2k=";
63
64 buildNoDefaultFeatures = true;
65 buildFeatures = [
66 "cli"
67 ]
68 ++ lib.optional withServer [
69 "server"
70 ];
71
72 preConfigure = lib.optionalString withServer ''
73 cp -r ${web}/dist src/static
74 '';
75
76 passthru = {
77 inherit web;
78 updateScript = nix-update-script {
79 extraArgs = [
80 "--subpackage"
81 "web"
82 ];
83 };
84 };
85
86 meta = {
87 description = "Lightweight way to check for container image updates. written in Rust";
88 homepage = "https://cup.sergi0g.dev";
89 license = lib.licenses.agpl3Only;
90 platforms = lib.platforms.all;
91 changelog = "https://github.com/sergi0g/cup/releases";
92 mainProgram = "cup";
93 maintainers = with lib.maintainers; [
94 kuflierl
95 ];
96 };
97}