nixos-config/flake.nix

40 lines
1.3 KiB
Nix
Raw Normal View History

{
2021-08-04 12:37:55 -07:00
description = "Fudo Host Configuration";
2021-07-28 12:01:06 -07:00
2021-08-09 11:12:39 -07:00
inputs = {
nixpkgs.url = "nixpkgs/nixos-21.05";
home-manager.url = "github:nix-community/home-manager/release-21.05";
2021-07-28 12:01:06 -07:00
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { nixpkgs, home-manager, ... }:
let
2021-08-06 16:25:01 -07:00
hosts-path = ./config/hosts;
2021-08-04 17:12:06 -07:00
lib = nixpkgs.lib;
2021-07-28 12:01:06 -07:00
is-nix-file = filename: type: (builtins.match ".+.nix$" filename) != null;
is-regular-file = filename: type: type == "regular" || type == "link";
hostname-from-file = filename:
builtins.replaceStrings [ ".nix" ] [ "" ] filename;
2021-08-04 17:12:06 -07:00
hosts = map hostname-from-file (lib.attrNames (lib.filterAttrs is-nix-file
2021-08-06 16:25:01 -07:00
(lib.filterAttrs is-regular-file (builtins.readDir hosts-path))));
2021-08-06 16:30:35 -07:00
hostsOpts = lib.listToAttrs (hostname:
lib.nameValuePair hostname (import hosts-path + "/${hostname}.nix"));
2021-07-28 12:01:06 -07:00
2021-08-04 12:37:55 -07:00
pkgs = import nixpkgs { };
2021-07-28 12:01:06 -07:00
in {
2021-08-06 16:30:35 -07:00
nixConfigurations = lib.mapAttrs (hostname: hostOpts:
lib.nixosSystem {
2021-08-06 16:25:01 -07:00
system = hostOpts.platform;
2021-08-04 12:37:55 -07:00
modules = [
(import ./initialize.nix {
hostname = hostname;
home-manager-package = home-manager;
pkgs = pkgs;
include-secrets = true;
})
];
2021-08-06 16:30:35 -07:00
}) hostsOpts;
2021-07-28 12:01:06 -07:00
};
}