Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / re / resticprofile / package.nix
blob2903a99878334c87fa607a50b2c2020f2f4aee25
2   lib,
3   buildGoModule,
4   fetchFromGitHub,
5   installShellFiles,
6   restic,
7   bash,
8   testers,
9   resticprofile,
12 buildGoModule rec {
13   pname = "resticprofile";
14   version = "0.27.0";
16   src = fetchFromGitHub {
17     owner = "creativeprojects";
18     repo = "resticprofile";
19     rev = "refs/tags/v${version}";
20     hash = "sha256-CUTDlSpP0ztr3sEKT0ppFnWx/bcVuY1oIKWJNZylDoM=";
21   };
23   postPatch = ''
24     substituteInPlace schedule_jobs.go \
25         --replace-fail "os.Executable()" "\"$out/bin/resticprofile\", nil"
27     substituteInPlace shell/command.go \
28         --replace-fail '"bash"' '"${lib.getExe bash}"'
30     substituteInPlace filesearch/filesearch.go \
31         --replace-fail 'paths := getSearchBinaryLocations()' 'return "${lib.getExe restic}", nil; paths := getSearchBinaryLocations()'
33   '';
35   vendorHash = "sha256-t2R5uNsliSn+rIvRM0vT6lQJY62DhhozXnONiCJ9CMc=";
37   ldflags = [
38     "-X main.commit=${src.rev}"
39     "-X main.date=unknown"
40     "-X main.builtBy=nixpkgs"
41   ];
43   nativeBuildInputs = [ installShellFiles ];
45   preCheck = ''
46     rm battery_test.go # tries to get battery data
47     rm update_test.go # tries to use network
48     rm lock/lock_test.go # needs ping
49     rm preventsleep/caffeinate_test.go # tries to communicate with dbus
50     rm priority/ioprio_test.go # tries to set nice(2) IO priority
51     rm restic/downloader_test.go # tries to use network
52     rm schedule/schedule_test.go # tries to use systemctl
54     # `config/path_test.go` expects `$HOME` to be the same as `~nixbld` which is `$NIX_BUILD_TOP`
55     export HOME="$NIX_BUILD_TOP"
56     # `util/tempdir_test.go` expects `$HOME/.cache` to exist
57     mkdir "$HOME/.cache"
58   '';
60   installPhase = ''
61     runHook preInstall
63     install -Dm755 $GOPATH/bin/resticprofile -t $out/bin
65     installShellCompletion --cmd resticprofile \
66         --bash <($out/bin/resticprofile generate --bash-completion) \
67         --zsh <($out/bin/resticprofile generate --zsh-completion)
69     runHook postInstall
70   '';
72   passthru = {
73     tests.version = testers.testVersion {
74       package = resticprofile;
75       command = "resticprofile version";
76     };
77   };
79   meta = {
80     changelog = "https://github.com/creativeprojects/resticprofile/releases/tag/v${version}";
81     description = "Configuration profiles manager for restic backup";
82     homepage = "https://creativeprojects.github.io/resticprofile/";
83     license = with lib.licenses; [
84       gpl3Only
85       lgpl3 # bash shell completion
86     ];
87     mainProgram = "resticprofile";
88     maintainers = with lib.maintainers; [ tomasajt ];
89     platforms = lib.platforms.linux ++ lib.platforms.darwin;
90   };