Add module with images service definition

main
Elnu 1 year ago
parent 7591109e50
commit 138bc69590

@ -58,6 +58,7 @@
nixosModules.default = { config, ... }: let nixosModules.default = { config, ... }: let
lib = nixpkgs.lib; lib = nixpkgs.lib;
in { in {
# tatoeba
options.services.tatoeba = { options.services.tatoeba = {
enable = lib.mkEnableOption (lib.mdDoc "tatoeba service"); enable = lib.mkEnableOption (lib.mdDoc "tatoeba service");
package = lib.mkOption { package = lib.mkOption {
@ -76,21 +77,54 @@
''; '';
}; };
}; };
config = { config.systemd.services.tatoeba = let
systemd.services.tatoeba = let cfg = config.services.tatoeba;
cfg = config.services.tatoeba; pkg = self.packages.${system}.tatoeba;
pkg = self.packages.${system}.tatoeba; in lib.mkIf cfg.enable {
in lib.mkIf cfg.enable { description = pkg.meta.description;
description = pkg.meta.description; after = [ "network.target" ];
after = [ "network.target" ]; wantedBy = [ "network.target" ];
wantedBy = [ "network.target" ]; serviceConfig = {
serviceConfig = { ExecStart = ''
ExecStart = '' ${cfg.package}/bin/tatoeba --port ${builtins.toString cfg.port}
${cfg.package}/bin/tatoeba --port ${builtins.toString cfg.port} '';
''; Restart = "always";
Restart = "always"; DynamicUser = true;
DynamicUser = true; };
}; };
# images
options.services.images = {
enable = lib.mkEnableOption (lib.mdDoc "images service");
package = lib.mkOption {
type = lib.types.package;
default = self.packages.${system}.images;
defaultText = "pkgs.images";
description = lib.mdDoc ''
The images package that should be used.
'';
};
port = lib.mkOption {
type = lib.types.port;
default = 3002;
description = lib.mdDoc ''
The port at which to run.
'';
};
};
config.systemd.services.images = let
cfg = config.services.images;
pkg = self.packages.${system}.images;
in lib.mkIf cfg.enable {
description = pkg.meta.description;
after = [ "network.target" ];
wantedBy = [ "network.target" ];
serviceConfig = {
ExecStart = ''
${cfg.package}/bin/images --port ${builtins.toString cfg.port}
'';
Restart = "always";
DynamicUser = true;
}; };
}; };
}; };

Loading…
Cancel
Save