Skip to content

Commit

Permalink
Merge pull request #426 from docspell/nix-module-update
Browse files Browse the repository at this point in the history
Update nix module to new options
  • Loading branch information
eikek authored Feb 5, 2024
2 parents 36295fe + ad701c8 commit 28dd54e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 50 deletions.
29 changes: 19 additions & 10 deletions nix/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ in
default = false;
description = "Whether to upload to the integration endpoint.";
};
header-file = mkOption {
type = types.nullOr types.path;
default = null;
description = "A file containing the `header:value` pair for the integration endpoint.";
};
basic-file = mkOption {
type = types.nullOr types.path;
default = null;
description = "A file containing the `user:password` pair for the integration endpoint.";
};
header = mkOption {
type = types.nullOr types.str;
default = null;
Expand Down Expand Up @@ -116,16 +126,15 @@ in
args = (if cfg.recursive then [ "-r" ] else [ ]) ++
(if cfg.delete-files then [ "--delete" ] else [ ]) ++
(if cfg.integration-endpoint.enabled then [ "-i" ] else [ ]) ++
(if cfg.integration-endpoint.header != null
then
[ "--header" "'${cfg.integration-endpoint.header}'" ]
else
[ ]) ++
(if cfg.integration-endpoint.basic != null
then
[ "--basic" "'${cfg.integration-endpoint.basic}'" ]
else
[ ]) ++
(if cfg.integration-endpoint.header-file != null
then [ "--header-file" "'${cfg.integration-endpoint.header-file}'" ]
else if cfg.integration-endpoint.basic-file != null
then [ "--basic-file" "'${cfg.integration-endpoint.basic-file}'" ]
else if cfg.integration-endpoint.header != null
then [ "--header" "'${cfg.integration-endpoint.header}'" ]
else if cfg.integration-endpoint.basic != null
then [ "--basic" "'${cfg.integration-endpoint.basic}'" ]
else [ ]) ++
(if cfg.include-filter != null then
[ "--matches" "'${toString cfg.include-filter}'" ]
else [ ]) ++
Expand Down
48 changes: 8 additions & 40 deletions nix/nixosConfigurations/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
let
full-text-search = {
enabled = true;
solr.url = "http://localhost:${toString config.services.solr.port}/solr/docspell";
backend = "postgresql";
postgresql = {
pg-config = {
"german" = "my-germam";
Expand Down Expand Up @@ -43,7 +43,7 @@ in
# Docspell
{ from = "host"; host.port = 64080; guest.port = 7880; }
];
system.stateVersion = "22.11";
system.stateVersion = "23.11";
# This slows down the build of a vm
documentation.enable = false;

Expand All @@ -64,16 +64,20 @@ in
watchDir # Note, dsc expects files to be in a subdirectory corresponding to a collective. There is no way to declaratively create a collective as of the time of writing
];
integration-endpoint =
let
headerFile = pkgs.writeText "int-header-file" ''
Docspell-Integration:${integrationHeaderValue}
'';
in
{
enabled = true;
header = "Docspell-Integration:${integrationHeaderValue}";
header-file = headerFile;
};
};

# Docspell service configuration and its requirements
services.docspell-joex = {
enable = true;
waitForTarget = "solr-init.target";
bind.address = "0.0.0.0";
base-url = "http://localhost:7878";
jvmArgs = [ "-J-Xmx1536M" ];
Expand Down Expand Up @@ -108,40 +112,4 @@ in
};
};
};
nixpkgs.config = {
permittedInsecurePackages = [
"solr-8.6.3"
];
};

services.solr = {
enable = true;
};
# This is needed to run solr script as user solr
users.users.solr.useDefaultShell = true;

systemd.services.solr-init =
let
solrPort = toString config.services.solr.port;
initSolr = ''
if [ ! -f ${config.services.solr.stateDir}/docspell_core ]; then
while ! echo "" | ${pkgs.inetutils}/bin/telnet localhost ${solrPort}
do
echo "Waiting for SOLR become ready..."
sleep 1.5
done
${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh solr -c "${pkgs.solr}/bin/solr create_core -c docspell -p ${solrPort}";
touch ${config.services.solr.stateDir}/docspell_core
fi
'';
in
{
script = initSolr;
after = [ "solr.target" ];
wantedBy = [ "multi-user.target" ];
requires = [ "solr.target" ];
description = "Create a core at solr";
};


}

0 comments on commit 28dd54e

Please sign in to comment.