Update nix setup

Removes the consumedir module, use the module in the dsc project [0]
instead.

[0] https://github.com/docspell/dsc/blob/master/nix/module.nix
This commit is contained in:
eikek 2021-08-28 12:52:43 +02:00
parent be510b0363
commit 5cc2ad92a2
4 changed files with 14 additions and 177 deletions

View File

@ -50,19 +50,9 @@ in
};
inherit full-text-search;
};
services.docspell-consumedir = {
enable = true;
integration-endpoint = {
enabled = true;
header = "Docspell-Integration:test123";
};
watchDirs = ["/tmp/docs"];
urls = ["http://localhost:7880/api/v1/open/integration/item"];
};
environment.systemPackages =
[ pkgs.docspell.tools
pkgs.docspell.server
[ pkgs.docspell.server
pkgs.docspell.joex
pkgs.jq
pkgs.telnet
@ -80,11 +70,6 @@ in
firewall.allowedTCPPorts = [7880];
};
system.activationScripts = {
initUploadDir = ''
mkdir -p ${builtins.concatStringsSep " " config.services.docspell-consumedir.watchDirs}
'';
};
system.stateVersion = "20.03";
system.stateVersion = "21.05";
}

View File

@ -1,129 +0,0 @@
{config, lib, pkgs, ...}:
with lib;
let
cfg = config.services.docspell-consumedir;
user = if cfg.runAs == null then "docspell-consumedir" else cfg.runAs;
in {
## interface
options = {
services.docspell-consumedir = {
enable = mkOption {
default = false;
description = "Whether to enable docspell consume directory.";
};
runAs = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
The user that runs the consumedir process.
'';
};
watchDirs = mkOption {
type = types.listOf types.str;
description = "The directories to watch for new files.";
};
verbose = mkOption {
type = types.bool;
default = false;
description = "Run in verbose mode";
};
deleteFiles = mkOption {
type = types.bool;
default = false;
description = "Whether to delete successfully uploaded files.";
};
distinct = mkOption {
type = types.bool;
default = true;
description = "Check for duplicates and update only if the file is not already present.";
};
integration-endpoint = mkOption {
type = types.submodule({
options = {
enabled = mkOption {
type = types.bool;
default = false;
description = "Whether to upload to the integration endpoint.";
};
header = mkOption {
type = types.str;
default = "";
description = ''
The `header:value` string matching the configured header-name
and value for the integration endpoint.
'';
};
user = mkOption {
type = types.str;
default = "";
description = ''
The `user:password` string matching the configured user and password
for the integration endpoint. Since both are separated by a colon, the
user name may not contain a colon (the password can).
'';
};
};
});
default = {
enabled = false;
header = "";
user = "";
};
description = "Settings for using the integration endpoint.";
};
urls = mkOption {
type = types.listOf types.str;
example = [ "http://localhost:7880/api/v1/open/upload/item/abced-12345-abcde-12345" ];
description = "A list of upload urls.";
};
};
};
## implementation
config = mkIf config.services.docspell-consumedir.enable {
users.users."${user}" = mkIf (cfg.runAs == null) {
name = user;
isSystemUser = true;
description = "Docspell consumedir user";
};
systemd.services.docspell-consumedir =
let
args = (builtins.concatMap (a: ["--path" ("'" + a + "'")]) cfg.watchDirs) ++
(if cfg.verbose then ["-v"] else []) ++
(if cfg.deleteFiles then ["-d"] else []) ++
(if cfg.distinct then [ "-m" ] else []) ++
(if cfg.integration-endpoint.enabled then [ "-i" ] else []) ++
(if cfg.integration-endpoint.header != ""
then
[ "--iheader" cfg.integration-endpoint.header ]
else
[]) ++
(if cfg.integration-endpoint.user != ""
then
[ "--iuser" cfg.integration-endpoint.user ]
else
[]) ++
(map (a: "'" + a + "'") cfg.urls);
cmd = "${pkgs.docspell.tools}/bin/ds-consumedir " + (builtins.concatStringsSep " " args);
in
{
description = "Docspell Consumedir";
after = [ "networking.target" ];
wantedBy = [ "multi-user.target" ];
path = [ pkgs.utillinux pkgs.curl pkgs.coreutils ];
script =
"${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${user} -c \"${cmd}\"";
};
};
}

View File

@ -51,32 +51,4 @@ in
inherit meta;
};
tools = stdenv.mkDerivation {
name = "docspell-tools-${cfg.version}";
src = fetchzip cfg.tools;
buildPhase = "true";
installPhase = ''
mkdir -p $out/bin
cp $src/ds.sh $out/bin/ds
sed -i 's,CURL_CMD="curl",CURL_CMD="${curl}/bin/curl",g' $out/bin/ds
while read f; do
target="ds-$(basename "$f" ".sh")"
echo "Installing $f -> $target"
cp "$f" "$out/bin/$target"
sed -i 's,CURL_CMD="curl",CURL_CMD="${curl}/bin/curl",g' $out/bin/$target
sed -i 's,INOTIFY_CMD="inotifywait",INOTIFY_CMD="${inotifyTools}/bin/inotifywait",g' $out/bin/$target
sed -i 's,JQ_CMD="jq",JQ_CMD="${jq}/bin/jq",g' $out/bin/$target
sed -i 's,SQLITE_CMD="sqlite3",SQLITE_CMD="${sqlite}/bin/sqlite3",g' $out/bin/$target
done < <(find . -name "*.sh" -mindepth 2 -not -path "*webextension*")
chmod 755 $out/bin/*
'';
inherit meta;
};
}

View File

@ -1,5 +1,16 @@
rec {
cfg = {
v0_26_0 = rec {
version = "0.26.0";
server = {
url = "https://github.com/eikek/docspell/releases/download/v${version}/docspell-restserver-${version}.zip";
sha256 = "1wdjqxyg5d2zjfsw7gnjbsh6wyw300yd83vgy60yffdm1rishlgl";
};
joex = {
url = "https://github.com/eikek/docspell/releases/download/v${version}/docspell-joex-${version}.zip";
sha256 = "1d66nspsnlha9hc84mcycsds3r8d4q9grgnvg8vcykd7z9jaak7i";
};
};
v0_25_1 = rec {
version = "0.25.1";
server = {
@ -107,12 +118,10 @@ rec {
};
};
pkg = v: import ./pkg.nix v;
currentPkg = pkg cfg.v0_25_1;
currentPkg = pkg cfg.v0_26_0;
module-joex = ./module-joex.nix;
module-restserver = ./module-server.nix;
module-consumedir = ./module-consumedir.nix;
modules = [ module-joex
module-restserver
module-consumedir
];
}