School: add mongodb and mongosh

This commit is contained in:
Toast 2024-02-23 09:54:03 +01:00
parent dddd601fd2
commit 7c7f1ca339
2 changed files with 32 additions and 0 deletions

View file

@ -5,5 +5,6 @@
./syncthing.nix
./mysql.nix
./xampp.nix
./mongodb.nix
];
}

View file

@ -0,0 +1,31 @@
{ config, pkgs, lib, ... }:
{
services.mongodb = {
enable = true;
package = pkgs.mongodb-4_4;
user = "toast";
};
# Don't autostart MySQL
systemd.services.mongodb.wantedBy = lib.mkForce [];
# Allow regular users to start/stop mongodb
# https://stackoverflow.com/questions/61480914/using-policykit-to-allow-non-root-users-to-start-and-stop-a-service
security.polkit.extraConfig = ''
polkit.addRule(function(action, subject) {
if (
action.id == "org.freedesktop.systemd1.manage-units" &&
action.lookup("unit") == "mongodb.service" &&
subject.user == "${config.services.mongodb.user}"
)
{
return polkit.Result.YES;
}
})
'';
environment.systemPackages = with pkgs; [
mongosh
];
}