Add Mealie service
This commit is contained in:
parent
268559dbce
commit
028d7e781d
11 changed files with 206 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
{...}: {
|
||||
_: {
|
||||
nixngModules = {
|
||||
bazarr = import ./bazarr.nix;
|
||||
radicale = import ./radicale.nix;
|
||||
|
@ -8,5 +8,6 @@
|
|||
prowlarr = import ./prowlarr.nix;
|
||||
ids = import ./ids.nix;
|
||||
deluge = import ./deluge.nix;
|
||||
mealie = import ./mealie.nix;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{...}: {
|
||||
{
|
||||
ids = {
|
||||
uids = {
|
||||
radicale = 408;
|
||||
|
@ -8,6 +8,7 @@
|
|||
bazarr = 412;
|
||||
prowlarr = 413;
|
||||
deluge = 414;
|
||||
mealie = 415;
|
||||
};
|
||||
|
||||
gids = {
|
||||
|
@ -19,6 +20,7 @@
|
|||
bazarr = 412;
|
||||
prowlarr = 413;
|
||||
deluge = 414;
|
||||
mealie = 415;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
85
nixng-modules/mealie.nix
Normal file
85
nixng-modules/mealie.nix
Normal file
|
@ -0,0 +1,85 @@
|
|||
{
|
||||
lib,
|
||||
nglib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.services.mealie;
|
||||
cfgInit = config.init.services.mealie;
|
||||
in {
|
||||
options.services.mealie = {
|
||||
enable = lib.mkEnableOption "mealie";
|
||||
package = lib.mkPackageOption pkgs "mealie" {};
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
freeformType = with lib.types; attrsOf str;
|
||||
|
||||
options = {
|
||||
PRODUCTION = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "true";
|
||||
};
|
||||
|
||||
DATA_DIR = lib.mkOption {
|
||||
type = with lib.types; nullOr str;
|
||||
default = null;
|
||||
};
|
||||
|
||||
DB_ENGINE = lib.mkOption {
|
||||
type = with lib.types; nullOr str;
|
||||
default = "sqlite";
|
||||
};
|
||||
|
||||
ALEMBIC_CONFIG_FILE = lib.mkOption {
|
||||
type = with lib.types; nullOr str;
|
||||
default = "${cfg.package}/alembic.ini";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
description = ''
|
||||
Configuration of the Mealie service.
|
||||
|
||||
See [the Mealie documentation](https://nightly.mealie.io/documentation/getting-started/installation/backend-config/) for available options and default values.
|
||||
'';
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
init.services.mealie = {
|
||||
enabled = true;
|
||||
user = lib.mkDefault "mealie";
|
||||
group = lib.mkDefault "mealie";
|
||||
|
||||
tmpfiles = with nglib.nottmpfiles.dsl; lib.optional (cfg.settings.DATA_DIR != null) (d "${cfg.settings.DATA_DIR}" "-" cfgInit.user cfgInit.group "-" _);
|
||||
|
||||
execStart =
|
||||
pkgs.writeShellScript "mealie-run"
|
||||
(let
|
||||
# Mealie can only be configured via environmental variables.
|
||||
# With this, we don't accidentally overwrite env variables set by the user.
|
||||
extraEnvLines = lib.mapAttrsToList (key: value: ''export ${key}=''${${key}:=${value}}'') cfg.settings;
|
||||
in ''
|
||||
${lib.concatStringsSep "\n" extraEnvLines}
|
||||
${cfg.package}/libexec/init_db
|
||||
|
||||
${lib.getExe cfg.package} -b 0.0.0.0:8000
|
||||
'');
|
||||
};
|
||||
|
||||
environment.systemPackages = [cfg.package];
|
||||
|
||||
users.users.${cfgInit.user} = nglib.mkDefaultRec {
|
||||
description = "mealie";
|
||||
inherit (cfgInit) group;
|
||||
createHome = false;
|
||||
home = "/var/empty";
|
||||
useDefaultShell = true;
|
||||
uid = config.ids.uids.mealie;
|
||||
};
|
||||
|
||||
users.groups.${cfgInit.group} = nglib.mkDefaultRec {gid = config.ids.gids.mealie;};
|
||||
};
|
||||
}
|
|
@ -35,7 +35,7 @@ in {
|
|||
|
||||
users.users.${cfgInit.user} = lib.mkIf (cfgInit.user == "radarr") (nglib.mkDefaultRec {
|
||||
description = "radarr";
|
||||
group = cfgInit.group;
|
||||
inherit (cfgInit) group;
|
||||
createHome = false;
|
||||
home = "/var/empty";
|
||||
useDefaultShell = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue