simplify flake functions

This commit is contained in:
Pim Kunis 2024-01-28 13:57:36 +01:00
parent a015290fcf
commit 8e9d566d10
2 changed files with 11 additions and 18 deletions

View file

@ -40,20 +40,15 @@
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
machines = import ./nixos/machines;
physicalMachines = lib.filterAttrs (n: v: v.type == "physical") machines;
# TODO: Use mergeAttrLists
mkNixosSystems = systemDef:
nixpkgs.lib.foldlAttrs
(acc: name: machine:
acc // {
"${name}" = nixpkgs.lib.nixosSystem (systemDef name machine);
})
{ }
builtins.mapAttrs
(name: machine:
nixpkgs.lib.nixosSystem (systemDef name machine)
)
physicalMachines;
mkDeployNodes = nodeDef:
# TODO: Use mergeAttrLists
nixpkgs.lib.foldlAttrs
(acc: name: machine: acc // { "${name}" = nodeDef name machine; })
{ }
builtins.mapAttrs
(name: machine: nodeDef name machine)
physicalMachines;
in
{

View file

@ -1,6 +1,5 @@
{
jefke = {
# TODO: model this in a nixos module?
type = "physical";
nixosModule = {
@ -57,7 +56,7 @@
lewis = {
type = "physical";
nixosModule = { pkgs, ... }: {
nixosModule = {
networking.hostName = "lewis";
lab = {
@ -81,14 +80,13 @@
type = "virtual";
hypervisorName = "lewis";
nixosModule = { pkgs, config, ... }: {
nixosModule = { pkgs, ... }: {
networking.hostName = "my-microvm";
lab.vmMacAddress = "BA:DB:EE:F0:00:00";
programs.bash.interactiveShellInit = ''
echo "Hello world from inside a virtual machine!!" | ${pkgs.lolcat}/bin/lolcat
'';
networking.hostName = "my-microvm";
lab.vmMacAddress = "BA:DB:EE:F0:00:00";
};
};
}