aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules/bcg.nix
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2024-04-16 10:51:59 +0200
committerKarel Kočí <cynerd@email.cz>2024-04-16 10:53:52 +0200
commitbbda84ca261397086f866ece115c4ec9111d4d02 (patch)
tree29b165207bf12de36cc6f983edd3f3a65512fba2 /nixos/modules/bcg.nix
parent2fcf002e3abff092eafd098fadafa15ea579aae4 (diff)
downloadnixos-personal-bbda84ca261397086f866ece115c4ec9111d4d02.tar.gz
nixos-personal-bbda84ca261397086f866ece115c4ec9111d4d02.tar.bz2
nixos-personal-bbda84ca261397086f866ece115c4ec9111d4d02.zip
Try to improve the code
Diffstat (limited to 'nixos/modules/bcg.nix')
-rw-r--r--nixos/modules/bcg.nix31
1 files changed, 14 insertions, 17 deletions
diff --git a/nixos/modules/bcg.nix b/nixos/modules/bcg.nix
index 626a67f..3146c15 100644
--- a/nixos/modules/bcg.nix
+++ b/nixos/modules/bcg.nix
@@ -4,13 +4,10 @@
pkgs,
...
}:
-
-with lib;
-
-let
+with lib; let
cfg = config.services.bcg;
configFile = (pkgs.formats.yaml {}).generate "bcg.conf.yaml" (
- filterAttrsRecursive (n: v: v != null) {
+ filterAttrsRecursive (_: v: v != null) {
inherit (cfg) device name mqtt;
retain_node_messages = cfg.retainNodeMessages;
qos_node_messages = cfg.qosNodeMessages;
@@ -21,16 +18,15 @@ let
automatic_rename_nodes = cfg.automaticRenameNodes;
}
);
-in
-{
+in {
options = {
services.bcg = {
enable = mkEnableOption "BigClown gateway";
- package = mkPackageOption pkgs [ "python3Packages" "bcg" ] { };
+ package = mkPackageOption pkgs ["python3Packages" "bcg"] {};
environmentFiles = mkOption {
type = types.listOf types.path;
default = [];
- example = [ "/run/keys/bcg.env" ];
+ example = ["/run/keys/bcg.env"];
description = ''
File to load as environment file. Environment variables from this file
will be interpolated into the config file using envsubst with this
@@ -148,21 +144,22 @@ in
systemd.services.bcg = let
envConfig = cfg.environmentFiles != [];
- finalConfig = if envConfig
- then "$RUNTIME_DIRECTORY/bcg.config.yaml"
- else configFile;
+ finalConfig =
+ if envConfig
+ then "$RUNTIME_DIRECTORY/bcg.config.yaml"
+ else configFile;
in {
description = "BigClown Gateway";
- wantedBy = [ "multi-user.target" ];
- wants = [ "network-online.target" ] ++ lib.optional config.services.mosquitto.enable "mosquitto.service";
- after = [ "network-online.target" ];
+ wantedBy = ["multi-user.target"];
+ wants = ["network-online.target"] ++ lib.optional config.services.mosquitto.enable "mosquitto.service";
+ after = ["network-online.target"];
preStart = ''
umask 077
${pkgs.envsubst}/bin/envsubst -i "${configFile}" -o "${finalConfig}"
- '';
+ '';
serviceConfig = {
EnvironmentFile = cfg.environmentFiles;
- ExecStart="${cfg.package}/bin/bcg -c ${finalConfig} -v ${cfg.verbose}";
+ ExecStart = "${cfg.package}/bin/bcg -c ${finalConfig} -v ${cfg.verbose}";
RuntimeDirectory = "bcg";
};
};