Skip to content

Commit 8c2e0d7

Browse files
committed
discuss: Add discuss module, plus firewall support
1 parent ccb2d87 commit 8c2e0d7

File tree

4 files changed

+75
-5
lines changed

4 files changed

+75
-5
lines changed

modules/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
# Add your NixOS modules here
33
#
44
# my-module = ./my-module;
5+
discussd = ./discussd.nix;
56
remctld = ./remctld.nix;
67
}

modules/discussd.nix

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{ lib, pkgs, config, options, ...
2+
}:
3+
let
4+
cfg = config.services.discussd;
5+
athena-pkgs = import ../pkgs { inherit pkgs; };
6+
in
7+
{
8+
options.services.discussd = (let
9+
mkOption = lib.mkOption;
10+
mkEnableOption = lib.mkEnableOption;
11+
types = lib.types;
12+
in {
13+
enable = mkEnableOption "discussd";
14+
openFirewall = mkOption {
15+
description = "open firewall for discuss (if service enabled)";
16+
default = true;
17+
type = types.bool;
18+
};
19+
});
20+
21+
config = lib.mkIf cfg.enable {
22+
users.groups.discuss = { };
23+
users.users.discuss = {
24+
description = "Discuss server";
25+
isSystemUser = true;
26+
group = "discuss";
27+
};
28+
29+
# systemd unit
30+
systemd.services."discussd@" = {
31+
description = "Discuss server";
32+
documentation = [ "man:discussd(8)" ];
33+
requires = [ "discussd.socket" ];
34+
serviceConfig = {
35+
#Type = "simple";
36+
#NotifyAccess = "main";
37+
#Restart = "always";
38+
User = "discuss";
39+
StandardInput = "socket";
40+
PrivateTmp = true;
41+
PrivateUsers = true;
42+
ExecStart = "${athena-pkgs.discuss}/sbin/discussd";
43+
};
44+
};
45+
systemd.sockets.discussd = {
46+
description = "discussd listening socket";
47+
documentation = [ "man:discussd(8)" ];
48+
socketConfig = {
49+
ListenStream = 2100;
50+
Accept = true;
51+
};
52+
wantedBy= [ "sockets.target" ];
53+
};
54+
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [2100];
55+
};
56+
}

modules/remctld.nix

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ in
1313

1414
remctl_options = {
1515
executable = mkOption {
16-
type = types.string;
16+
type = types.str;
1717
example = "/bin/echo";
1818
description = "Executable to run";
1919
};
2020

2121
help = mkOption {
22-
type = types.nullOr types.string;
22+
type = types.nullOr types.str;
2323
example = "--help";
2424
default = null;
2525
description = "Argument for the command that will print help for the subcommand";
@@ -30,20 +30,25 @@ in
3030
#sudo
3131
#summary
3232
user = mkOption {
33-
type = types.nullOr types.string;
33+
type = types.nullOr types.str;
3434
example = "apache2";
3535
default = null;
3636
description = "user to run the command as";
3737
};
3838

3939
acl = mkOption {
40-
type = types.listOf types.string;
40+
type = types.listOf types.str;
4141
default = ["ANYUSER"];
4242
description = "ACL for the command";
4343
};
4444
};
4545
in {
4646
enable = mkEnableOption "remctld";
47+
openFirewall = mkOption {
48+
description = "open firewall for discuss (if service enabled)";
49+
default = true;
50+
type = types.bool;
51+
};
4752
commands = mkOption {
4853
description = "command definitions";
4954
type = types.attrsOf (types.attrsOf (types.submodule {
@@ -77,5 +82,6 @@ in
7782
# systemd unit
7883
systemd.packages = [ athena-pkgs.remctl ];
7984
systemd.sockets.remctld.wantedBy = ["multi-user.target"];
85+
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [4373];
8086
};
8187
}

pkgs/discuss.nix

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,12 @@ in stdenv.mkDerivation {
3636
];
3737

3838
#configureFlags = ["--without-krb4" "--with-krb5" "--with-zephyr"];
39-
configureFlags = ["--without-krb4" "--with-krb5" "--without-zephyr"];
39+
configureFlags = [
40+
"--without-krb4" "--with-krb5" "--without-zephyr"
41+
];
42+
preConfigure = ''
43+
configureFlagsArray+=(
44+
"CFLAGS=-DDSC_SETUP=\\\"$out/bin/dsc_setup\\\""
45+
)
46+
'';
4047
}

0 commit comments

Comments
 (0)