diff options
author | makefu <github@syntax-fehler.de> | 2021-12-29 00:20:28 +0100 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2021-12-29 00:20:28 +0100 |
commit | 7766b006a8c10453d3111cf41d5852176375c677 (patch) | |
tree | b0d96501145fcf5bd827efecf21c09fc2d9b0554 /krebs/3modules/ergo.nix | |
parent | 3330b6a2c4bd6a2fb4614dd9283d97d40f9f1a41 (diff) | |
parent | 687948cfe5154e03f93886dd27dc30c7910ba754 (diff) |
Merge remote-tracking branch 'tv/master'
Diffstat (limited to 'krebs/3modules/ergo.nix')
-rw-r--r-- | krebs/3modules/ergo.nix | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/krebs/3modules/ergo.nix b/krebs/3modules/ergo.nix index df9757db0..0ce0345d8 100644 --- a/krebs/3modules/ergo.nix +++ b/krebs/3modules/ergo.nix @@ -1,24 +1,8 @@ -{ config, lib, pkgs, ... }: - -let - inherit (lib) mkEnableOption mkIf mkOption types; - inherit (pkgs) coreutils ergo; - cfg = config.krebs.ergo; - - configFile = pkgs.writeText "ergo.conf" (builtins.toJSON cfg.config); -in - -{ - - ###### interface - +{ config, lib, options, pkgs, ... }: { options = { - krebs.ergo = { - - enable = mkEnableOption "Ergo IRC daemon"; - - config = mkOption { + enable = lib.mkEnableOption "Ergo IRC daemon"; + config = lib.mkOption { type = (pkgs.formats.json {}).type; description = '' Ergo IRC daemon configuration file. @@ -74,25 +58,22 @@ in }; }; }; - }; - }; - - - ###### implementation - - config = mkIf cfg.enable ({ - + config = let + cfg = config.krebs.ergo; + configFile = pkgs.writeJSON "ergo.conf" cfg.config; + in lib.mkIf cfg.enable ({ + krebs.ergo.config = + lib.mapAttrsRecursive (_: lib.mkDefault) options.krebs.ergo.config.default; systemd.services.ergo = { description = "Ergo IRC daemon"; wantedBy = [ "multi-user.target" ]; serviceConfig = { - ExecStart = "${ergo}/bin/ergo run --conf ${configFile}"; + ExecStart = "${pkgs.ergo}/bin/ergo run --conf ${configFile}"; DynamicUser = true; StateDirectory = "ergo"; }; }; - }); } |