Unverified Commit 14c234a2 authored by Niklas Korz's avatar Niklas Korz Committed by GitHub
Browse files

duplicati: 2.1.0.2 -> 2.1.0.5 (#412906)

parents d2a7d406 0fc73e51
Loading
Loading
Loading
Loading
+43 −1
Original line number Diff line number Diff line
@@ -6,6 +6,12 @@
}:
let
  cfg = config.services.duplicati;

  parametersFile =
    if cfg.parametersFile != null then
      cfg.parametersFile
    else
      pkgs.writeText "duplicati-parameters" cfg.parameters;
in
{
  options = {
@@ -53,12 +59,48 @@ in
          Run as root with special care.
        '';
      };

      parameters = lib.mkOption {
        default = "";
        type = lib.types.lines;
        example = ''
          --webservice-allowedhostnames=*
        '';
        description = ''
          This option can be used to store some or all of the options given to the
          commandline client.
          Each line in this option should be of the format --option=value.
          The options in this file take precedence over the options provided
          through command line arguments.
          <link xlink:href="https://duplicati.readthedocs.io/en/latest/06-advanced-options/#parameters-file">Duplicati docs: parameters-file</link>
        '';
      };

      parametersFile = lib.mkOption {
        default = null;
        type = lib.types.nullOr lib.types.path;
        description = ''
          This file can be used to store some or all of the options given to the
          commandline client.
          Each line in the file option should be of the format --option=value.
          The options in this file take precedence over the options provided
          through command line arguments.
          <link xlink:href="https://duplicati.readthedocs.io/en/latest/06-advanced-options/#parameters-file">Duplicati docs: parameters-file</link>
        '';
      };
    };
  };

  config = lib.mkIf cfg.enable {
    environment.systemPackages = [ cfg.package ];

    assertions = [
      {
        assertion = !(cfg.parametersFile != null && cfg.parameters != "");
        message = "cannot set both services.duplicati.parameters and services.duplicati.parametersFile at the same time";
      }
    ];

    systemd.services.duplicati = {
      description = "Duplicati backup";
      after = [ "network.target" ];
@@ -67,7 +109,7 @@ in
        {
          User = cfg.user;
          Group = "duplicati";
          ExecStart = "${cfg.package}/bin/duplicati-server --webservice-interface=${cfg.interface} --webservice-port=${toString cfg.port} --server-datafolder=${cfg.dataDir}";
          ExecStart = "${cfg.package}/bin/duplicati-server --webservice-interface=${cfg.interface} --webservice-port=${toString cfg.port} --server-datafolder=${cfg.dataDir} --parameters-file=${parametersFile}";
          Restart = "on-failure";
        }
        (lib.mkIf (cfg.dataDir == "/var/lib/duplicati") {
+49 −23
Original line number Diff line number Diff line
@@ -2,44 +2,70 @@
  lib,
  stdenv,
  fetchzip,
  mono,
  sqlite,
  makeWrapper,
  autoPatchelfHook,
  gcc-unwrapped,
  zlib,
  lttng-ust_2_12,
  icu,
  openssl,
  makeBinaryWrapper,
}:

let
  _supportedPlatforms = {
    "armv7l-linux" = "linux-arm7";
    "x86_64-linux" = "linux-x64";
    "aarch64-linux" = "linux-arm64";
  };
  _platform = _supportedPlatforms."${stdenv.hostPlatform.system}";
  # nix hash convert --to sri "sha256:`nix-prefetch-url --unpack https://updates.duplicati.com/stable/duplicati-2.1.0.5_stable_2025-03-04-linux-arm64-cli.zip`"
  _fileHashForSystem = {
    "armv7l-linux" = "sha256-FQQ07M0rwvxNkHPW6iK5WBTKgFrZ4LOP4vgINfmtq4k=";
    "x86_64-linux" = "sha256-1QspF/A3hOtqd8bVbSqClJIHUN9gBrd18J5qvZJLkQE=";
    "aarch64-linux" = "sha256-mSNInaCkNf1MBZK2M42SjJnYRtB5SyGMvSGSn5oH1Cs=";
  };
in
stdenv.mkDerivation (finalAttrs: {
  # TODO build duplicati from source https://github.com/duplicati/duplicati/blob/master/.github/workflows/build-packages.yml
  pname = "duplicati";
  version = "2.1.0.2";
  channel = "beta";
  build_date = "2024-11-29";
  version = "2.1.0.5";
  channel = "stable";
  buildDate = "2025-03-04";

  src = fetchzip {
    url =
      with finalAttrs;
      "https://github.com/duplicati/duplicati/releases/download/v${version}-${version}_${channel}_${build_date}/duplicati-${version}_${channel}_${build_date}.zip";
    hash = "sha256-LmW6yGutxP33ghFqyOLKrGDNCQdr8DDFn/IHigsLpzA=";
    stripRoot = false;
      "https://updates.duplicati.com/stable/duplicati-${version}_${channel}_${buildDate}-${_platform}-cli.zip";
    hash = _fileHashForSystem."${stdenv.hostPlatform.system}";
    stripRoot = true;
  };

  nativeBuildInputs = [ makeWrapper ];
  nativeBuildInputs = [
    autoPatchelfHook
    makeBinaryWrapper
  ];
  buildInputs = [
    gcc-unwrapped
    zlib
    lttng-ust_2_12
  ];

  installPhase = ''
    mkdir -p $out/{bin,share/duplicati-${finalAttrs.version}}
    cp -r * $out/share/duplicati-${finalAttrs.version}
    makeWrapper "${lib.getExe mono}" $out/bin/duplicati-cli \
      --add-flags "$out/share/duplicati-${finalAttrs.version}/Duplicati.CommandLine.exe" \
      --prefix LD_LIBRARY_PATH : ${
        lib.makeLibraryPath [
          sqlite
        ]
      }
    makeWrapper "${lib.getExe mono}" $out/bin/duplicati-server \
      --add-flags "$out/share/duplicati-${finalAttrs.version}/Duplicati.Server.exe" \
    runHook preInstall

    mkdir -p $out/{bin,share}
    cp -r * "$out/share/"
    for file in $out/share/duplicati-*; do
      makeBinaryWrapper "$file" "$out/bin/$(basename $file)" \
      --prefix LD_LIBRARY_PATH : ${
        lib.makeLibraryPath [
          sqlite
          icu
          openssl
        ]
      }
    done

    runHook postInstall
  '';

  meta = {
@@ -51,6 +77,6 @@ stdenv.mkDerivation (finalAttrs: {
      bot-wxt1221
    ];
    sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
    platforms = lib.platforms.all;
    platforms = builtins.attrNames _supportedPlatforms;
  };
})