Files
oott/flake.nix
T
2026-01-24 19:11:00 -05:00

90 lines
2.4 KiB
Nix

{
description = "OOTT - An easy to setup and use network device monitoring service";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
};
outputs = {
self,
nixpkgs,
}: let
# System types to support.
supportedSystems = ["x86_64-linux"];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs {inherit system;});
version = "0.0.1";
pname = "oott";
in {
packages = forAllSystems (system: let
pkgs = nixpkgsFor.${system};
in {
${pname} = pkgs.rustPlatform.buildRustPackage rec {
inherit pname;
inherit version;
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [pkgs.pkg-config];
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
};
});
nixosModules = forAllSystems (system: let
pkgs = nixpkgsFor.${system};
in
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.oott;
in {
options.services.oott = {
enable = mkEnableOption "Enable oott as a service";
package = mkOption {
type = types.package;
default = self.packages.${system}.oott;
description = "oott package to use";
};
networking.interface = mkOption {
type = types.str;
description = "Network interface to use for scans";
default = "eno1";
};
log.level = mkOption {
type = types.str;
description = "Log level for the oott service";
default = "info";
};
};
config = mkIf cfg.enable {
systemd.services.oott = {
description = "oott - network device scanner";
wantedBy = ["multi-user.target"];
serviceConfig = {
ExecStart = "${cfg.package}/bin/oott ${
builtins.toFile "oott.toml"
(generators.toTOML {} cfg)
}";
ProtectHome = "read-only";
Restart = "on-failure";
Type = "exec";
};
};
};
});
};
}