{ lib, sources, pkgs, ... }: let inherit (lib) concatStringsSep mkOption ; inherit (lib.types) attrsOf bool enum listOf nullOr path str submodule unspecified ; machine_meta = { config, ... }: { options = { version = mkOption { type = enum [ "stable" "unstable" ]; }; patches = mkOption { type = listOf path; default = [ ]; }; overlay-paths = mkOption { type = listOf path; default = [ ]; # /!\ Take care of imported files }; wg-key = mkOption { type = nullOr str; default = null; }; vpn-ip4 = mkOption { type = nullOr str; default = null; }; vpn-hub = mkOption { type = bool; default = false; description = '' Peering with a hub should give access to all subnets, while hubs are the only points with multiple peers. Non hub peers with all hub, and vice-versa. TODO: multiple hubs ? ''; }; subnets = mkOption { type = listOf str; default = [ ]; }; fqdn = mkOption { type = nullOr str; default = null; }; node_meta = mkOption { type = unspecified; readOnly = true; }; }; config.node_meta = rec { inherit (config) version wg-key vpn-ip4 vpn-hub subnets fqdn ; patches = [ ./nginx-fallback.patch ] ++ config.patches; overlay-paths = [ "${sources.kat-pkgs}/overlay.nix" (pkgs.writeText "lix-overlay.nix" '' import "${sources.lix-overlay}/overlay.nix" { lix = ${sources.lix}; } '') ] ++ config.overlay-paths; nixpkgs-paths = { nixpkgs-src = pkgs.applyPatches { src = sources."nixpkgs-${version}"; name = "nixpkgs-${version}-patched"; inherit patches; }; nixpkgs = pkgs.writeText "nixpkgs-entry.nix" '' { overlays ? [ ], ... }@args: import ${nixpkgs-paths.nixpkgs-src} (args // { overlays = [ ${concatStringsSep "\n " (map (p: "(import ${p})") overlay-paths)} ] ++ overlays; }) ''; }; home-manager = "${sources."home-manager-${version}"}/nixos"; nixvim = import sources."nixvim-${version}"; }; }; in { options.machines = mkOption { type = attrsOf (submodule machine_meta); }; }