mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 19:55:41 +03:00

Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:
nix-build ci -A fmt.check
This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).
This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).
Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase
).
If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
114 lines
2.6 KiB
Nix
114 lines
2.6 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
let
|
|
cfg = config.services.metabase;
|
|
|
|
inherit (lib) mkEnableOption mkIf mkOption;
|
|
inherit (lib) optional optionalAttrs types;
|
|
|
|
dataDir = "/var/lib/metabase";
|
|
|
|
in
|
|
{
|
|
|
|
options = {
|
|
|
|
services.metabase = {
|
|
enable = mkEnableOption "Metabase service";
|
|
|
|
package = lib.mkPackageOption pkgs "metabase" { };
|
|
|
|
listen = {
|
|
ip = mkOption {
|
|
type = types.str;
|
|
default = "0.0.0.0";
|
|
description = ''
|
|
IP address that Metabase should listen on.
|
|
'';
|
|
};
|
|
|
|
port = mkOption {
|
|
type = types.port;
|
|
default = 3000;
|
|
description = ''
|
|
Listen port for Metabase.
|
|
'';
|
|
};
|
|
};
|
|
|
|
ssl = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Whether to enable SSL (https) support.
|
|
'';
|
|
};
|
|
|
|
port = mkOption {
|
|
type = types.port;
|
|
default = 8443;
|
|
description = ''
|
|
Listen port over SSL (https) for Metabase.
|
|
'';
|
|
};
|
|
|
|
keystore = mkOption {
|
|
type = types.nullOr types.path;
|
|
default = "${dataDir}/metabase.jks";
|
|
example = "/etc/secrets/keystore.jks";
|
|
description = ''
|
|
[Java KeyStore](https://www.digitalocean.com/community/tutorials/java-keytool-essentials-working-with-java-keystores) file containing the certificates.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
openFirewall = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Open ports in the firewall for Metabase.
|
|
'';
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.metabase = {
|
|
description = "Metabase server";
|
|
wantedBy = [ "multi-user.target" ];
|
|
wants = [ "network-online.target" ];
|
|
after = [ "network-online.target" ];
|
|
environment =
|
|
{
|
|
MB_PLUGINS_DIR = "${dataDir}/plugins";
|
|
MB_DB_FILE = "${dataDir}/metabase.db";
|
|
MB_JETTY_HOST = cfg.listen.ip;
|
|
MB_JETTY_PORT = toString cfg.listen.port;
|
|
}
|
|
// optionalAttrs (cfg.ssl.enable) {
|
|
MB_JETTY_SSL = true;
|
|
MB_JETTY_SSL_PORT = toString cfg.ssl.port;
|
|
MB_JETTY_SSL_KEYSTORE = cfg.ssl.keystore;
|
|
};
|
|
serviceConfig = {
|
|
DynamicUser = true;
|
|
StateDirectory = baseNameOf dataDir;
|
|
ExecStart = lib.getExe cfg.package;
|
|
};
|
|
};
|
|
|
|
networking.firewall = mkIf cfg.openFirewall {
|
|
allowedTCPPorts = [ cfg.listen.port ] ++ optional cfg.ssl.enable cfg.ssl.port;
|
|
};
|
|
|
|
};
|
|
}
|