docspell/flake.nix

190 lines
5.1 KiB
Nix
Raw Normal View History

2024-03-09 00:28:44 +00:00
{
description = "Docspell";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
devshell-tools.url = "github:eikek/devshell-tools";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
devshell-tools,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
2024-03-09 23:59:56 +00:00
sbt17 = pkgs.sbt.override { jre = pkgs.jdk17; };
2024-03-10 14:50:06 +00:00
ciPkgs = with pkgs; [
2024-03-09 23:59:56 +00:00
sbt17
2024-03-09 00:28:44 +00:00
jdk17
dpkg
elmPackages.elm
fakeroot
zola
yarn
2024-03-10 14:50:06 +00:00
nodejs
2024-03-10 18:53:36 +00:00
redocly-cli
2024-03-10 19:13:41 +00:00
tailwindcss
2024-03-09 00:28:44 +00:00
];
2024-03-10 14:50:06 +00:00
devshellPkgs = ciPkgs ++ (with pkgs; [
jq
scala-cli
netcat
wget
which
inotifyTools
]);
2024-03-09 00:28:44 +00:00
docspellPkgs = pkgs.callPackage (import ./nix/pkg.nix) {};
dockerAmd64 = pkgs.pkgsCross.gnu64.callPackage (import ./nix/docker.nix) {
inherit (docspellPkgs) docspell-restserver docspell-joex;
2024-03-09 00:28:44 +00:00
};
dockerArm64 = pkgs.pkgsCross.aarch64-multiplatform.callPackage (import ./nix/docker.nix) {
inherit (docspellPkgs) docspell-restserver docspell-joex;
2024-03-09 00:28:44 +00:00
};
in {
formatter = pkgs.alejandra;
packages = {
inherit (docspellPkgs) docspell-restserver docspell-joex;
2024-03-09 00:28:44 +00:00
};
legacyPackages = {
docker = {
amd64 = {
inherit (dockerAmd64) docspell-restserver docspell-joex;
2024-03-09 00:28:44 +00:00
};
arm64 = {
inherit (dockerArm64) docspell-restserver docspell-joex;
2024-03-09 00:28:44 +00:00
};
};
};
checks = {
build-server = self.packages.${system}.docspell-restserver;
2024-03-09 00:28:44 +00:00
build-joex = self.packages.${system}.docspell-joex;
test = with import (nixpkgs + "/nixos/lib/testing-python.nix")
{
inherit system;
};
makeTest {
name = "docspell";
nodes = {
machine = {...}: {
nixpkgs.overlays = [self.overlays.default];
imports = [
self.nixosModules.default
./nix/checks
];
};
};
testScript = builtins.readFile ./nix/checks/testScript.py;
};
};
devShells = {
dev-cnt = pkgs.mkShellNoCC {
buildInputs =
(builtins.attrValues devshell-tools.legacyPackages.${system}.cnt-scripts)
++ devshellPkgs;
2024-03-09 23:59:56 +00:00
DOCSPELL_ENV = "dev";
2024-03-09 00:28:44 +00:00
DEV_CONTAINER = "docsp-dev";
SBT_OPTS = "-Xmx2G -Xss4m";
};
dev-vm = pkgs.mkShellNoCC {
buildInputs =
(builtins.attrValues devshell-tools.legacyPackages.${system}.vm-scripts)
++ devshellPkgs;
2024-03-09 23:59:56 +00:00
DOCSPELL_ENV = "dev";
2024-03-09 00:28:44 +00:00
SBT_OPTS = "-Xmx2G -Xss4m";
DEV_VM = "dev-vm";
VM_SSH_PORT = "10022";
};
2024-03-10 14:50:06 +00:00
ci = pkgs.mkShellNoCC {
buildInputs = ciPkgs;
SBT_OPTS = "-Xmx2G -Xss4m";
};
2024-03-09 00:28:44 +00:00
};
})
// {
nixosModules = {
default = {...}: {
imports = [
./nix/modules/server.nix
./nix/modules/joex.nix
];
};
server = import ./nix/modules/server.nix;
joex = import ./nix/modules/joex.nix;
};
overlays.default = final: prev: let
docspellPkgs = final.callPackage (import ./nix/pkg.nix) {};
in {
inherit (docspellPkgs) docspell-restserver docspell-joex;
2024-03-09 00:28:44 +00:00
};
nixosConfigurations = {
test-vm = devshell-tools.lib.mkVm {
system = "x86_64-linux";
modules = [
self.nixosModules.default
{
nixpkgs.overlays = [self.overlays.default];
}
./nix/test-vm.nix
];
};
docsp-dev = devshell-tools.lib.mkContainer {
system = "x86_64-linux";
modules = [
{
2024-03-09 23:59:56 +00:00
services.dev-postgres = {
enable = true;
databases = ["docspell"];
};
2024-03-09 00:28:44 +00:00
services.dev-email.enable = true;
services.dev-minio.enable = true;
2024-03-09 23:59:56 +00:00
services.dev-solr = {
enable = true;
cores = ["docspell"];
};
2024-03-09 00:28:44 +00:00
}
];
};
dev-vm = devshell-tools.lib.mkVm {
system = "x86_64-linux";
modules = [
{
2024-03-09 23:59:56 +00:00
services.dev-postgres = {
enable = true;
databases = ["docspell"];
};
2024-03-09 00:28:44 +00:00
services.dev-email.enable = true;
services.dev-minio.enable = true;
2024-03-09 23:59:56 +00:00
services.dev-solr = {
enable = true;
cores = ["docspell"];
};
2024-03-09 00:28:44 +00:00
port-forward.ssh = 10022;
port-forward.dev-postgres = 6534;
port-forward.dev-smtp = 10025;
port-forward.dev-imap = 10143;
port-forward.dev-webmail = 8080;
port-forward.dev-minio-api = 9000;
port-forward.dev-minio-console = 9001;
port-forward.dev-solr = 8983;
networking.hostName = "dev-vm";
}
];
};
};
};
}