99 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			99 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
| {
 | |
|   rustPlatform,
 | |
|   fetchFromGitHub,
 | |
|   lib,
 | |
|   stdenvNoCC,
 | |
|   bun,
 | |
|   nodejs-slim_latest,
 | |
|   nix-update-script,
 | |
|   withServer ? true,
 | |
| }:
 | |
| let
 | |
|   pname = "cup-docker";
 | |
|   version = "3.4.0";
 | |
|   src = fetchFromGitHub {
 | |
|     owner = "sergi0g";
 | |
|     repo = "cup";
 | |
|     tag = "v${version}";
 | |
|     hash = "sha256-ciH3t2L2eJhk1+JXTqEJSuHve8OuVod7AuQ3iFWmKRE=";
 | |
|   };
 | |
|   web = stdenvNoCC.mkDerivation (finalAttrs: {
 | |
|     pname = "${pname}-web";
 | |
|     inherit version src;
 | |
|     impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
 | |
|       "GIT_PROXY_COMMAND"
 | |
|       "SOCKS_SERVER"
 | |
|     ];
 | |
|     sourceRoot = "${finalAttrs.src.name}/web";
 | |
|     nativeBuildInputs = [
 | |
|       bun
 | |
|       nodejs-slim_latest
 | |
|     ];
 | |
|     configurePhase = ''
 | |
|       runHook preConfigure
 | |
|       bun install --no-progress --frozen-lockfile
 | |
|       substituteInPlace node_modules/.bin/{vite,tsc} \
 | |
|         --replace-fail "/usr/bin/env node" "${nodejs-slim_latest}/bin/node"
 | |
|       runHook postConfigure
 | |
|     '';
 | |
|     buildPhase = ''
 | |
|       runHook preBuild
 | |
|       bun run build
 | |
|       runHook postBuild
 | |
|     '';
 | |
|     installPhase = ''
 | |
|       runHook preInstall
 | |
|       mkdir -p $out/dist
 | |
|       cp -R ./dist $out
 | |
|       runHook postInstall
 | |
|     '';
 | |
|     outputHash = "sha256-Ac1PJYmTQv9XrmhmF1p77vdXh8252hz0CUKxJA+VQR4=";
 | |
|     outputHashAlgo = "sha256";
 | |
|     outputHashMode = "recursive";
 | |
|   });
 | |
| in
 | |
| rustPlatform.buildRustPackage {
 | |
|   inherit
 | |
|     src
 | |
|     version
 | |
|     pname
 | |
|     ;
 | |
| 
 | |
|   cargoHash = "sha256-L9zugOwlPwpdtjV87dT1PH7FAMJYHYFuvfyOfPe5b2k=";
 | |
| 
 | |
|   buildNoDefaultFeatures = true;
 | |
|   buildFeatures =
 | |
|     [
 | |
|       "cli"
 | |
|     ]
 | |
|     ++ lib.optional withServer [
 | |
|       "server"
 | |
|     ];
 | |
| 
 | |
|   preConfigure = lib.optionalString withServer ''
 | |
|     cp -r ${web}/dist src/static
 | |
|   '';
 | |
| 
 | |
|   passthru = {
 | |
|     inherit web;
 | |
|     updateScript = nix-update-script {
 | |
|       extraArgs = [
 | |
|         "--subpackage"
 | |
|         "web"
 | |
|       ];
 | |
|     };
 | |
|   };
 | |
| 
 | |
|   meta = {
 | |
|     description = "a lightweight way to check for container image updates. written in Rust";
 | |
|     homepage = "https://cup.sergi0g.dev";
 | |
|     license = lib.licenses.agpl3Only;
 | |
|     platforms = lib.platforms.all;
 | |
|     changelog = "https://github.com/sergi0g/cup/releases";
 | |
|     mainProgram = "cup";
 | |
|     maintainers = with lib.maintainers; [
 | |
|       kuflierl
 | |
|     ];
 | |
|   };
 | |
| }
 | 
