3 Commits

Author SHA1 Message Date
e66070383f flake: Improve service preStart 2025-01-07 22:42:59 +03:00
438cd3d86f flake: Improve service preStart 2025-01-07 22:40:48 +03:00
0cf9b85787 flake: use enum for mode option 2025-01-07 22:15:08 +03:00

View File

@@ -77,7 +77,7 @@
''; '';
}; };
mode = mkOption { mode = mkOption {
type = types.str; type = types.enum [ "hardlink" "symlink" "move" "copy" ];
default = "hardlink"; default = "hardlink";
description = '' description = ''
Organization mode, one of [ hardlink symlink move copy ]. Organization mode, one of [ hardlink symlink move copy ].
@@ -100,10 +100,11 @@
wantedBy = [ wantedBy = [
"default.target" "default.target"
]; ];
preStart = if !sync.skipFullSync then ('' preStart = ''
mkdir -p ${sync.target} mkdir -p ${sync.target}
'' + (if !sync.skipFullSync then (''
photocatalog -source ${sync.source} -target ${sync.target} -mode ${sync.mode} ${if sync.overwrite then "-overwrite" else ""} photocatalog -source ${sync.source} -target ${sync.target} -mode ${sync.mode} ${if sync.overwrite then "-overwrite" else ""}
'') else null; '') else null);
script = "photocatalog -source ${sync.source} -target ${sync.target} -skip-full-sync -watch -mode ${sync.mode} ${if sync.overwrite then "-overwrite" else ""}"; script = "photocatalog -source ${sync.source} -target ${sync.target} -skip-full-sync -watch -mode ${sync.mode} ${if sync.overwrite then "-overwrite" else ""}";
serviceConfig = { serviceConfig = {
Type="simple"; Type="simple";