Unverified Commit 110489e1 authored by adisbladis's avatar adisbladis Committed by GitHub
Browse files

Merge pull request #243373 from adisbladis/pict-rs_0_4

pict-rs: 0.3.3 -> 0.4.0
parents dee09dee 4d790c7c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -72,6 +72,8 @@

- `services.lemmy.settings.federation` was removed in 0.17.0 and no longer has any effect. To enable federation, the hostname must be set in the configuration file and then federation must be enabled in the admin web UI. See the [release notes](https://github.com/LemmyNet/lemmy/blob/c32585b03429f0f76d1e4ff738786321a0a9df98/RELEASES.md#upgrade-instructions) for more details.

- `pict-rs` was upgraded from 0.3 to 0.4 and contains an incompatible database & configuration change. To upgrade on systems with `stateVersion = "23.05";` or older follow the migration steps from https://git.asonix.dog/asonix/pict-rs#user-content-0-3-to-0-4-migration-guide and set `services.pict-rs.package = pkgs.pict-rs;`.

- The following packages in `haskellPackages` have now a separate bin output: `cabal-fmt`, `calligraphy`, `eventlog2html`, `ghc-debug-brick`, `hindent`, `nixfmt`, `releaser`. This means you need to replace e.g. `"${pkgs.haskellPackages.nixfmt}/bin/nixfmt"` with `"${lib.getBin pkgs.haskellPackages.nixfmt}/bin/nixfmt"` or `"${lib.getExe pkgs.haskellPackages.nixfmt}"`. The binaries also won’t be in scope if you rely on them being installed e.g. via `ghcWithPackages`. `environment.packages` picks the `bin` output automatically, so for normal installation no intervention is required. Also, toplevel attributes like `pkgs.nixfmt` are not impacted negatively by this change.

- `spamassassin` no longer supports the `Hashcash` module. The module needs to be removed from the `loadplugin` list if it was copied over from the default `initPreConf` option.
+65 −7
Original line number Diff line number Diff line
{ lib, pkgs, config, ... }:
with lib;

let
  cfg = config.services.pict-rs;
  inherit (lib) maintainers mkOption types;

  is03 = lib.versionOlder cfg.package.version "0.4.0";

in
{
  meta.maintainers = with maintainers; [ happysalada ];
  meta.doc = ./pict-rs.md;

  options.services.pict-rs = {
    enable = mkEnableOption (lib.mdDoc "pict-rs server");
    enable = lib.mkEnableOption (lib.mdDoc "pict-rs server");

    package = mkOption {
      type = types.package;
      example = lib.literalExpression "pkgs.pict-rs";
      description = lib.mdDoc ''
        pict-rs package to use.
      '';
    };

    dataDir = mkOption {
      type = types.path;
      default = "/var/lib/pict-rs";
      description = lib.mdDoc ''
        The directory where to store the uploaded images & database.
      '';
    };

    repoPath = mkOption {
      type = types.nullOr (types.path);
      default = null;
      description = lib.mdDoc ''
        The directory where to store the database.
        This option takes precedence over dataDir.
      '';
    };

    storePath = mkOption {
      type = types.nullOr (types.path);
      default = null;
      description = lib.mdDoc ''
        The directory where to store the uploaded images.
        This option takes precedence over dataDir.
      '';
    };

    address = mkOption {
      type = types.str;
      default = "127.0.0.1";
@@ -23,6 +55,7 @@ in
        The IPv4 address to deploy the service to.
      '';
    };

    port = mkOption {
      type = types.port;
      default = 8080;
@@ -31,18 +64,43 @@ in
      '';
    };
  };

  config = lib.mkIf cfg.enable {
    services.pict-rs.package = lib.mkDefault (
      # An incompatible db change happened in the transition from 0.3 to 0.4.
      if lib.versionAtLeast config.system.stateVersion "23.11"
      then pkgs.pict-rs
      else pkgs.pict-rs_0_3
    );

    # Account for config differences between 0.3 and 0.4
    assertions = [
      {
        assertion = !is03 || (cfg.repoPath == null && cfg.storePath == null);
        message = ''
          Using `services.pict-rs.repoPath` or `services.pict-rs.storePath` with pict-rs 0.3 or older has no effect.
        '';
      }
    ];

    systemd.services.pict-rs = {
      environment = {
      # Pict-rs split it's database and image storage paths in 0.4.0.
      environment =
        if is03 then {
          PICTRS__PATH = cfg.dataDir;
          PICTRS__ADDR = "${cfg.address}:${toString cfg.port}";
        } else {
          PICTRS__REPO__PATH = if cfg.repoPath != null then cfg.repoPath else "${cfg.dataDir}/sled-repo";
          PICTRS__STORE__PATH = if cfg.storePath != null then cfg.storePath else "${cfg.dataDir}/files";
          PICTRS__SERVER__ADDR = "${cfg.address}:${toString cfg.port}";
        };
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        DynamicUser = true;
        StateDirectory = "pict-rs";
        ExecStart = "${pkgs.pict-rs}/bin/pict-rs";
        ExecStart = if is03 then "${lib.getBin cfg.package}/bin/pict-rs" else "${lib.getBin cfg.package}/bin/pict-rs run";
      };
    };
  };

}
+53 −0
Original line number Diff line number Diff line
{ stdenv
, lib
, fetchFromGitea
, rustPlatform
, makeWrapper
, protobuf
, Security
, imagemagick
, ffmpeg
, exiftool
, nixosTests
}:

rustPlatform.buildRustPackage rec {
  pname = "pict-rs";
  version = "0.3.3";

  src = fetchFromGitea {
    domain = "git.asonix.dog";
    owner = "asonix";
    repo = pname;
    rev = "v${version}";
    sha256 = "mEZBFDR+/aMRFw54Yq+f1gyEz8H+5IggNCpzv3UdDFg=";
  };

  cargoLock = {
    lockFile = ./Cargo-0.3.lock;
    outputHashes = {
      "aws-creds-0.29.1" = "bwDFmDPThMLrpaB7cAj/2/vJKhbX6/DqgcIRBVKSZhg=";
    };
  };

  # needed for internal protobuf c wrapper library
  PROTOC = "${protobuf}/bin/protoc";
  PROTOC_INCLUDE = "${protobuf}/include";

  nativeBuildInputs = [ makeWrapper ];
  buildInputs = lib.optionals stdenv.isDarwin [ Security ];

  postInstall = ''
    wrapProgram "$out/bin/pict-rs" \
        --prefix PATH : "${lib.makeBinPath [ imagemagick ffmpeg exiftool ]}"
  '';

  passthru.tests = { inherit (nixosTests) pict-rs; };

  meta = with lib; {
    description = "A simple image hosting service";
    homepage = "https://git.asonix.dog/asonix/pict-rs";
    license = with licenses; [ agpl3Plus ];
    maintainers = with maintainers; [ happysalada ];
  };
}
+3 −8
Original line number Diff line number Diff line
@@ -13,22 +13,17 @@

rustPlatform.buildRustPackage rec {
  pname = "pict-rs";
  version = "0.3.3";
  version = "0.4.0";

  src = fetchFromGitea {
    domain = "git.asonix.dog";
    owner = "asonix";
    repo = pname;
    rev = "v${version}";
    sha256 = "mEZBFDR+/aMRFw54Yq+f1gyEz8H+5IggNCpzv3UdDFg=";
    sha256 = "sha256-1WNd7Ei21g01S5ko6y+uyhHP+xlGtnrwU8MLMxnW3P8=";
  };

  cargoLock = {
    lockFile = ./Cargo.lock;
    outputHashes = {
      "aws-creds-0.29.1" = "bwDFmDPThMLrpaB7cAj/2/vJKhbX6/DqgcIRBVKSZhg=";
    };
  };
  cargoHash = "sha256-xD2LvB0xBDAShp4k4VnnhnOWowhU/0OKvkEzI6RzuJY=";

  # needed for internal protobuf c wrapper library
  PROTOC = "${protobuf}/bin/protoc";
Loading