nixos-module.nix: init
This commit is contained in:
parent
3bb3e3bb0d
commit
68507c174a
1 changed files with 59 additions and 0 deletions
59
nixos-module.nix
Normal file
59
nixos-module.nix
Normal file
|
@ -0,0 +1,59 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
yammat = import ./. { inherit pkgs; };
|
||||
cfg = config.services.yammat;
|
||||
in
|
||||
{
|
||||
options.services.yammat = with lib; {
|
||||
enable = mkEnableOption "Yammat";
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "yammat";
|
||||
description = "System user to run Yammat";
|
||||
};
|
||||
|
||||
group = mkOption {
|
||||
type = types.str;
|
||||
default = "yammat";
|
||||
description = "System group to run Yammat";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.users.${cfg.user} = {
|
||||
isSystemUser = true;
|
||||
group = cfg.group;
|
||||
};
|
||||
users.groups.${cfg.group} = {};
|
||||
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
ensureDatabases = [ "yammat" ];
|
||||
ensureUsers = [ {
|
||||
name = cfg.user;
|
||||
ensurePermissions = {
|
||||
"DATABASE yammat" = "ALL PRIVILEGES";
|
||||
};
|
||||
} ];
|
||||
};
|
||||
|
||||
systemd.services.yammat = {
|
||||
description = "Yammat Matemat";
|
||||
after = [ "postgresql.service" ];
|
||||
requires = [ "postgresql.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment = {
|
||||
APPROOT = yammat;
|
||||
STATIC_DIR = "${yammat}/static";
|
||||
PGHOST = "";
|
||||
};
|
||||
serviceConfig = {
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
WorkingDirectory = yammat;
|
||||
ExecStart = "${yammat}/bin/yammat";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue