-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
79 lines (72 loc) · 2.76 KB
/
flake.nix
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
inputs = {
cargo2nix.url = "github:cargo2nix/cargo2nix/release-0.11.0";
flake-utils.follows = "cargo2nix/flake-utils"; nixpkgs.follows =
"cargo2nix/nixpkgs";
};
outputs = inputs: with inputs;
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system; overlays = [cargo2nix.overlays.default];
};
rustPkgs = pkgs.rustBuilder.makePackageSet {
rustVersion = "1.75.0"; packageFun = import ./Cargo.nix;
};
in rec {
packages = {
wsh = (rustPkgs.workspace.wsh {}); default = packages.wsh;
}; nixosModules = {
default = ({ config, lib, pkgs, ... }:
with lib;
{
options = {
services.wsh = {
enable = mkEnableOption "Enable the WSH service";
port = mkOption {
type = types.int; default = 8012; description =
"Port for the WSH service";
}; host_mode = mkOption {
type = types.string; default = "mirror"; description =
"Mode for the WSH service: 'mirror' or 'local'";
}; mirror = {
url = mkOption {
type = types.string;
default = "https://wsh.draculente.eu";
description = "URL for the mirror";
};
}; configFile = mkOption {
type = types.path;
default = "/example/path/config.toml";
description = "path for a configuration toml file";
};
};
};
config = mkIf config.services.wsh.enable {
systemd.services.wsh = {
description = "WSH Service";
wantedBy= [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
ExecStart = "${packages.wsh}/bin/wsh";
Environment = [
"WEBCOMMAND_PORT=${toString config.services.wsh.port}"
''WEBCOMMAND_CONFIG=${
if
config.services.wsh.host_mode == "mirror"
then
config.services.wsh.mirror.url
else
config.services.wsh.configFile
}''
"WEBCOMMAND_HOST_MODE=${if config.services.wsh.host_mode == "local" then "true" else "false"}"
];
};
};
};
}
);
};
}
);
}