From 841f1b5e9d6022bbe07825d06861ccb4f73cfa41 Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 12 Mar 2024 18:06:52 +0000 Subject: add service --- .gitignore | 1 + flake.nix | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/flake.nix b/flake.nix index 742af2f..6d629dd 100644 --- a/flake.nix +++ b/flake.nix @@ -136,6 +136,48 @@ inherit (nixpkgsFor."${system}") flaresolverr; }); + nixosModules.default = { config, pkgs, lib, ... }: + with lib; + let + cfg = config.services.flaresolverr; + in + { + options = { + services.flaresolverr = { + enable = mkOption { + default = false; + description = '' + Whether to enable flaresolverr. + ''; + }; + }; + + openFirewall = mkOption { + type = types.bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + + systemd.services.flaresolverr = { + description = "FlareSolverr"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.flaresolverr}/bin/flaresolverr"; + Restart = "on-failure"; + }; + }; + + networking.firewall = mkIf cfg.openFirewall { + allowedTCPPorts = [ 8191 ]; + }; + }; + }; + defaultPackage = forAllSystems (system: self.packages."${system}".flaresolverr); }; -- cgit v1.2.3