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