L7KG2HKA2ZOTR3VPQT7MTAL2HFBVVULTUIENWWIKF5QR2XJZ3DDAC self,config,lib,pkgs,...}:letinherit (lib.modules) mkIf;inherit (lib)enabledmergetypes;inherit (config.networking) domain;in{imports = [ (self + /modules/nginx.nix) ];
config.flake.modules.nixos.nix-cache ={config,lib,pkgs,...}:letinherit (lib.modules) mkIf;inherit (lib.types) types;inherit (config.myLib) merge;inherit (config.networking) domain;in{options.cache = {enable = lib.mkEnableOption "nix-serve cache server";
fqdn = lib.mkOption {type = types.str;example = "cache1.example.com";description = "Fully qualified domain name for the cache";};port = lib.mkOption {type = types.port;default = 8006;description = "Port for nix-serve to listen on";};secretKeyFile = lib.mkOption {type = types.path;example = "/run/agenix/nixServeKey";description = "Path to the secret key file for signing the cache";};};config = mkIf config.cache.enable {age.secrets.nixServeKey = {rekeyFile = config.cache.secretKeyFile;owner = "root";};
port = lib.mkOption {type = types.port;default = 8006;description = "Port for nix-serve to listen on";};};
services.nix-serve = enabled {package = pkgs.nix-serve-ng;secretKeyFile = config.age.secrets.nixServeKey.path;bindAddress = "127.0.0.1";inherit (config.cache) port;};
config = mkIf config.cache.enable {services.nix-serve = {enable = true;package = pkgs.nix-serve-ng;secretKeyFile = config.age.secrets.nixServeKey.path;bindAddress = "127.0.0.1";inherit (config.cache) port;};
services.nginx.virtualHosts.${config.cache.fqdn} = merge config.services.nginx.sslTemplate {locations."= /".return = "301 https://${domain}/404";locations."/".proxyPass = "http://127.0.0.1:${toString config.cache.port}";
services.nginx.virtualHosts.${config.cache.fqdn} = merge config.services.nginx.sslTemplate {locations."= /".return = "301 https://${domain}/404";locations."/".proxyPass = "http://127.0.0.1:${toString config.cache.port}";};};