mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-02-15 20:33:26 +00:00
nix: add user doc and pkg fixes
- Add user doc for how to use with nix/nixos - fix potential collisions in packages if both are installed via `nix-env`
This commit is contained in:
parent
c0f39d6497
commit
61bbdab8b5
@ -314,7 +314,8 @@ val microsite = project.in(file("modules/microsite")).
|
||||
fork in run := true,
|
||||
micrositeCompilingDocsTool := WithMdoc,
|
||||
mdocVariables := Map(
|
||||
"VERSION" -> version.value
|
||||
"VERSION" -> version.value,
|
||||
"PVERSION" -> version.value.replace('.', '_')
|
||||
),
|
||||
Compile/resourceGenerators += Def.task {
|
||||
val conf1 = (resourceDirectory in (restserver, Compile)).value / "reference.conf"
|
||||
|
129
modules/microsite/docs/doc/nix.md
Normal file
129
modules/microsite/docs/doc/nix.md
Normal file
@ -0,0 +1,129 @@
|
||||
---
|
||||
layout: docs
|
||||
title: Nix/NixOS
|
||||
permalink: doc/nix
|
||||
---
|
||||
|
||||
# {{ page.title }}
|
||||
|
||||
## Install via Nix
|
||||
|
||||
Docspell can be installed via the [nix](https://nixos.org/nix) package
|
||||
manager, which is available for Linux and OSX. Docspell is currently not
|
||||
part of the [nixpkgs collection](https://nixos.org/nixpkgs/), but you
|
||||
can use the derivation from this repository. This is sometimes
|
||||
referred to as [import from
|
||||
derivation](https://nixos.wiki/wiki/Import_From_Derivation).
|
||||
|
||||
For example, the `builtins.fetchTarball` function can be used to
|
||||
retrieve the files; then import the `release.nix` file:
|
||||
|
||||
``` nix
|
||||
let
|
||||
docspellsrc = builtins.fetchTarball "https://github.com/eikek/docspell/archive/master.tar.gz";
|
||||
in
|
||||
import "${docspellsrc}/nix/release.nix";
|
||||
```
|
||||
|
||||
This creates a set containing a function for creating a derivation for
|
||||
docspell. This then needs to be called like other custom packages. For
|
||||
example, in your `~/.nixpkgs/config.nix` you could write this:
|
||||
|
||||
``` nix
|
||||
let
|
||||
docspellsrc = builtins.fetchTarball "https://github.com/eikek/docspell/archive/master.tar.gz";
|
||||
docspell = import "${docspellsrc}/nix/release.nix";
|
||||
in
|
||||
{ packageOverrides = pkgs:
|
||||
let
|
||||
callPackage = pkgs.lib.callPackageWith(custom // pkgs);
|
||||
custom = {
|
||||
docspell = callPackage docspell.currentPkg {};
|
||||
};
|
||||
in custom;
|
||||
}
|
||||
```
|
||||
|
||||
The `docspell` custom package is again a set that contains derivations
|
||||
for all 3 installable docspell programs: the restserver, joex and the
|
||||
tools.
|
||||
|
||||
Then you can install docspell via `nix-shell` or `nix-env`, for example:
|
||||
|
||||
``` bash
|
||||
$ nix-env -iA nixpkgs.docspell.server nixpkgs.docspell.joex nixpkgs.docspell.tools
|
||||
```
|
||||
|
||||
You may need to replace `nixpkgs` with `nixos` when you're on NixOS.
|
||||
|
||||
The expression `docspell.currentPkg` refers to the most current release
|
||||
of Docspell. So even if you use the tarball of the current master
|
||||
branch, the `release.nix` file only contains derivations for releases.
|
||||
The expression `docspell.currentPkg` is a shortcut for selecting the
|
||||
most current release. For example it translates to `docspell.pkg
|
||||
docspell.cfg.v@PVERSION@` – if the current version is `@VERSION@`.
|
||||
|
||||
|
||||
## Docspell as a service on NixOS
|
||||
|
||||
If you are running [NixOS](https://nixos.org), there is a module
|
||||
definition for installing Docspell as a service using systemd.
|
||||
|
||||
There are the following modules provided:
|
||||
|
||||
- restserver
|
||||
- joex
|
||||
- consumedir
|
||||
|
||||
The `consumedir` module defines a systemd unit that starts the
|
||||
`consumedir.sh` script to watch one or more directories for new files.
|
||||
|
||||
You need to import the `release.nix` file as described above in your
|
||||
`configuration.nix` and then append the docspell module to your list of
|
||||
modules. Here is an example:
|
||||
|
||||
```nix
|
||||
{ config, pkgs, ... }:
|
||||
let
|
||||
docspellsrc = builtins.fetchTarball "https://github.com/eikek/docspell/archive/master.tar.gz";
|
||||
docspell = import "${docspellsrc}/nix/release.nix";
|
||||
in
|
||||
{
|
||||
imports = [ mymodule1 mymodule2 ] ++ docspell.modules;
|
||||
|
||||
nixpkgs = {
|
||||
config = {
|
||||
packageOverrides = pkgs:
|
||||
let
|
||||
callPackage = pkgs.lib.callPackageWith(custom // pkgs);
|
||||
custom = {
|
||||
docspell = callPackage docspell.currentPkg {};
|
||||
};
|
||||
in custom;
|
||||
};
|
||||
};
|
||||
|
||||
services.docspell-restserver = {
|
||||
enable = true;
|
||||
base-url = "http://docspelltest:7880";
|
||||
# ... more settings here
|
||||
};
|
||||
services.docspell-joex = {
|
||||
enable = true;
|
||||
base-url = "http://docspelltexst:7878";
|
||||
# ... more settings here
|
||||
};
|
||||
services.docspell-consumedir = {
|
||||
enable = true;
|
||||
watchDirs = ["/tmp/test"];
|
||||
urls = ["http://localhost:7880/api/v1/open/upload/item/the-source-id"];
|
||||
};
|
||||
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Please see the `nix/module-server.nix` and `nix/module-joex.nix` files
|
||||
for the set of options. The nixos options are modelled after the
|
||||
default configuration file.
|
@ -18,6 +18,9 @@ options:
|
||||
- title: Installation
|
||||
url: doc/install.html
|
||||
|
||||
- title: Nix/NixOS
|
||||
url: doc/nix
|
||||
|
||||
- title: Configuring
|
||||
url: doc/configure.html
|
||||
|
||||
|
@ -39,7 +39,11 @@ in
|
||||
urls = ["http://localhost:7880/api/v1/open/upload/item/blabla"];
|
||||
};
|
||||
|
||||
environment.systemPackages = [ pkgs.docspell.tools pkgs.jq ];
|
||||
environment.systemPackages =
|
||||
[ pkgs.docspell.tools
|
||||
pkgs.docspell.server
|
||||
pkgs.docspell.joex pkgs.jq
|
||||
];
|
||||
|
||||
services.xserver = {
|
||||
enable = false;
|
||||
|
12
nix/pkg.nix
12
nix/pkg.nix
@ -17,11 +17,11 @@ in
|
||||
buildPhase = "true";
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/{bin,program}
|
||||
cp -R * $out/program/
|
||||
mkdir -p $out/{bin,docspell-restserver-${cfg.version}}
|
||||
cp -R * $out/docspell-restserver-${cfg.version}/
|
||||
cat > $out/bin/docspell-restserver <<-EOF
|
||||
#!${bash}/bin/bash
|
||||
$out/program/bin/docspell-restserver -java-home ${jre8_headless} "\$@"
|
||||
$out/docspell-restserver-${cfg.version}/bin/docspell-restserver -java-home ${jre8_headless} "\$@"
|
||||
EOF
|
||||
chmod 755 $out/bin/docspell-restserver
|
||||
'';
|
||||
@ -39,11 +39,11 @@ in
|
||||
buildPhase = "true";
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/{bin,program}
|
||||
cp -R * $out/program/
|
||||
mkdir -p $out/{bin,docspell-joex-${cfg.version}}
|
||||
cp -R * $out/docspell-joex-${cfg.version}/
|
||||
cat > $out/bin/docspell-joex <<-EOF
|
||||
#!${bash}/bin/bash
|
||||
$out/program/bin/docspell-joex -java-home ${jre8_headless} "\$@"
|
||||
$out/docspell-joex-${cfg.version}/bin/docspell-joex -java-home ${jre8_headless} "\$@"
|
||||
EOF
|
||||
chmod 755 $out/bin/docspell-joex
|
||||
'';
|
||||
|
Loading…
Reference in New Issue
Block a user