From 18ecdc2f2a2e093a116eeb4a2fde49a690242607 Mon Sep 17 00:00:00 2001 From: rzuasti Date: Sun, 25 Jan 2026 10:37:47 -0500 Subject: [PATCH] Trying to fix flake --- flake.nix | 84 ++++++++++-------------------------------------- modules.nix | 9 ++++++ oott-service.nix | 49 ++++++++++++++++++++++++++++ package.nix | 17 ++++++++++ 4 files changed, 92 insertions(+), 67 deletions(-) create mode 100644 modules.nix create mode 100644 oott-service.nix create mode 100644 package.nix diff --git a/flake.nix b/flake.nix index 1a13b3e..51b5477 100644 --- a/flake.nix +++ b/flake.nix @@ -8,87 +8,37 @@ outputs = { self, nixpkgs, + nix, }: 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; + forEachSystem = nixpkgs.lib.genAttrs supportedSystems; + + # Package overlays to include + overlayList = [self.overlays.default]; # 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"; pname = "oott"; - in { + in rec { # 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 - 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"; - }; + packages = forEachSystem (system: { + ${pname} = pkgsBySystem.${system}.${pname}; + default = pkgsBySystem.${system}.${pname}; }); - # Module definition - 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"; - }; - }; - }; - }); + # Modules definition + nixosModules = import ./modules.nix {overlays = overlayList;}; }; } diff --git a/modules.nix b/modules.nix new file mode 100644 index 0000000..92bf2cc --- /dev/null +++ b/modules.nix @@ -0,0 +1,9 @@ +{overlays}: { + simple-go-server = import ./oott-service.nix; + + overlayNixpkgsForThisInstance = {pkgs, ...}: { + nixpkgs = { + inherit overlays; + }; + }; +} diff --git a/oott-service.nix b/oott-service.nix new file mode 100644 index 0000000..871a71b --- /dev/null +++ b/oott-service.nix @@ -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"; + }; + }; + }; +} diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..64bd2e1 --- /dev/null +++ b/package.nix @@ -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"; +}