-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces the ability to install Docspell from a Nix flake. There are no major changes to the logic of the previous modules outside of organizing them in a flake and adding a simple check script.
- Loading branch information
1 parent
1d39b5c
commit 562c482
Showing
8 changed files
with
2,887 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ config, pkgs, ... }: | ||
let | ||
full-text-search = { | ||
enabled = true; | ||
solr.url = "http://localhost:${toString config.services.solr.port}/solr/docspell"; | ||
postgresql = { | ||
pg-config = { | ||
"german" = "my-germam"; | ||
}; | ||
}; | ||
}; | ||
in | ||
{ | ||
|
||
i18n = { | ||
defaultLocale = "en_US.UTF-8"; | ||
}; | ||
console.keyMap = "de"; | ||
|
||
users.users.root = { | ||
password = "root"; | ||
}; | ||
|
||
|
||
services.docspell-joex = { | ||
enable = true; | ||
waitForTarget = "solr-init.target"; | ||
bind.address = "0.0.0.0"; | ||
base-url = "http://localhost:7878"; | ||
jvmArgs = [ "-J-Xmx1536M" ]; | ||
inherit full-text-search; | ||
}; | ||
services.docspell-restserver = { | ||
enable = true; | ||
bind.address = "0.0.0.0"; | ||
backend = { | ||
addons.enabled = true; | ||
}; | ||
integration-endpoint = { | ||
enabled = true; | ||
http-header = { | ||
enabled = true; | ||
header-value = "test123"; | ||
}; | ||
}; | ||
openid = [ | ||
{ | ||
enabled = true; | ||
display = "Local"; | ||
provider = { | ||
provider-id = "local"; | ||
client-id = "cid1"; | ||
client-secret = "csecret-1"; | ||
authorize-url = "http://auth"; | ||
token-url = "http://token"; | ||
sign-key = "b64:uiaeuae"; | ||
}; | ||
} | ||
]; | ||
inherit full-text-search; | ||
}; | ||
|
||
environment.systemPackages = | ||
[ | ||
pkgs.docspell.server | ||
pkgs.docspell.joex | ||
pkgs.jq | ||
pkgs.telnet | ||
pkgs.htop | ||
pkgs.openjdk | ||
]; | ||
|
||
|
||
services.xserver = { | ||
enable = false; | ||
}; | ||
|
||
networking = { | ||
hostName = "docspelltest"; | ||
firewall.allowedTCPPorts = [ 7880 ]; | ||
}; | ||
|
||
system.stateVersion = "21.05"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ ... }: | ||
{ | ||
imports = [ | ||
./configuration-test.nix | ||
./solr.nix | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ config, pkgs, ... }: | ||
|
||
# This module sets up solr with one core. It is a bit tedious…. If you | ||
# know a better solution, please let me know. | ||
{ | ||
|
||
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.telnet}/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"; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
with subtest("services are up"): | ||
machine.wait_for_unit("docspell-restserver") | ||
machine.wait_for_unit("docspell-joex") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
{ | ||
description = "Docspell flake"; | ||
|
||
outputs = { self, nixpkgs }: | ||
let | ||
supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; | ||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; | ||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); | ||
# Version config | ||
cfg = { | ||
v0_39_0 = rec { | ||
version = "0.39.0"; | ||
server = { | ||
url = "https://github.com/eikek/docspell/releases/download/v${version}/docspell-restserver-${version}.zip"; | ||
sha256 = "sha256-YZzYOqJzp2J5ioTT8H7qpRA3mHDRjJYNA7fUOEQWSfY="; | ||
}; | ||
joex = { | ||
url = "https://github.com/eikek/docspell/releases/download/v${version}/docspell-joex-${version}.zip"; | ||
sha256 = "sha256-6Vcuk9+JDkNAdTQd+sRLARfE+y9cbtGE8hWTTcxZk3E="; | ||
}; | ||
}; | ||
}; | ||
current_version = cfg.v0_39_0; | ||
inherit (current_version) version; | ||
in | ||
rec | ||
{ | ||
overlays.default = final: prev: { | ||
docspell-server = with final; stdenv.mkDerivation { | ||
inherit version; | ||
pname = "docspell-server"; | ||
|
||
src = fetchzip current_version.server; | ||
buildInputs = [ jdk11 ]; | ||
buildPhase = "true"; | ||
|
||
installPhase = '' | ||
mkdir -p $out/{bin,docspell-restserver-${version}} | ||
cp -R * $out/docspell-restserver-${version}/ | ||
cat > $out/bin/docspell-restserver <<-EOF | ||
#!${bash}/bin/bash | ||
$out/docspell-restserver-${version}/bin/docspell-restserver -java-home ${jdk11} "\$@" | ||
EOF | ||
chmod 755 $out/bin/docspell-restserver | ||
''; | ||
}; | ||
docspell-joex = with final; stdenv.mkDerivation rec { | ||
inherit version; | ||
|
||
pname = "docspell-joex"; | ||
|
||
src = fetchzip current_version.joex; | ||
|
||
buildInputs = [ jdk11 ]; | ||
|
||
buildPhase = "true"; | ||
|
||
installPhase = '' | ||
mkdir -p $out/{bin,docspell-joex-${version}} | ||
cp -R * $out/docspell-joex-${version}/ | ||
cat > $out/bin/docspell-joex <<-EOF | ||
#!${bash}/bin/bash | ||
$out/docspell-joex-${version}/bin/docspell-joex -java-home ${jdk11} "\$@" | ||
EOF | ||
chmod 755 $out/bin/docspell-joex | ||
''; | ||
}; | ||
|
||
}; | ||
|
||
packages = forAllSystems (system: | ||
{ | ||
default = (import nixpkgs { | ||
inherit system; | ||
overlays = [ self.overlays.default ]; | ||
}).docspell-server; | ||
}); | ||
|
||
checks = forAllSystems | ||
(system: { | ||
build = self.packages.${system}.default; | ||
|
||
test = | ||
with import (nixpkgs + "/nixos/lib/testing-python.nix") | ||
{ | ||
inherit system; | ||
}; | ||
|
||
makeTest { | ||
name = "docspell"; | ||
nodes = { | ||
client = { ... }: { | ||
imports = [ | ||
self.nixosModules.default | ||
./checks | ||
]; | ||
}; | ||
}; | ||
|
||
testScript = | ||
'' | ||
start_all() | ||
client.wait_for_unit("docspell-restserver") | ||
''; | ||
}; | ||
}); | ||
|
||
nixosModules = { | ||
default = { ... }: { | ||
imports = [ | ||
((import ./modules/server.nix) self.overlays.default) | ||
((import ./modules/joex.nix) self.overlays.default) | ||
]; | ||
}; | ||
server = ((import ./modules/server.nix) self.overlays.default); | ||
joex = ((import ./modules/joex.nix) self.overlays.default); | ||
}; | ||
|
||
|
||
# nixosModules = { | ||
# # Default module imports both server and joex | ||
# default = import ./modules; | ||
# server = import ./modules/server.nix; | ||
# joex = import ./modules/joex.nix; | ||
# }; | ||
}; | ||
} |
Oops, something went wrong.