Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 47 additions & 26 deletions nixos/modules/services/web-apps/pict-rs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
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 ];
Expand Down Expand Up @@ -61,38 +58,62 @@ 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
);
else throw ''
pict-rs made changes to the database schema between 0.3 and 0.4. It
will apply these automatically on the first run of 0.4, but the old
version will no longer work after that.

Your configuration is currently using the old default of pict-rs
0.3. Unfortunately, 0.3 no longer builds due to the Rust 1.80 update,
and has been removed. pict-rs has already been updated to 0.5 in
Nixpkgs, which has another schema change but removes the migration
logic for 0.3.

You will need to migrate to 0.4 first, and then to 0.5. As 0.4 is
no longer present in Nixpkgs, the recommended migration path is:

* Import a separate Nixpkgs old enough to contain 0.4, temporarily
set `services.pict-rs.package` to its pict-rs, set the
`PICTRS__OLD_DB__PATH` environment variable for the migration, and
activate your configuration to start it. The following configuration
snippet should work:

services.pict-rs.package =
(import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/9b19f5e77dd906cb52dade0b7bd280339d2a1f3d.tar.gz";
sha256 = "sha256:0939vbhln9d33xkqw63nsk908k03fxihj85zaf70i3il9z42q8mc";
}) pkgs.config).pict-rs;

# 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__OLD_DB__PATH = config.services.pict-rs.dataDir;

* After the migration to 0.4 completes, remove the package and
environment variable overrides, set `services.pict-rs.package` to
the current `pkgs.pict-rs` instead, and activate your configuration
to begin the migration to 0.5.

For more information, see:

* <https://git.asonix.dog/asonix/pict-rs/src/tag/v0.4.8#0-3-to-0-4-migration-guide>
* <https://git.asonix.dog/asonix/pict-rs/src/tag/v0.5.16#0-4-to-0-5-migration-guide>

The NixOS module will handle the configuration changes for you,
at least.
''
);

systemd.services.pict-rs = {
# 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}";
};
environment = {
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__ADDRESS = "${cfg.address}:${toString cfg.port}";
};
wantedBy = [ "multi-user.target" ];
serviceConfig = {
DynamicUser = true;
StateDirectory = "pict-rs";
ExecStart = if is03 then "${lib.getBin cfg.package}/bin/pict-rs" else "${lib.getBin cfg.package}/bin/pict-rs run";
ExecStart = "${lib.getBin cfg.package}/bin/pict-rs run";
};
};
};
Expand Down
1 change: 1 addition & 0 deletions pkgs/top-level/aliases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ mapAliases ({
picom-allusive = throw "picom-allusive was renamed to compfy and is being abandoned by upstream"; # Added 2024-02-13
picom-jonaburg = throw "picom-jonaburg was removed because it is unmaintained by upstream"; # Added 2024-02-13
picom-next = picom; # Added 2024-02-13
pict-rs_0_3 = throw "pict-rs_0_3 has been removed, as it was an outdated version and no longer compiled"; # Added 2024-08-20

# Obsolete PHP version aliases
php80 = throw "php80 has been dropped due to the lack of maintenance from upstream for future releases"; # Added 2023-06-21
Expand Down
5 changes: 0 additions & 5 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25417,11 +25417,6 @@ with pkgs;

pict-rs = callPackage ../servers/web-apps/pict-rs { };

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 { };
Expand Down