{ description = "NixOS Configuration"; inputs = { nixpkgs-git.url = "github:/NixOS/nixpkgs"; nixpkgs-stable.url = "github:/NixOS/nixpkgs/nixos-24.05"; nixpkgs-unstable.url = "github:/NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:/NixOS/nixpkgs/nixos-unstable"; nixos-hardware.url = "github:NixOS/nixos-hardware/master"; impermanence.url = "github:nix-community/impermanence"; flake-utils.url = "github:numtide/flake-utils"; nixpkgs-wayland = { url = "github:nix-community/nixpkgs-wayland"; inputs.nixpkgs.follows = "nixpkgs"; }; mailserver.url = "gitlab:/simple-nixos-mailserver/nixos-mailserver"; sops-nix = { url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, flake-utils, nixpkgs-wayland, mailserver, sops-nix, ... } @ attrs: flake-utils.lib.eachDefaultSystem ( system: let inherit (nixpkgs) lib; fn = import ./fn.nix {inherit lib;}; pkgs = nixpkgs.legacyPackages."${system}"; machineList = fn.lst { p = toString ./machines; t = "directory"; b = false; }; nixosSystemFor = machine: { name = machine; value = let configFiles = fn.lst { p = toString ./config; b = true; }; pkgsFiles = fn.lst { p = toString ./pkgs; b = true; }; serviceFiles = fn.lst { p = toString ./services; b = true; }; machinePath = lib.concatStringsSep "/" [(toString ./.) "machines" machine]; machineFiles = lib.filter (lib.strings.hasSuffix ".nix") (fn.lst { p = machinePath; b = true; }); in nixpkgs.lib.nixosSystem { inherit system; specialArgs = attrs // { inherit system; inherit fn; }; modules = [ ({config, ...}: {config.nixpkgs.overlays = [nixpkgs-wayland.overlay];}) (toString ./options/machine.nix) sops-nix.nixosModules.sops ] ++ machineFiles ++ configFiles ++ pkgsFiles ++ serviceFiles; }; }; in { apps = { "lint" = { type = "app"; program = "${pkgs.statix}/bin/statix"; }; }; formatter = pkgs.nixfmt-rfc-style; packages.nixosConfigurations = lib.listToAttrs (map nixosSystemFor machineList); } ); }