Unverified Commit 30cf7646 authored by Aleksana's avatar Aleksana Committed by GitHub
Browse files

backrest: never download restic from an external URL (#422233)

parents b441e40f 125ae45f
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
  restic,
  stdenv,
  util-linux,
  makeBinaryWrapper,
}:
let
  pname = "backrest";
@@ -53,9 +54,19 @@ in
buildGoModule {
  inherit pname src version;

  postPatch = ''
    sed -i -e \
      '/func installRestic(targetPath string) error {/a\
        return fmt.Errorf("installing restic from an external source is prohibited by nixpkgs")' \
      internal/resticinstaller/resticinstaller.go
  '';

  vendorHash = "sha256-AINnBkP+e9C/f/C3t6NK+6PYSVB4NON0C71S6SwUXbE=";

  nativeBuildInputs = [ gzip ];
  nativeBuildInputs = [
    gzip
    makeBinaryWrapper
  ];

  preBuild = ''
    mkdir -p ./webui/dist
@@ -87,6 +98,11 @@ buildGoModule {
    export HOME=$(pwd)
  '';

  postInstall = ''
    wrapProgram $out/bin/backrest \
      --set-default BACKREST_RESTIC_COMMAND "${lib.getExe restic}"
  '';

  meta = {
    description = "Web UI and orchestrator for restic backup";
    homepage = "https://github.com/garethgeorge/backrest";