1{ stdenv, lib, buildGoModule, fetchFromGitHub, installShellFiles, makeWrapper
2, nixosTests, rclone }:
3
4buildGoModule rec {
5 pname = "restic";
6 version = "0.14.0";
7
8 src = fetchFromGitHub {
9 owner = "restic";
10 repo = "restic";
11 rev = "v${version}";
12 hash = "sha256-DwXAifXXQNnbzj2XngCyqPABzB9PS/T9U2/T4/z7wm0=";
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 = "sha256-FakmnQ8RkBYjmj3piA1lDV61FdYIyBmFLY2XXN3AyIQ=";
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 changelog = "https://github.com/restic/restic/blob/${src.rev}/CHANGELOG.md";
46 description = "A backup program that is fast, efficient and secure";
47 platforms = platforms.linux ++ platforms.darwin;
48 license = licenses.bsd2;
49 maintainers = [ maintainers.mbrgm maintainers.dotlambda ];
50 };
51}