diff --git a/hosts/arr/default.nix b/hosts/arr/default.nix index ac3f590..6c0b154 100644 --- a/hosts/arr/default.nix +++ b/hosts/arr/default.nix @@ -1,8 +1,7 @@ -{ - config, - pkgs, - lib, - ... +{ config +, pkgs +, lib +, ... }: { my = { diff --git a/hosts/deadbeef/default.nix b/hosts/deadbeef/default.nix index 3d7a837..ea0caf0 100644 --- a/hosts/deadbeef/default.nix +++ b/hosts/deadbeef/default.nix @@ -49,13 +49,13 @@ audio.enable = false; }; + utils.commons.enable = true; + }; # Vedi https://github.com/TLATER/dotfiles/blob/f989a86890f27f6b089e9d74b7e8356ec8e5683d/home-config/hosts/yui.nix # home-manager.users.pazpi = import "${flake-inputs.self}/home-config/hosts/deadbeef.nix"; - # flake-inputs.self cartella di partenza dove c'รจ flake.nix - # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions # on your system were taken. It's perfectly fine and recommended to leave diff --git a/hosts/default.nix b/hosts/default.nix new file mode 100644 index 0000000..4c69e99 --- /dev/null +++ b/hosts/default.nix @@ -0,0 +1,42 @@ +{ nixpkgs +, home-manager +, nixos-hardware +, agenix +, ... +}: +let + agenixOverlay = final: prev: { + agenix = agenix.packages.${prev.system}.default; + }; + pkgs = system: import nixpkgs { + inherit system; + overlays = [ agenixOverlay ]; + config.allowUnfree = true; + }; +in +{ + deadbeef = nixpkgs.lib.nixosSystem { + pkgs = pkgs "x86_64-linux"; + modules = [ + ./deadbeef + nixos-hardware.nixosModules.dell-xps-15-9560 + home-manager.nixosModules.home-manager + agenix.nixosModules.default + ]; + specialArgs = { + # inherit nixvim nix-index-database; + }; + }; + + arr = nixpkgs.lib.nixosSystem { + pkgs = pkgs "x86_64-linux"; + modules = [ + ./arr + agenix.nixosModules.default + ]; + specialArgs = { + # inherit nixvim nix-index-database; + }; + }; + +} diff --git a/modules/services/default.nix b/modules/services/default.nix index e31221b..87b15f9 100644 --- a/modules/services/default.nix +++ b/modules/services/default.nix @@ -1,7 +1,6 @@ { imports = [ ./download-pod.nix - ./download-pod-old.nix ./nextcloud-podman.nix ]; } diff --git a/modules/services/download-pod-old.nix b/modules/services/download-pod-old.nix deleted file mode 100644 index 50835b3..0000000 --- a/modules/services/download-pod-old.nix +++ /dev/null @@ -1,154 +0,0 @@ -{ - lib, - config, - pkgs, - ... -}: -let - cfg = config.my.services.download-pod-old; -in -{ - options.my.services.download-pod-old = { - enable = lib.mkEnableOption "Enable download services module"; - - proxy = { - enable = lib.mkEnableOption "Enable proxy for the services"; - - hostName = lib.mkOption { - default = "example.com"; - type = lib.types.str; - description = '' - Top level hostname - ''; - }; - - serverName = lib.mkOption { - default = "localhost"; - type = lib.types.str; - description = '' - Server name where Caddy is - ''; - }; - - }; - - dataDir = lib.mkOption { - default = "/mnt/data"; - type = lib.types.str; - description = '' - Base download dir for stuff - ''; - }; - - }; - - config = lib.mkIf cfg.enable { - my.virtualisation.podman.enable = true; - - systemd.services.pod-download = { - description = "Start podman 'download' pod"; - wants = [ "network-online.target" ]; - after = [ "network-online.target" ]; - requiredBy = [ - "podman-jackett.service" - "podman-radarr.service" - "podman-sabnzbd.service" - "podman-sonarr.service" - ]; - unitConfig = { - RequiresMountsFor = "/run/containers"; - }; - serviceConfig = { - Type = "oneshot"; - ExecStart = "-${pkgs.podman}/bin/podman pod create -p 9117:9117 -p 7878:7878 -p 8080:8080 -p 8989:8989 download"; - }; # -p 9117:9117 -p 7878:7878 -p 8080:8080 -p 8989:8989 - #--share cgroup,ipc,uts - path = [ pkgs.podman ]; - }; - - virtualisation.oci-containers.containers = { - jackett = { - image = "linuxserver/jackett"; - autoStart = true; - user = "1000:100"; - ports = [ "9117:9117" ]; - extraOptions = [ - "--init=true" - "--pod=download" - ]; - volumes = [ - "jackett_config:/config" - "${cfg.dataDir}:/data" - ]; - }; - - radarr = { - image = "linuxserver/radarr"; - autoStart = true; - user = "1000:100"; - ports = [ "7878:7878" ]; - extraOptions = [ - "--init=true" - "--pod=download" - ]; - volumes = [ - "radarr_config:/config" - "${cfg.dataDir}:/data" - ]; - }; - - sabnzbd = { - image = "linuxserver/sabnzbd"; - autoStart = true; - user = "1000:100"; - ports = [ "8080:8080" ]; - extraOptions = [ - "--init=true" - "--pod=download" - ]; - volumes = [ - "sabnzbd_config:/config" - "${cfg.dataDir}:/data" - ]; - }; - - sonarr = { - image = "linuxserver/sonarr"; - autoStart = true; - user = "1000:100"; - ports = [ "8989:8989" ]; - extraOptions = [ - "--init=true" - "--pod=download" - ]; - volumes = [ - "sonarr_config:/config" - "${cfg.dataDir}:/data" - ]; - }; - - }; - - services.caddy = lib.mkIf cfg.proxy.enable { - enable = true; - enableReload = false; - virtualHosts = { - "jackett.${cfg.proxy.hostName}".extraConfig = '' - reverse_proxy http://${cfg.proxy.serverName}:9117 - ''; - "radarr.${cfg.proxy.hostName}".extraConfig = '' - reverse_proxy http://${cfg.proxy.serverName}:7878 - ''; - "sabnzbd.${cfg.proxy.hostName}".extraConfig = '' - reverse_proxy http://${cfg.proxy.serverName}:8080 - ''; - "sonarr.${cfg.proxy.hostName}".extraConfig = '' - reverse_proxy http://${cfg.proxy.serverName}:8989 - ''; - }; - - }; - - }; - -} diff --git a/modules/services/download-pod.nix b/modules/services/download-pod.nix index a456a58..9cb6c9b 100644 --- a/modules/services/download-pod.nix +++ b/modules/services/download-pod.nix @@ -72,57 +72,6 @@ in virtualisation.oci-containers.containers = enabledContainers containers; - # virtualisation.oci-containers.containers = { - - # jackett = { - # image = "linuxserver/jackett"; - # autoStart = true; - # extraOptions = [ "--pod=my-pod" ]; - # volumes = [ - # "jackett_config:/config" - # "jackett_data:/data" - # ]; - # }; - - # radarr = { - # image = "linuxserver/radarr"; - # autoStart = true; - # extraOptions = [ "--pod=download" ]; - # volumes = [ - # "radarr_config:/config" - # "radarr_data:/data" - # ]; - # }; - - # sabnzbd = { - # image = "linuxserver/sabnzbd"; - # autoStart = true; - # extraOptions = [ "--pod=download" ]; - # volumes = [ - # "sabnzbd_config:/config" - # "sabnzbd_data:/data" - # ]; - # }; - - # sonarr = { - # image = "linuxserver/sonarr"; - # autoStart = true; - # extraOptions = [ "--pod=download" ]; - # volumes = [ - # "sonarr_config:/config" - # "sonarr_data:/data" - # ]; - # }; - - # prowlarr = { - # image = "linuxserver/prowlarr"; - # autoStart = true; - # extraOptions = [ "--pod=download" ]; - # volumes = [ "prowlarr_config:/config" ]; - # }; - - # }; - services.caddy = lib.mkIf cfg.proxy.enable { enable = true; enableReload = false; diff --git a/modules/virtualisation/podman-pod.nix b/modules/virtualisation/podman-pod.nix index 3a70613..386c429 100644 --- a/modules/virtualisation/podman-pod.nix +++ b/modules/virtualisation/podman-pod.nix @@ -1,8 +1,7 @@ -{ - config, - lib, - pkgs, - ... +{ config +, lib +, pkgs +, ... }: with lib; @@ -10,35 +9,6 @@ with lib; let cfg = config.my.virtualisation.podmanPods; - # Get the options from the original oci-containers module - # containerOptions = ( - # filterAttrs ( - # n: v: n != "definition" - # ) config.virtualisation.oci-containers.containers.type.getSubOptions - # ); - - # containerDefinition = mkOption { - # type = types.attrs; - # description = "The container definition, derived from virtualisation.oci-containers.containers."; - # example = { - # image = "nginx:latest"; - # ports = [ "8080:80" ]; - # }; - # default = { }; - # }; - - # containerDefinition = mkOption { - # type = types.attrs; - # description = "The container definition, derived from virtualisation.oci-containers.containers."; - # example = { - # image = "nginx:latest"; - # ports = [ "8080:80" ]; - # }; - # default = {}; - - # }; - # # config.virtualisation.oci-containers.containers.type.getSubOptions; - containerDefinition = config.virtualisation.oci-containers.containers.type.getSubOptions; # Add our enable option @@ -104,12 +74,6 @@ let fi ''; - # enabledContainers = lib.flatten ( - # mapAttrs ( - # podName: podConfig: filterAttrs (name: value: value.enable or true) podConfig.containers - # ) cfg - # ); - # flattenPodContainers = # pods: # mapAttrs' ( @@ -140,14 +104,6 @@ in environment.systemPackages = [ pkgs.jq ]; - # virtualisation.oci-containers.containers = enabledContainers; - - # virtualisation.oci-containers.containers = flattenPodContainers cfg; - - # virtualisation.oci-containers.containers = lib.mkMerge ( - # map (entry: entry.container) (filter (entry: entry.enable) cfg.containers) - # ); - # virtualisation.oci-containers.containers = listToAttrs (flatten (mapAttrsToList # (podName: podDef: # mapAttrs @@ -162,56 +118,45 @@ in # ) # cfg)); - # virtualisation.oci-containers.containers = lib.flatten - # (mapAttrs - # (podName: podConfig: - # mapAttrs - # (containerName: containerConfig: - # filterAttrs (attrName: attrValue: attrName != "enable") containerConfig - # ) - # (filterAttrs (name: value: value.enable) podConfig.containers) - # ) - # (filterAttrs (podName: podConfig: podConfig.enable) cfg) - # ); - # mapAttrs - # (name: value: - # filterAttrs (n: v: n != "enable") value - # ) - # (filterAttrs (name: value: value.enable) cfg.containers); - networking.firewall.allowedTCPPorts = flatten ( - mapAttrsToList ( - name: podDef: map (portMapping: lib.toInt (lib.head (lib.splitString ":" portMapping))) podDef.ports - ) cfg + mapAttrsToList + ( + name: podDef: map (portMapping: lib.toInt (lib.head (lib.splitString ":" portMapping))) podDef.ports + ) + cfg ); systemd.services = let - podServices = mapAttrs' ( - name: podDef: - nameValuePair "podman-pod-${name}" { - description = "Manage Podman pod: ${name}"; - serviceConfig = { - Type = "oneshot"; - ExecStart = "${createPodScript name podDef}"; - }; - path = [ - pkgs.jq - pkgs.podman - ]; - after = [ "network.target" ]; - wantedBy = [ "multi-user.target" ]; - } - ) cfg; + podServices = mapAttrs' + ( + name: podDef: + nameValuePair "podman-pod-${name}" { + description = "Manage Podman pod: ${name}"; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${createPodScript name podDef}"; + }; + path = [ + pkgs.jq + pkgs.podman + ]; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + } + ) + cfg; - containerServices = mapAttrs' ( - name: container: - nameValuePair "podman-${name}" { - after = [ "podman-pod-${lib.head (lib.splitString "-" name)}.service" ]; - requires = [ "podman-pod-${lib.head (lib.splitString "-" name)}.service" ]; - partOf = [ "podman-pod-${lib.head (lib.splitString "-" name)}.service" ]; - } - ) config.containers; + containerServices = mapAttrs' + ( + name: container: + nameValuePair "podman-${name}" { + after = [ "podman-pod-${lib.head (lib.splitString "-" name)}.service" ]; + requires = [ "podman-pod-${lib.head (lib.splitString "-" name)}.service" ]; + partOf = [ "podman-pod-${lib.head (lib.splitString "-" name)}.service" ]; + } + ) + config.containers; in podServices // containerServices;