Add flake & module
This commit is contained in:
parent
0a763d257d
commit
a1cddab829
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
description = "Tattler Notification Listener";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-22.05";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
helpers = {
|
||||
url = "git+https://git.fudo.org/fudo-public/nix-helpers.git";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils, helpers, ... }:
|
||||
utils.lib.eachDefaultSystem (system:
|
||||
let pkgs = nixpkgs.legacyPackages."${system}";
|
||||
in {
|
||||
packages = rec {
|
||||
default = tattler;
|
||||
tattler = helpers.packages."${system}".mkClojureBin {
|
||||
name = "org.fudo/tattler";
|
||||
primaryNamespace = "tattler.cli";
|
||||
src = ./.;
|
||||
};
|
||||
};
|
||||
|
||||
devShells = rec {
|
||||
default = updateDeps;
|
||||
updateDeps = pkgs.mkShell {
|
||||
buildInputs = with helpers.packages."${system}";
|
||||
[ updateClojureDeps ];
|
||||
};
|
||||
tattler = pkgs.mkShell {
|
||||
buildInputs = with self.packages."${system}"; [ tattler-server ];
|
||||
};
|
||||
};
|
||||
}) // {
|
||||
nixosModules = rec {
|
||||
default = tattler;
|
||||
tattler = import ./module.nix self.packages;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
packages:
|
||||
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
tattler = packages."${pkgs.system}".tattler;
|
||||
cfg = config.services.tattler;
|
||||
|
||||
in {
|
||||
options.services.tattler = with types; {
|
||||
enable = mkEnableOption "Enable Tattler notification listener.";
|
||||
|
||||
verbose = mkEnableOption "Generate verbose logs and output.";
|
||||
|
||||
notification-topic = mkOption {
|
||||
type = str;
|
||||
description = "MQTT topic on which to send notifications.";
|
||||
};
|
||||
|
||||
mqtt = {
|
||||
host = mkOption {
|
||||
type = str;
|
||||
description = "Hostname of the MQTT server.";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = port;
|
||||
description = "Port on which the MQTT server is listening.";
|
||||
default = 1883;
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
type = nullOr str;
|
||||
description = "User as which to connect to the MQTT server.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
password-file = mkOption {
|
||||
type = nullOr str;
|
||||
description =
|
||||
"User password file with which to connect to the MQTT server.";
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf enable {
|
||||
systemd.user.services.tattler = {
|
||||
path = [ tattler ];
|
||||
wantedBy = [ "default.target" ];
|
||||
serviceConfig = {
|
||||
ExecStart = pkgs.writeShellScript "tattler.sh" (concatStringsSep " " ([
|
||||
"tattler"
|
||||
"--mqtt-host=${cfg.mqtt.host}"
|
||||
"--mqtt-port=${cfg.mqtt.port}"
|
||||
"--notification-topic=${cfg.notification-topic}"
|
||||
] ++ (optional cfg.verbose "--verbose")
|
||||
++ (optional cfg.mqtt.user "--mqtt-user=${cfg.mqtt.user}")
|
||||
++ (optional cfg.mqtt.password-file
|
||||
"--mqtt-user=${cfg.mqtt.password-file}")));
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue