nix-stuff/roles/school/services/mongodb.nix

31 lines
729 B
Nix

{ 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
];
}