{ inputs = { nixpkgs.url = "nixpkgs/nixos-24.11"; unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; interlude.url = "git+https://git.strudelline.net/nix/interlude"; nixos-generators = { url = "github:nix-community/nixos-generators"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, unstable, interlude, nixos-generators }@inputs: with builtins; with nixpkgs.lib; with interlude.lib; let buildMachine = name: arch: { # the evaluated machine nixosConfigurations."${name}" = let pkgs = import nixpkgs { config = { allowUnfree = true; }; system = arch; }; specialArgs = { basePath = "${toString ./.}"; inherit inputs; }; in nixosSystem ( { inherit pkgs specialArgs; modules = [ (import "${./.}/hosts/${name}.nix") { system.stateVersion = mkForce "24.05"; nix.settings.require-sigs = mkForce false; networking.hostName = name; # Define your hostname. } self.nixosModules.vmFormats self.nixosModules.fixFlakeRegistry ]; }); }; hosts = let hostsPath = "${./.}" + "/hosts"; dirContents = readDir hostsPath; filenames = attrNames dirContents; in concatMap (filterAndStripSuffix ".nix") (filter (n: dirContents."${n}" == "regular") filenames); in foldl recursiveUpdate { nixosModules = { vmFormats = { config, ... }: { imports = [ nixos-generators.nixosModules.all-formats ]; nixpkgs.hostPlatform = "x86_64-linux"; formatConfigs.iso = { ... }: { isoImage.squashfsCompression = "zstd"; }; # the sample format from nixos-generators # formatConfigs.my-custom-format = { config, modulesPath, ... }: { # networking.wireless.networks = { # # ... # }; # }; }; fixFlakeRegistry = { ... }: { nix.registry = { nixpkgs.flake = inputs.nixpkgs; unstable.flake = inputs.unstable; };}; }; } ( [] # lists to recursively merge into the config. ++ (map (h: buildMachine h "x86_64-linux") hosts) ); }