1{ stdenv, lib, buildGoModule, fetchFromGitHub, installShellFiles, makeWrapper
2, nixosTests, rclone }:
3
4buildGoModule rec {
5 pname = "restic";
6 version = "0.12.1";
7
8 src = fetchFromGitHub {
9 owner = "restic";
10 repo = "restic";
11 rev = "v${version}";
12 sha256 = "19lzccipbpxdkay60zdqfq8dgah0sbxzjcfcx285c28js2zpp85m";
13 };
14
15 patches = [
16 # The TestRestoreWithPermissionFailure test fails in Nix’s build sandbox
17 ./0001-Skip-testing-restore-with-permission-failure.patch
18 ];
19
20 vendorSha256 = "0sdswihiy4r3lw9a87xj2qm3nf28cw56yfm56mva6b8lr3vk93l6";
21
22 subPackages = [ "cmd/restic" ];
23
24 nativeBuildInputs = [ installShellFiles makeWrapper ];
25
26 passthru.tests.restic = nixosTests.restic;
27
28 postPatch = ''
29 rm cmd/restic/integration_fuse_test.go
30 '';
31
32 postInstall = ''
33 wrapProgram $out/bin/restic --prefix PATH : '${rclone}/bin'
34 '' + lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
35 $out/bin/restic generate \
36 --bash-completion restic.bash \
37 --zsh-completion restic.zsh \
38 --man .
39 installShellCompletion restic.{bash,zsh}
40 installManPage *.1
41 '';
42
43 meta = with lib; {
44 homepage = "https://restic.net";
45 description = "A backup program that is fast, efficient and secure";
46 platforms = platforms.linux ++ platforms.darwin;
47 license = licenses.bsd2;
48 maintainers = [ maintainers.mbrgm ];
49 };
50}