Add module
This commit is contained in:
67
module.nix
67
module.nix
@@ -1,2 +1,67 @@
|
||||
{...}: {
|
||||
self: {
|
||||
config,
|
||||
system,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config.services.conmorfeusz;
|
||||
morfeusz = self.packages.${system}.morfeusz;
|
||||
concraft-pl = self.packages.${system}.concraft-pl;
|
||||
conmorfeusz = self.packages.${system}.conmorfeusz;
|
||||
|
||||
serverConfig = cfg.server.config // {port = toString cfg.server.port;};
|
||||
in {
|
||||
options.services.conmorfeusz = with lib; {
|
||||
enable = mkEnableOption "conmorfeusz";
|
||||
|
||||
model = mkOption {
|
||||
type = types.nullOr types.package;
|
||||
description = "The target concraft-pl model";
|
||||
default = null;
|
||||
};
|
||||
|
||||
server = {
|
||||
enable = mkEnableOption "concraft-pl server";
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
description = "Port on which server should listen";
|
||||
default = 8080;
|
||||
};
|
||||
|
||||
config = mkOption {
|
||||
type = types.attrs;
|
||||
description = "CLI parameters of 'concraft-pl server' command";
|
||||
default = {
|
||||
inmodel = toString (pkgs.callPackage ./concraft-sgjp-model.nix {});
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = [
|
||||
morfeusz
|
||||
concraft-pl
|
||||
(conmorfeusz.override {
|
||||
model = cfg.model;
|
||||
local = !cfg.server.enable;
|
||||
serverUrl =
|
||||
if cfg.server.enable
|
||||
then "http://localhost:${toString cfg.server.port}"
|
||||
else null;
|
||||
})
|
||||
];
|
||||
|
||||
systemd.services.conmorfeusz = lib.mkIf cfg.server.enable {
|
||||
enable = true;
|
||||
description = "Conmorfeusz";
|
||||
|
||||
wantedBy = ["multi-user.target"];
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${concraft-pl}/bin/concraft-pl server ${lib.cli.toGNUCommandLineShell {} serverConfig}";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user