diff --git a/nix/modules/nixos/features/homelab/default.nix b/nix/modules/nixos/features/homelab/default.nix index a23216c..c62d843 100644 --- a/nix/modules/nixos/features/homelab/default.nix +++ b/nix/modules/nixos/features/homelab/default.nix @@ -2,7 +2,7 @@ imports = [ ./audiobookshelf.nix ./forgejo.nix - ./freshrss + ./freshrss.nix ./gitea.nix ./immich.nix ./jellyfin.nix diff --git a/nix/modules/nixos/features/homelab/freshrss.nix b/nix/modules/nixos/features/homelab/freshrss.nix new file mode 100644 index 0000000..d353be3 --- /dev/null +++ b/nix/modules/nixos/features/homelab/freshrss.nix @@ -0,0 +1,105 @@ +{ config, lib, ... }: + +with lib; + +let + cfg = config.features.homelab.freshrss; + port = 4003; +in +{ + options.features.homelab.freshrss.enable = mkEnableOption "Enable freshrss"; + + config = mkIf cfg.enable { + # Auto-generated using compose2nix v0.3.2-pre. + virtualisation = { + docker = { + enable = true; + autoPrune.enable = true; + }; + + oci-containers.backend = "docker"; + }; + + virtualisation.oci-containers.containers."freshrss" = { + image = "lscr.io/linuxserver/freshrss:latest"; + + environment = { + "PGID" = "1000"; + "PUID" = "1000"; + "TZ" = "Etc/UTC"; + }; + + volumes = [ + "/home/opdavies/Code/dotfiles/freshrss-config:/config:rw" + ]; + + ports = [ + "${toString port}:80/tcp" + ]; + + log-driver = "journald"; + + extraOptions = [ + "--network-alias=freshrss" + "--network=freshrss_default" + ]; + }; + + systemd.services."docker-freshrss" = { + serviceConfig = { + Restart = lib.mkOverride 90 "always"; + RestartMaxDelaySec = lib.mkOverride 90 "1m"; + RestartSec = lib.mkOverride 90 "100ms"; + RestartSteps = lib.mkOverride 90 9; + }; + + after = [ + "docker-network-freshrss_default.service" + ]; + + requires = [ + "docker-network-freshrss_default.service" + ]; + + partOf = [ + "docker-compose-freshrss-root.target" + ]; + + wantedBy = [ + "docker-compose-freshrss-root.target" + ]; + }; + + systemd.services."docker-network-freshrss_default" = { + path = [ pkgs.docker ]; + + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStop = "docker network rm -f freshrss_default"; + }; + + script = '' + docker network inspect freshrss_default || docker network create freshrss_default + ''; + + partOf = [ "docker-compose-freshrss-root.target" ]; + wantedBy = [ "docker-compose-freshrss-root.target" ]; + }; + + systemd.targets."docker-compose-freshrss-root" = { + unitConfig = { + Description = "Root target generated by compose2nix."; + }; + + wantedBy = [ "multi-user.target" ]; + }; + + services.nginx = { + enable = true; + + virtualHosts."freshrss.oliverdavies.uk".locations."/".proxyPass = + "http://localhost:${toString port}/"; + }; + }; +} diff --git a/nix/modules/nixos/features/homelab/freshrss/container.nix b/nix/modules/nixos/features/homelab/freshrss/container.nix deleted file mode 100644 index 9576d60..0000000 --- a/nix/modules/nixos/features/homelab/freshrss/container.nix +++ /dev/null @@ -1,88 +0,0 @@ -# Auto-generated using compose2nix v0.3.2-pre. -{ pkgs, lib, ... }: - -let - port = 4003; -in -{ - virtualisation.docker = { - enable = true; - autoPrune.enable = true; - }; - virtualisation.oci-containers.backend = "docker"; - - virtualisation.oci-containers.containers."freshrss" = { - image = "lscr.io/linuxserver/freshrss:latest"; - - environment = { - "PGID" = "1000"; - "PUID" = "1000"; - "TZ" = "Etc/UTC"; - }; - - volumes = [ - "/home/opdavies/Code/dotfiles/freshrss-config:/config:rw" - ]; - - ports = [ - "${toString port}:80/tcp" - ]; - - log-driver = "journald"; - - extraOptions = [ - "--network-alias=freshrss" - "--network=freshrss_default" - ]; - }; - - systemd.services."docker-freshrss" = { - serviceConfig = { - Restart = lib.mkOverride 90 "always"; - RestartMaxDelaySec = lib.mkOverride 90 "1m"; - RestartSec = lib.mkOverride 90 "100ms"; - RestartSteps = lib.mkOverride 90 9; - }; - - after = [ - "docker-network-freshrss_default.service" - ]; - - requires = [ - "docker-network-freshrss_default.service" - ]; - - partOf = [ - "docker-compose-freshrss-root.target" - ]; - - wantedBy = [ - "docker-compose-freshrss-root.target" - ]; - }; - - systemd.services."docker-network-freshrss_default" = { - path = [ pkgs.docker ]; - - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - ExecStop = "docker network rm -f freshrss_default"; - }; - - script = '' - docker network inspect freshrss_default || docker network create freshrss_default - ''; - - partOf = [ "docker-compose-freshrss-root.target" ]; - wantedBy = [ "docker-compose-freshrss-root.target" ]; - }; - - systemd.targets."docker-compose-freshrss-root" = { - unitConfig = { - Description = "Root target generated by compose2nix."; - }; - - wantedBy = [ "multi-user.target" ]; - }; -} diff --git a/nix/modules/nixos/features/homelab/freshrss/default.nix b/nix/modules/nixos/features/homelab/freshrss/default.nix deleted file mode 100644 index ea09bdc..0000000 --- a/nix/modules/nixos/features/homelab/freshrss/default.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ pkgs, lib, ... }: - -let - port = 4003; -in -{ - imports = [ ./container.nix ]; - - services.nginx = { - enable = true; - - virtualHosts."freshrss.oliverdavies.uk".locations."/".proxyPass = - "http://localhost:${toString port}/"; - }; -}