{ lib, sources, pkgs, ... }: let inherit (lib) mkOption concatStringsSep ; inherit (lib.types) attrsOf listOf submodule enum path 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 }; node_meta = mkOption { type = unspecified; readOnly = true; }; }; config.node_meta = rec { inherit (config) version; patches = [ ./nginx-fallback.patch ] ++ config.patches; overlay-paths = [ "${sources.kat-pkgs}/overlay.nix" ] ++ 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); }; }