diff --git a/hosts/hackens-org/configuration.nix b/hosts/hackens-org/configuration.nix index 6add84c..d7083a6 100644 --- a/hosts/hackens-org/configuration.nix +++ b/hosts/hackens-org/configuration.nix @@ -14,6 +14,7 @@ ./webpass.nix ./mosquitto.nix ./prometheus + ./kfet2mqtt.nix # ./bridge.nix # ./gha.nix # ./sync.nix diff --git a/hosts/hackens-org/kfet2mqtt.nix b/hosts/hackens-org/kfet2mqtt.nix new file mode 100644 index 0000000..76262a5 --- /dev/null +++ b/hosts/hackens-org/kfet2mqtt.nix @@ -0,0 +1,25 @@ +{ pkgs, ... }: +let + python = pkgs.python39.withPackages (ps: [ + ps.asyncio-mqtt + ps.websockets + ]); + script = pkgs.fetchgit { + url = "https://git.eleves.ens.fr/hackens/kfet2mqtt.git"; + rev = "30d948dc2f7b4a0b440445ef578b6ed718a53273"; + sha256 = "0d93jc0cwx1a8rhq9m0lwzqp53jsffr9qyswdkwydji14f3kwd4d"; + }; +in +{ + systemd.services."kfet2mqtt" = { + enable = true; + description = "Programme qui indique l'ouverture de la k-fet sur le broker mqtt d'hackENS"; + after = [ "network.target" ]; + serviceConfig = { + ExecStart = "${python}/bin/python ${script}/script.py"; + Restart = "always"; + RestartSec = 10; + }; + wantedBy = [ "mulit-user.target" ]; + }; +}