Trying to fix flake

This commit is contained in:
rzuasti
2026-01-25 10:37:47 -05:00
parent ea9bc7f13d
commit 18ecdc2f2a
4 changed files with 92 additions and 67 deletions
+17 -67
View File
@@ -8,87 +8,37 @@
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
nix,
}: let }: let
# System types to support. # System types to support.
supportedSystems = ["x86_64-linux"]; supportedSystems = ["x86_64-linux"];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; forEachSystem = nixpkgs.lib.genAttrs supportedSystems;
# Package overlays to include
overlayList = [self.overlays.default];
# Nixpkgs instantiated for supported system types. # Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs {inherit system;}); pkgsBySystem = forEachSystem (system:
import nixpkgs {
inherit system;
overlays = overlayList;
});
version = "0.0.1"; version = "0.0.1";
pname = "oott"; pname = "oott";
in { in rec {
# A Nixpkgs overlay that provides a 'oott' package. # A Nixpkgs overlay that provides a 'oott' package.
overlays.default = final: prev: {oott = final.callPackage self {};}; overlays.default = final: prev: {oott = final.callPackage ./package.nix {};};
# Package definition # Package definition
packages = forAllSystems (system: let packages = forEachSystem (system: {
pkgs = nixpkgsFor.${system}; ${pname} = pkgsBySystem.${system}.${pname};
in { default = pkgsBySystem.${system}.${pname};
${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";
};
}); });
# Module definition # Modules definition
nixosModules = forAllSystems (system: let nixosModules = import ./modules.nix {overlays = overlayList;};
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";
};
};
};
});
}; };
} }
+9
View File
@@ -0,0 +1,9 @@
{overlays}: {
simple-go-server = import ./oott-service.nix;
overlayNixpkgsForThisInstance = {pkgs, ...}: {
nixpkgs = {
inherit overlays;
};
};
}
+49
View File
@@ -0,0 +1,49 @@
{
config,
pkgs,
lib ? pkgs.lib,
...
}:
with lib; let
cfg = config.services.oott;
in {
# Service options
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";
};
};
# Service implementation
config = mkIf cfg.enable {
environment.systemPackages = [pkgs.oott];
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";
};
};
};
}
+17
View File
@@ -0,0 +1,17 @@
{
pkgs,
buildRustPackage,
pname,
version,
}:
buildRustPackage rec {
inherit pname;
inherit version;
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [pkgs.pkg-config];
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
}