summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/security/e-imzo.nix
blob: 1755a20542556ce4a251ab6010fedf9cb8028136 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.services.e-imzo;
in
{
  options = {
    services.e-imzo = {
      enable = lib.mkEnableOption "E-IMZO";

      package = lib.mkPackageOption pkgs "e-imzo" {
        extraDescription = "Official mirror deletes old versions as soon as they release new one. Feel free to use either unstable or your own custom e-imzo package and ping maintainer.";
      };
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.user.services.e-imzo = {
      enable = true;
      description = "E-IMZO, uzbek state web signing service";
      documentation = [ "https://github.com/xinux-org/e-imzo" ];

      after = [
        "network-online.target"
        "graphical.target"
      ];
      wants = [
        "network-online.target"
        "graphical.target"
      ];
      wantedBy = [ "default.target" ];

      serviceConfig = {
        Type = "simple";
        Restart = "always";
        RestartSec = 1;
        ExecStartPre = [
          (pkgs.writeShellScript "e-imzo-check-port-availability" ''
            until [ -z "$(${pkgs.iproute2}/bin/ss -tuln | grep -E ':(64646|64443)\>')" ]; do
              sleep 1
            done
          '')
        ];
        ExecStart = lib.getExe cfg.package;

        NoNewPrivileges = true;
        SystemCallArchitectures = "native";
      };
    };
  };

  meta.maintainers = with lib.maintainers; [
    orzklv
    shakhzodkudratov
    bahrom04
    bemeritus
  ];
}