forked from lamka02sk/picturium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
136 lines (125 loc) · 4.52 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{
description = "picturium - a lightweight thumbnail server";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
picturium = pkgs.rustPlatform.buildRustPackage {
pname = "picturium";
version = "0.1.1";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = { };
};
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ vips ];
doCheck = false;
meta = with pkgs.lib; {
description = "picturium - a lightweight thumbnail server";
};
};
in {
packages.default = picturium;
nixosModules.picturium = { lib, ... }: {
options = {
services.picturium = with lib; {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable the Picturium service.";
};
log = mkOption {
type = types.str;
default = "info";
description = "Log level for Picturium. (debug, info, warn, error)";
};
host = mkOption {
type = types.str;
default = "127.0.0.1";
description = "Host for Picturium.";
};
port = mkOption {
type = types.int;
default = 20045;
description = "Port for Picturium.";
};
cors = mkOption {
type = types.str;
default = "";
description = "CORS settings for Picturium.";
};
secret_key = mkOption {
type = types.str;
default = "";
description = "A secret string used for HMAC verification in requests. Must be a secure, random string (e.g., 32+ chars)";
};
avifEnable = mkOption {
type = types.bool;
default = true;
description = "Enable AVIF support in Picturium.";
};
cache = mkOption {
type = types.str;
default = "/var/cache/picturium";
description = "Cache directory for Picturium.";
};
cacheEnable = mkOption {
type = types.bool;
default = true;
description = "Enable caching in Picturium.";
};
cacheCapacity = mkOption {
type = types.int;
default = 10;
description = "Cache capacity for Picturium.";
};
dataDir = mkOption {
type = types.str;
default = "/var/lib/picturium/data";
description = "Data directory for Picturium.";
};
};
};
config = { config, pkgs, ... }: {
systemd.services.picturium = {
description = "Picturium Thumbnail Service";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${pkgs.picturium}/bin/picturium";
Environment = [
"LOG=${config.services.picturium.log}"
"HOST=${config.services.picturium.host}"
"PORT=${config.services.picturium.port}"
"CORS=${config.services.picturium.cors}"
"KEY=${config.services.picturium.secret_key}"
"AVIF_ENABLE=${config.services.picturium.avifEnable}"
"CACHE=${config.services.picturium.cache}"
"CACHE_ENABLE=${config.services.picturium.cacheEnable}"
"CACHE_CAPACITY=${config.services.picturium.cacheCapacity}"
"DATA_DIR=${config.services.picturium.dataDir}"
"MPV=${pkgs.mpv}/bin/mpv"
];
};
};
};
};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
rustc
cargo
rustfmt
clippy
rust-analyzer
pkg-config
vips
];
LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.libexif}/lib";
};
});
}