feat(nixosModules/server): add mongodb
This commit is contained in:
parent
68b200175f
commit
2f23b952de
2 changed files with 39 additions and 0 deletions
38
modules/nixos/server/databases/default.nix
Normal file
38
modules/nixos/server/databases/default.nix
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{ lib, config, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.server.databases;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.server.databases = {
|
||||||
|
mongodb.enable = lib.mkEnableOption "";
|
||||||
|
mongodb.dbPath = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "/var/db/mongodb";
|
||||||
|
};
|
||||||
|
mongodb.port = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 27017;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkMerge [
|
||||||
|
(lib.mkIf cfg.mongodb.enable {
|
||||||
|
environment.persistence."/persist".directories = [
|
||||||
|
{
|
||||||
|
directory = cfg.mongodb.dbPath;
|
||||||
|
user = "mongodb";
|
||||||
|
group = "mongodb";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
networking.firewall.allowedTCPPorts = [ cfg.mongodb.port ];
|
||||||
|
services.mongodb = {
|
||||||
|
enable = true;
|
||||||
|
dbpath = cfg.mongodb.dbPath;
|
||||||
|
bind_ip = "0.0.0.0";
|
||||||
|
extraConfig = ''
|
||||||
|
net.port: ${builtins.toString cfg.mongodb.port}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
|
@ -23,6 +23,7 @@
|
||||||
server = {
|
server = {
|
||||||
enableDDNS = true;
|
enableDDNS = true;
|
||||||
mountHelios = true;
|
mountHelios = true;
|
||||||
|
databases.mongodb.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue