nixConfig/nixos/flake-module.nix

30 lines
1.1 KiB
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}
#
# a comment regarding pkgs.nixos vs lib.nixosSystem
# while lib.nixosSystem is the usual enduser way to evaluate nixos configurations
# in flakes, pkgs.nixos sets the package set to the packages it comes from.
# This spares us tracking our potentiell overlays and own package additions, but just
# using the right package set to begin with. Using lib.nixosSystem from the flake we would
# need to specify that again.
2023-06-12 06:34:47 +00:00
{ withSystem, lib, inputs, ... }: {
flake = {
nixosConfigurations = withSystem "x86_64-linux" ({ pkgs, ... }:
let
machines = builtins.attrNames (builtins.readDir ./machines);
makeSystem = name:
pkgs.nixos {
imports = [
(import (./. + "/machines/${name}/configuration.nix") inputs)
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);
};
}