-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashy.nix
99 lines (96 loc) · 2.52 KB
/
dashy.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{
config,
lib,
pkgs,
...
}:
# based on https://github.com/LongerHV/nixos-configuration/blob/f4d51a14753f9998b4585d6db525b12ec8e62a7b/modules/nixos/dashy.nix
# by LongerHV
let
cfg = config.services.dashy;
format = pkgs.formats.yaml {};
configFile = format.generate "conf.yml" cfg.settings;
in {
options.services.dashy = with lib; {
enable = mkEnableOption "dashy";
imageTag = mkOption {
type = types.str;
};
# package = mkOption {
# type = types.package;
# default = pkgs.dashy;
# };
port = mkOption {
type = types.int;
default = 4000;
};
# user = mkOption {
# type = types.str;
# default = "dashy";
# };
# group = mkOption {
# type = types.str;
# default = "dashy";
# };
# dataDir = mkOption {
# type = types.path;
# default = "/var/lib/dashy";
# };
# mutableConfig = mkOption {
# type = types.bool;
# default = false;
# };
settings = mkOption {
type = types.attrs;
default = {};
};
extraOptions = mkOption {};
};
config = lib.mkIf cfg.enable {
# users.users."${cfg.user}" = {
# inherit (cfg) group;
# isSystemUser = true;
# home = cfg.dataDir;
# createHome = true;
# };
# users.groups."${cfg.group}" = { };
virtualisation.oci-containers.containers = {
dashy = {
autoStart = true;
ports = ["4000:80"]; # server port : docker port
image = "lissy93/dashy:${cfg.imageTag}";
inherit (cfg) extraOptions;
environment = {
TZ = "${config.time.timeZone}";
};
volumes = [
"${configFile}:/app/public/conf.yml"
];
};
};
# systemd.services.dashy = {
# after = [ "network-online.target" ];
# wantedBy = [ "multi-user.target" ];
# preStart = ''
# mkdir -p ${cfg.dataDir}/public
# '' + (if cfg.mutableConfig then ''
# if [ ! -f ${cfg.dataDir}/public/conf.yml ]; then
# cp ${cfg.package}/share/dashy/public/conf.yml ${cfg.dataDir}/public/conf.yml
# chmod u+w ${cfg.dataDir}/public/conf.yml
# fi
# '' else ''
# ln -sf ${configFile} ${cfg.dataDir}/public/conf.yml
# '');
# serviceConfig = {
# ExecStart = "${cfg.package}/bin/dashy";
# WorkingDirectory = cfg.dataDir;
# User = cfg.user;
# Group = cfg.group;
# Restart = "always";
# };
# environment = {
# PORT = builtins.toString cfg.port;
# };
# };
};
}