diff options
-rw-r--r-- | nixos/doc/manual/release-notes/rl-2311.section.md | 2 | ||||
-rw-r--r-- | nixos/modules/services/web-apps/pict-rs.nix | 72 | ||||
-rw-r--r-- | pkgs/servers/web-apps/pict-rs/0.3.nix | 53 | ||||
-rw-r--r-- | pkgs/servers/web-apps/pict-rs/Cargo-0.3.lock (renamed from pkgs/servers/web-apps/pict-rs/Cargo.lock) | 0 | ||||
-rw-r--r-- | pkgs/servers/web-apps/pict-rs/default.nix | 11 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 5 |
6 files changed, 128 insertions, 15 deletions
diff --git a/nixos/doc/manual/release-notes/rl-2311.section.md b/nixos/doc/manual/release-notes/rl-2311.section.md index 2998256f51893..8cb00f1407ee1 100644 --- a/nixos/doc/manual/release-notes/rl-2311.section.md +++ b/nixos/doc/manual/release-notes/rl-2311.section.md @@ -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. diff --git a/nixos/modules/services/web-apps/pict-rs.nix b/nixos/modules/services/web-apps/pict-rs.nix index 3270715a051ba..e1b8c83335536 100644 --- a/nixos/modules/services/web-apps/pict-rs.nix +++ b/nixos/modules/services/web-apps/pict-rs.nix @@ -1,21 +1,53 @@ { 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 = { - PICTRS__PATH = cfg.dataDir; - PICTRS__ADDR = "${cfg.address}:${toString cfg.port}"; - }; + # 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"; }; }; }; + } diff --git a/pkgs/servers/web-apps/pict-rs/0.3.nix b/pkgs/servers/web-apps/pict-rs/0.3.nix new file mode 100644 index 0000000000000..c113322a37947 --- /dev/null +++ b/pkgs/servers/web-apps/pict-rs/0.3.nix @@ -0,0 +1,53 @@ +{ 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 ]; + }; +} diff --git a/pkgs/servers/web-apps/pict-rs/Cargo.lock b/pkgs/servers/web-apps/pict-rs/Cargo-0.3.lock index c5618b62d4200..c5618b62d4200 100644 --- a/pkgs/servers/web-apps/pict-rs/Cargo.lock +++ b/pkgs/servers/web-apps/pict-rs/Cargo-0.3.lock diff --git a/pkgs/servers/web-apps/pict-rs/default.nix b/pkgs/servers/web-apps/pict-rs/default.nix index 6629477fae23d..30d9c002ca3cd 100644 --- a/pkgs/servers/web-apps/pict-rs/default.nix +++ b/pkgs/servers/web-apps/pict-rs/default.nix @@ -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"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c4d3bfacf9569..fe4835e3267dc 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -26335,6 +26335,11 @@ with pkgs; ffmpeg = ffmpeg_4; }; + pict-rs_0_3 = callPackage ../servers/web-apps/pict-rs/0.3.nix { + inherit (darwin.apple_sdk.frameworks) Security; + ffmpeg = ffmpeg_4; + }; + popa3d = callPackage ../servers/mail/popa3d { }; postfix = callPackage ../servers/mail/postfix { }; |