{ description = "My machines"; inputs = { # Nixpkgs and unstable nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; # sops-nix sops-nix = { url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; # VSCode community extensions nix-vscode-extensions = { url = "github:nix-community/nix-vscode-extensions"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, sops-nix, ... } @ inputs: with inputs; { # Use nixpkgs-fmt for 'nix fmt' formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt; # Each subdirectory in ./machines is a host. Add them all to # nixosConfigurations. Host configurations need a file called # configuration.nix that will be read first nixosConfigurations = builtins.listToAttrs (map (x: { name = x; value = nixpkgs.lib.nixosSystem { # Make inputs and the flake itself accessible as module parameters. # Technically, adding the inputs is redundant as they can be also # accessed with flake-self.inputs.X, but adding them individually # allows to only pass what is needed to each module. specialArgs = {flake-self = self;} // inputs; system = "x86_64-linux"; modules = [ (./nixos/hosts + "/${x}/default.nix") sops-nix.nixosModules.sops ]; }; }) (builtins.attrNames (builtins.readDir ./nixos/hosts))); }; }