nixConfig/nixos/flake-module.nix

31 lines
912 B
Nix
Raw Permalink Normal View History

2023-06-12 06:34:47 +00:00
# copied and adopted from maralorns config
2023-06-12 10:02:01 +00:00
# This automatically searches for nixos configs in ./machines/${name}/configuration.nix
# and exposes them as outputs.nixosConfigurations.${name}
2023-11-07 23:47:14 +00:00
{
withSystem,
lib,
inputs,
...
}: {
2023-06-12 06:34:47 +00:00
flake = {
2023-11-07 23:47:14 +00:00
nixosConfigurations = withSystem "x86_64-linux" ({pkgs, ...}: let
2023-06-12 06:34:47 +00:00
machines = builtins.attrNames (builtins.readDir ./machines);
2023-11-07 23:47:14 +00:00
makeSystem = name: let
importedConfig = import (./. + "/machines/${name}/configuration.nix");
systemConfig =
if lib.isFunction importedConfig
then x: importedConfig (x // {flake-inputs = inputs;})
else importedConfig;
in
2023-06-12 06:34:47 +00:00
pkgs.nixos {
imports = [
2023-11-07 23:47:14 +00:00
systemConfig
2023-09-25 19:03:23 +00:00
inputs.sops-nix.nixosModules.sops
2023-09-28 15:12:34 +00:00
inputs.impermanence.nixosModules.impermanence
2023-06-12 06:34:47 +00:00
];
};
2023-11-07 23:47:14 +00:00
in
lib.genAttrs machines makeSystem);
2023-06-12 06:34:47 +00:00
};
}