Skip to content

Commit

Permalink
nixos/modules/cctl: initial module definition
Browse files Browse the repository at this point in the history
  • Loading branch information
marijanp committed Mar 21, 2024
1 parent f04b4eb commit d9b3eed
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ in
imports = [ ./modules/kairos.nix ];
services.kairos.package = self.packages.${pkgs.system}.kairos;
};
cctl =
{ pkgs, lib, ... }:
{
imports = [ ./modules/cctl.nix ];
services.cctl.package = self.packages.${pkgs.system}.cctld;
};
};
};
}
69 changes: 69 additions & 0 deletions nixos/modules/cctl.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{ lib, pkgs, config, ... }:
let
inherit (lib)
types
mkOption
mkIf
mkMerge
mkEnableOption
mdDoc
;
cfg = config.services.cctl;
in
{
options.services.cctl = {

enable = mkEnableOption (mdDoc "cctl");

package = mkOption {
type = types.package;
};

port = mkOption {
type = types.port;
default = 11101;
example = 60000;
description = mdDoc ''
Port to listen on.
TODO make port configurable in cctl
'';
};

logLevel = mkOption {
type = types.enum [
"error"
"warn"
"info"
"debug"
"trace"
];
default = "info";
description = ''
The log-level that should be used.
'';
};
};

config = mkIf cfg.enable {

systemd.services.cctl =
{
description = "cctl";
documentation = [ "" ];
wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" ];
requires = [ "network-online.target" ];
environment = {
RUST_LOG = cfg.logLevel;
};
serviceConfig = mkMerge [
{
ExecStart = ''${lib.getExe cfg.package}'';
Type = "notify";
Restart = "always";
DynamicUser = true;
}
];
};
};
}

0 comments on commit d9b3eed

Please sign in to comment.