1 { lib, pkgs, config, ... }:
4 cfg = config.services.pict-rs;
5 inherit (lib) maintainers mkOption types;
8 meta.maintainers = with maintainers; [ happysalada ];
9 meta.doc = ./pict-rs.md;
11 options.services.pict-rs = {
12 enable = lib.mkEnableOption "pict-rs server";
14 package = lib.mkPackageOption pkgs "pict-rs" { };
18 default = "/var/lib/pict-rs";
20 The directory where to store the uploaded images & database.
25 type = types.nullOr (types.path);
28 The directory where to store the database.
29 This option takes precedence over dataDir.
33 storePath = mkOption {
34 type = types.nullOr (types.path);
37 The directory where to store the uploaded images.
38 This option takes precedence over dataDir.
44 default = "127.0.0.1";
46 The IPv4 address to deploy the service to.
54 The port which to bind the service to.
59 config = lib.mkIf cfg.enable {
60 services.pict-rs.package = lib.mkDefault (
61 if lib.versionAtLeast config.system.stateVersion "23.11"
64 pict-rs made changes to the database schema between 0.3 and 0.4. It
65 will apply these automatically on the first run of 0.4, but the old
66 version will no longer work after that.
68 Your configuration is currently using the old default of pict-rs
69 0.3. Unfortunately, 0.3 no longer builds due to the Rust 1.80 update,
70 and has been removed. pict-rs has already been updated to 0.5 in
71 Nixpkgs, which has another schema change but removes the migration
74 You will need to migrate to 0.4 first, and then to 0.5. As 0.4 is
75 no longer present in Nixpkgs, the recommended migration path is:
77 * Import a separate Nixpkgs old enough to contain 0.4, temporarily
78 set `services.pict-rs.package` to its pict-rs, set the
79 `PICTRS__OLD_DB__PATH` environment variable for the migration, and
80 activate your configuration to start it. The following configuration
83 services.pict-rs.package =
84 (import (builtins.fetchTarball {
85 url = "https://github.com/NixOS/nixpkgs/archive/9b19f5e77dd906cb52dade0b7bd280339d2a1f3d.tar.gz";
86 sha256 = "sha256:0939vbhln9d33xkqw63nsk908k03fxihj85zaf70i3il9z42q8mc";
87 }) pkgs.config).pict-rs;
89 systemd.services.pict-rs.environment.PICTRS__OLD_DB__PATH = config.services.pict-rs.dataDir;
91 * After the migration to 0.4 completes, remove the package and
92 environment variable overrides, set `services.pict-rs.package` to
93 the current `pkgs.pict-rs` instead, and activate your configuration
94 to begin the migration to 0.5.
96 For more information, see:
98 * <https://git.asonix.dog/asonix/pict-rs/src/tag/v0.4.8#0-3-to-0-4-migration-guide>
99 * <https://git.asonix.dog/asonix/pict-rs/src/tag/v0.5.16#0-4-to-0-5-migration-guide>
101 The NixOS module will handle the configuration changes for you,
106 systemd.services.pict-rs = {
108 PICTRS__REPO__PATH = if cfg.repoPath != null then cfg.repoPath else "${cfg.dataDir}/sled-repo";
109 PICTRS__STORE__PATH = if cfg.storePath != null then cfg.storePath else "${cfg.dataDir}/files";
110 PICTRS__SERVER__ADDRESS = "${cfg.address}:${toString cfg.port}";
112 wantedBy = [ "multi-user.target" ];
115 StateDirectory = "pict-rs";
116 ExecStart = "${lib.getBin cfg.package}/bin/pict-rs run";