nixConfig/nixos/flake-module.nix

31 lines
912 B
Nix
Raw 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}
{
withSystem,
lib,
inputs,
...
}: {
2023-06-12 06:34:47 +00:00
flake = {
nixosConfigurations = withSystem "x86_64-linux" ({pkgs, ...}: let
2023-06-12 06:34:47 +00:00
machines = builtins.attrNames (builtins.readDir ./machines);
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 = [
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
];
};
in
lib.genAttrs machines makeSystem);
2023-06-12 06:34:47 +00:00
};
}