1{ stdenv, lib, buildGoModule, fetchFromGitHub, installShellFiles, makeWrapper
2, nixosTests, rclone }:
3
4buildGoModule rec {
5 pname = "restic";
6 version = "0.16.2";
7
8 src = fetchFromGitHub {
9 owner = "restic";
10 repo = "restic";
11 rev = "v${version}";
12 hash = "sha256-Qrbg8/f1ne+7c+mnUc/8CoZBjiGLohJXnu0cnc0pT4g=";
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 vendorHash = "sha256-Ctg6bln5kzGs7gDLo9zUpsbSybKOtHFuHvHG3cxCfac=";
21
22 subPackages = [ "cmd/restic" ];
23
24 nativeBuildInputs = [ installShellFiles makeWrapper ];
25
26 passthru.tests.restic = nixosTests.restic;
27
28 postPatch = ''
29 rm cmd/restic/cmd_mount_integration_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 --fish-completion restic.fish \
38 --zsh-completion restic.zsh \
39 --man .
40 installShellCompletion restic.{bash,fish,zsh}
41 installManPage *.1
42 '';
43
44 meta = with lib; {
45 homepage = "https://restic.net";
46 changelog = "https://github.com/restic/restic/blob/${src.rev}/CHANGELOG.md";
47 description = "A backup program that is fast, efficient and secure";
48 platforms = platforms.linux ++ platforms.darwin;
49 license = licenses.bsd2;
50 maintainers = [ maintainers.mbrgm maintainers.dotlambda ];
51 };
52}