-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
72 lines (65 loc) · 2.51 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
{
description = "Nix Flake for Dres";
inputs = {
nixpkgs = {
url = "github:nixos/nixpkgs/nixos-24.05";
};
};
outputs = { self, nixpkgs}:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
in {
nixosModules.dres = { config, lib, ...}:
with lib;
let
cfg = config.dogjam.services.dres;
configFile = pkgs.writeText "config.json" (builtins.toJSON cfg.config);
in {
options.dogjam.services.dres = {
enable = mkEnableOption "Enable Dres service";
config = mkOption {
type = types.attrs;
default = { };
description = lib.mdDoc ''
Dres configuration.
'';
example = literalExpression ''
{
resolvers = {
google = {
type = "delegating";
socket = "8.8.8.8:53";
};
cloudflare = {
type = "delegating";
socket = "1.1.1.1:53";
};
};
}
'';
};
};
config = mkIf cfg.enable {
systemd.services."dogjam-dres" = {
wantedBy = [ "multi-user.target" ];
serviceConfig = let pkg = self.packages.x86_64-linux.default; in {
Restart = "on-failure";
ExecStart = "${pkg}/bin/dres -config ${configFile}";
RuntimeDirectory = "dogjam.dres";
RuntimeDirectoryMode = "0755";
StateDirectory = "dogjam.dres";
StateDirectoryMode = "0700";
CacheDirectory = "dogjam.dres";
CacheDirectoryMode = "0750";
};
};
};
};
nixosModules.default = self.nixosModules.dres;
packages.x86_64-linux.default = pkgs.buildGoModule {
name = "dres";
src = ./.;
vendorHash = "sha256-EDCaFzQmZ/ftLaQ4rvA3Zm3iyvM8gnL0Q15pc/9fTjI=";
};
};
}