grafana-alloy: don't build the frontend twice
[NixPkgs.git] / nixos / modules / services / admin / meshcentral.nix
blob6e0801e1c08946d3e37b61f6266e99e0777b036b
1 { config, pkgs, lib, ... }:
2 let
3   cfg = config.services.meshcentral;
4   configFormat = pkgs.formats.json {};
5   configFile = configFormat.generate "meshcentral-config.json" cfg.settings;
6 in with lib; {
7   options.services.meshcentral = with types; {
8     enable = mkEnableOption "MeshCentral computer management server";
9     package = mkPackageOption pkgs "meshcentral" { };
10     settings = mkOption {
11       description = ''
12         Settings for MeshCentral. Refer to upstream documentation for details:
14         - [JSON Schema definition](https://github.com/Ylianst/MeshCentral/blob/master/meshcentral-config-schema.json)
15         - [simple sample configuration](https://github.com/Ylianst/MeshCentral/blob/master/sample-config.json)
16         - [complex sample configuration](https://github.com/Ylianst/MeshCentral/blob/master/sample-config-advanced.json)
17         - [Old homepage with documentation link](https://www.meshcommander.com/meshcentral2)
18       '';
19       type = types.submodule {
20         freeformType = configFormat.type;
21       };
22       example = {
23         settings = {
24           WANonly = true;
25           Cert = "meshcentral.example.com";
26           TlsOffload = "10.0.0.2,fd42::2";
27           Port = 4430;
28         };
29         domains."".certUrl = "https://meshcentral.example.com/";
30       };
31     };
32   };
33   config = mkIf cfg.enable {
34     services.meshcentral.settings.settings.autoBackup.backupPath = lib.mkDefault "/var/lib/meshcentral/backups";
35     systemd.services.meshcentral = {
36       wantedBy = ["multi-user.target"];
37       serviceConfig = {
38         ExecStart = "${cfg.package}/bin/meshcentral --datapath /var/lib/meshcentral --configfile ${configFile}";
39         DynamicUser = true;
40         StateDirectory = "meshcentral";
41         CacheDirectory = "meshcentral";
42       };
43     };
44   };
45   meta.maintainers = [ ];