nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 130 lines 3.0 kB view raw
1{ 2 buildGoModule, 3 fetchFromGitHub, 4 gzip, 5 iana-etc, 6 lib, 7 libredirect, 8 nodejs, 9 pnpm_9, 10 fetchPnpmDeps, 11 pnpmConfigHook, 12 restic, 13 stdenv, 14 util-linux, 15 makeBinaryWrapper, 16}: 17let 18 pname = "backrest"; 19 version = "1.10.1"; 20 21 src = fetchFromGitHub { 22 owner = "garethgeorge"; 23 repo = "backrest"; 24 tag = "v${version}"; 25 hash = "sha256-8WWs7XEVKAc/XmeL+dsw25azfLjUbHKp2MsB6Be14VE="; 26 }; 27 28 frontend = stdenv.mkDerivation (finalAttrs: { 29 inherit version; 30 pname = "${pname}-webui"; 31 src = "${src}/webui"; 32 33 nativeBuildInputs = [ 34 nodejs 35 pnpmConfigHook 36 pnpm_9 37 ]; 38 39 pnpmDeps = fetchPnpmDeps { 40 inherit (finalAttrs) pname version src; 41 pnpm = pnpm_9; 42 fetcherVersion = 1; 43 hash = "sha256-vJgsU0OXyAKjUJsPOyIY8o3zfNW1BUZ5IL814wmJr3o="; 44 }; 45 46 buildPhase = '' 47 runHook preBuild 48 export BACKREST_BUILD_VERSION=${version} 49 pnpm build 50 runHook postBuild 51 ''; 52 53 installPhase = '' 54 runHook preInstall 55 mkdir $out 56 cp -r dist/* $out 57 runHook postInstall 58 ''; 59 }); 60in 61buildGoModule { 62 inherit pname src version; 63 64 postPatch = '' 65 sed -i -e \ 66 '/func installRestic(targetPath string) error {/a\ 67 return fmt.Errorf("installing restic from an external source is prohibited by nixpkgs")' \ 68 internal/resticinstaller/resticinstaller.go 69 ''; 70 71 vendorHash = "sha256-cYqK/sddLI38K9bzCpnomcZOYbSRDBOEru4Y26rBLFw="; 72 73 nativeBuildInputs = [ 74 gzip 75 makeBinaryWrapper 76 ]; 77 78 preBuild = '' 79 mkdir -p ./webui/dist 80 cp -r ${frontend}/* ./webui/dist 81 82 go generate -skip="npm" ./... 83 ''; 84 85 nativeCheckInputs = [ 86 util-linux 87 ] 88 ++ lib.optionals stdenv.hostPlatform.isDarwin [ libredirect.hook ]; 89 90 checkFlags = 91 let 92 skippedTests = [ 93 "TestMultihostIndexSnapshots" 94 "TestRunCommand" 95 "TestSnapshot" 96 ] 97 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 98 "TestBackup" # relies on ionice 99 "TestCancelBackup" 100 "TestFirstRun" # e2e test requires networking 101 ]; 102 in 103 [ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ]; 104 105 preCheck = '' 106 # Use restic from nixpkgs, otherwise download fails in sandbox 107 export BACKREST_RESTIC_COMMAND="${restic}/bin/restic" 108 export HOME=$(pwd) 109 '' 110 + lib.optionalString (stdenv.hostPlatform.isDarwin) '' 111 export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/services=${iana-etc}/etc/services 112 ''; 113 114 doCheck = true; 115 116 postInstall = '' 117 wrapProgram $out/bin/backrest \ 118 --set-default BACKREST_RESTIC_COMMAND "${lib.getExe restic}" 119 ''; 120 121 meta = { 122 description = "Web UI and orchestrator for restic backup"; 123 homepage = "https://github.com/garethgeorge/backrest"; 124 changelog = "https://github.com/garethgeorge/backrest/releases/tag/v${version}"; 125 license = lib.licenses.gpl3Only; 126 maintainers = with lib.maintainers; [ iedame ]; 127 mainProgram = "backrest"; 128 platforms = lib.platforms.unix; 129 }; 130}