Skip to content

Instantly share code, notes, and snippets.

@CRTified
Created March 23, 2023 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CRTified/da942b857659c9308d1e62ea094e347c to your computer and use it in GitHub Desktop.
Save CRTified/da942b857659c9308d1e62ea094e347c to your computer and use it in GitHub Desktop.
Example flake with auto population from hosts dir
{
inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; };
outputs = { self, nixpkgs, ... }@inputs:
let
inherit (self) outputs;
files = builtins.readDir ./nix_configs/hosts;
hostnames = builtins.filter
(name: builtins.hasAttr name files && (files.${name} == "directory"))
(builtins.attrNames files);
system = "x86_64-linux";
in {
# nixos configuration entrypoints
nixosConfigurations = builtins.listToAttrs (map (hostname: {
name = hostname;
value = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit inputs; };
modules = [ ./nix_configs/hosts/${hostname} ];
};
}) hostnames);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment