Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchYarnDeps, 5 fetchFromGitHub, 6 fixup-yarn-lock, 7 nodejs_20, 8 python3, 9 makeBinaryWrapper, 10 git, 11 docker, 12 yarn, 13 docker-compose, 14 nix-update-script, 15}: 16 17let 18 nodejs = nodejs_20; # does not build with 22 19in 20stdenv.mkDerivation (finalAttrs: { 21 pname = "devcontainer"; 22 version = "0.80.0"; 23 24 src = fetchFromGitHub { 25 owner = "devcontainers"; 26 repo = "cli"; 27 tag = "v${finalAttrs.version}"; 28 hash = "sha256-p6iBDNTGYgOPQUTRbiu8IT7kN72OCrw7R0ouhWW9yok="; 29 }; 30 31 yarnOfflineCache = fetchYarnDeps { 32 yarnLock = "${finalAttrs.src}/yarn.lock"; 33 hash = "sha256-LqrNRBMAWUqJH0+a17dIJgpKFP2rlECnWi4eVFfUTFg="; 34 }; 35 36 nativeBuildInputs = [ 37 yarn 38 fixup-yarn-lock 39 python3 40 makeBinaryWrapper 41 nodejs 42 ]; 43 44 buildPhase = '' 45 runHook preBuild 46 47 export HOME=$(mktemp -d) 48 yarn config --offline set yarn-offline-mirror ${finalAttrs.yarnOfflineCache} 49 # Without this, yarn will try to download the dependencies 50 fixup-yarn-lock yarn.lock 51 52 # set nodedir to prevent node-gyp from downloading headers 53 export npm_config_nodedir=${nodejs} 54 55 yarn --offline --frozen-lockfile 56 yarn --offline --frozen-lockfile compile-prod 57 58 runHook postBuild 59 ''; 60 61 installPhase = '' 62 runHook preInstall 63 64 mkdir -p $out/{bin,libexec} 65 cp -r dist $out/libexec 66 cp devcontainer.js $out/libexec/devcontainer.js 67 cp -r node_modules $out/libexec/node_modules 68 cp -r $src/scripts $out/libexec/scripts 69 70 runHook postInstall 71 ''; 72 73 postInstall = '' 74 makeWrapper "${lib.getExe nodejs}" "$out/bin/devcontainer" \ 75 --add-flags "$out/libexec/devcontainer.js" \ 76 --prefix PATH : ${ 77 lib.makeBinPath [ 78 git 79 docker 80 docker-compose 81 ] 82 } 83 ''; 84 85 passthru.updateScript = nix-update-script { }; 86 87 meta = { 88 description = "Dev container CLI, run and manage your dev environments via a devcontainer.json"; 89 homepage = "https://containers.dev/"; 90 license = lib.licenses.mit; 91 maintainers = with lib.maintainers; [ rucadi ]; 92 platforms = lib.platforms.unix; 93 mainProgram = "devcontainer"; 94 }; 95})