1
0
Fork 0
selfhostblocks/modules/services/grocy.nix

107 lines
2.8 KiB
Nix
Raw Normal View History

{ config, pkgs, lib, ... }:
let
cfg = config.shb.grocy;
contracts = pkgs.callPackage ../contracts {};
fqdn = "${cfg.subdomain}.${cfg.domain}";
in
{
options.shb.grocy = {
enable = lib.mkEnableOption "selfhostblocks.grocy";
subdomain = lib.mkOption {
type = lib.types.str;
description = "Subdomain under which grocy will be served.";
example = "grocy";
};
domain = lib.mkOption {
type = lib.types.str;
description = "domain under which grocy will be served.";
example = "mydomain.com";
};
dataDir = lib.mkOption {
description = "Folder where Grocy will store all its data.";
type = lib.types.str;
default = "/var/lib/grocy";
};
currency = lib.mkOption {
type = lib.types.str;
description = "ISO 4217 code for the currency to display.";
default = "USD";
example = "NOK";
};
culture = lib.mkOption {
type = lib.types.enum [ "de" "en" "da" "en_GB" "es" "fr" "hu" "it" "nl" "no" "pl" "pt_BR" "ru" "sk_SK" "sv_SE" "tr" ];
default = "en";
flake.lock: Update (#226) Automated changes by the [update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock) GitHub Action. ``` Flake lock file updates: • Updated input 'nixpkgs': 'github:nixos/nixpkgs/b06025f1533a1e07b6db3e75151caa155d1c7eb3?narHash=sha256-qrxvLS888pNJFwJdK%2Bhf1wpRCSQcqA6W5%2BOx202NDa0%3D' (2024-03-19) → 'github:nixos/nixpkgs/5672bc9dbf9d88246ddab5ac454e82318d094bb8?narHash=sha256-NLznXB5AOnniUtZsyy/aPWOk8ussTuePp2acb9U%2BISA%3D' (2024-04-16) • Updated input 'sops-nix': 'github:Mic92/sops-nix/83b68a0e8c94b72cdd0a6e547a14ca7eb1c03616?narHash=sha256-RquCuzxfy4Nr8DPbdp3D/AsbYep21JgQzG8aMH9jJ4A%3D' (2024-03-17) → 'github:Mic92/sops-nix/cc535d07cbcdd562bcca418e475c7b1959cefa4b?narHash=sha256-APoDs2GtzVrsE%2BZ9w72qpHzEtEDfuinWcNTN7zhwLxg%3D' (2024-04-15) • Updated input 'sops-nix/nixpkgs': 'github:NixOS/nixpkgs/9af9c1c87ed3e3ed271934cb896e0cdd33dae212?narHash=sha256-huQT4Xs0y4EeFKn2BTBVYgEwJSv8SDlm82uWgMnCMmI%3D' (2024-03-15) → 'github:NixOS/nixpkgs/a0c9e3aee1000ac2bfb0e5b98c94c946a5d180a9?narHash=sha256-icE1IJE9fHcbDfJ0%2BqWoDdcBXUoZCcIJxME4lMHwvSM%3D' (2024-04-12) • Updated input 'sops-nix/nixpkgs-stable': 'github:NixOS/nixpkgs/6dc11d9859d6a18ab0c5e5829a5b8e4810658de3?narHash=sha256-y%2Bl3eH53UlENaYa1lmnCBHusZb1kxBEFd2/c7lDsGpw%3D' (2024-03-16) → 'github:NixOS/nixpkgs/c27f3b6d8e29346af16eecc0e9d54b1071eae27e?narHash=sha256-RifMwYuKu5v6x6O65msKDTqKkQ9crGwOB7yr20qMEuE%3D' (2024-04-13) ``` ### Running GitHub Actions on this PR GitHub Actions will not run workflows on pull requests which are opened by a GitHub Action. To run GitHub Actions workflows on this PR, run: ```sh git branch -D update_flake_lock_action git fetch origin git checkout update_flake_lock_action git commit --amend --no-edit git push origin update_flake_lock_action --force ``` --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-04-18 01:06:29 +02:00
description = ''
Display language of the frontend.
'';
};
ssl = lib.mkOption {
description = "Path to SSL files";
type = lib.types.nullOr contracts.ssl.certs;
default = null;
};
extraServiceConfig = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
description = "Extra configuration given to the systemd service file.";
default = {};
example = lib.literalExpression ''
{
MemoryHigh = "512M";
MemoryMax = "900M";
}
'';
};
logLevel = lib.mkOption {
type = lib.types.nullOr (lib.types.enum ["critical" "error" "warning" "info" "debug"]);
description = "Enable logging.";
default = false;
example = true;
};
};
config = lib.mkIf cfg.enable (lib.mkMerge [{
services.grocy = {
enable = true;
hostName = fqdn;
nginx.enableSSL = !(isNull cfg.ssl);
dataDir = cfg.dataDir;
settings.currency = cfg.currency;
settings.culture = cfg.culture;
};
services.phpfpm.pools.grocy.group = lib.mkForce "grocy";
users.groups.grocy = {};
users.users.grocy.group = lib.mkForce "grocy";
services.nginx.virtualHosts."${fqdn}" = {
enableACME = lib.mkForce false;
sslCertificate = lib.mkIf (!(isNull cfg.ssl)) cfg.ssl.paths.cert;
sslCertificateKey = lib.mkIf (!(isNull cfg.ssl)) cfg.ssl.paths.key;
};
# We backup the whole grocy directory and set permissions for the backup user accordingly.
users.groups.grocy.members = [ "backup" ];
users.groups.media.members = [ "backup" ];
shb.backup.instances.grocy = {
sourceDirectories = [
config.services.grocy.dataDir
];
};
} {
systemd.services.grocyd.serviceConfig = cfg.extraServiceConfig;
}]);
}