Skip to content

Commit 6ff9a90

Browse files
committed
refactor(modules): Add host-info as nixosModules
1 parent 7eb45d1 commit 6ff9a90

File tree

2 files changed

+67
-51
lines changed

2 files changed

+67
-51
lines changed

modules/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
./pyroscope
66
./folder-size-metrics
77
./shard-split
8+
./host-info.nix
89
];
910
}

modules/host-info.nix

Lines changed: 66 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,71 @@
1+
{ withSystem, ... }:
12
{
2-
config,
3-
lib,
4-
...
5-
}:
6-
{
7-
options.mcl.host-info = with lib; {
8-
type = mkOption {
9-
type = types.nullOr (
10-
types.enum [
11-
"desktop"
12-
"server"
13-
]
14-
);
15-
default = null;
16-
example = [ "desktop" ];
17-
description = ''
18-
Whether this host is a desktop or a server.
19-
'';
20-
};
3+
flake.modules.nixos.mcl-host-info =
4+
{
5+
config,
6+
lib,
7+
...
8+
}:
9+
{
10+
options.mcl.host-info = with lib; {
11+
type = mkOption {
12+
type = types.nullOr (
13+
types.enum [
14+
"desktop"
15+
"server"
16+
"container"
17+
]
18+
);
19+
default = null;
20+
example = [ "desktop" ];
21+
description = ''
22+
Whether this host is a desktop or a server.
23+
'';
24+
};
2125

22-
isVM = mkOption {
23-
type = types.nullOr types.bool;
24-
default = null;
25-
example = [ "false" ];
26-
description = ''
27-
Whether this configuration is a VM variant.
28-
'';
29-
};
26+
isDebugVM = mkOption {
27+
type = types.nullOr types.bool;
28+
default = null;
29+
example = [ "false" ];
30+
description = ''
31+
Whether this configuration is a VM variant with extra debug
32+
functionality.
33+
'';
34+
};
35+
36+
configPath = mkOption {
37+
type = types.nullOr types.path;
38+
default = null;
39+
example = [ "machines/server/solunska-server" ];
40+
description = ''
41+
The configuration path for this host relative to the repo root.
42+
'';
43+
};
3044

31-
configPath = mkOption {
32-
type = types.nullOr types.string;
33-
default = null;
34-
example = [ "machines/server/solunska-server" ];
35-
description = ''
36-
The configuration path for this host relative to the repo root.
37-
'';
45+
sshKey = mkOption {
46+
type = types.nullOr types.str;
47+
default = "";
48+
example = "ssh-ed25519 AAAAC3Nza";
49+
description = ''
50+
The public ssh key for this host.
51+
'';
52+
};
53+
};
54+
config = {
55+
assertions = [
56+
{
57+
assertion = config.mcl.host-info.type != null;
58+
message = "mcl.host-info.type must be defined for every host";
59+
}
60+
{
61+
assertion = config.mcl.host-info.isDebugVM != null;
62+
message = "mcl.host-info.isDebugVM must be defined for every host";
63+
}
64+
{
65+
assertion = config.mcl.host-info.configPath != null;
66+
message = "mcl.host-info.configPath must be defined for every host";
67+
}
68+
];
69+
};
3870
};
39-
};
40-
config = {
41-
assertions = [
42-
{
43-
assertion = config.mcl.host-info.type != null;
44-
message = "mcl.host-info.type must be defined for every host";
45-
}
46-
{
47-
assertion = config.mcl.host-info.isVM != null;
48-
message = "mcl.host-info.isVM must be defined for every host";
49-
}
50-
{
51-
assertion = config.mcl.host-info.configPath != null;
52-
message = "mcl.host-info.configPath must be defined for every host";
53-
}
54-
];
55-
};
5671
}

0 commit comments

Comments
 (0)