simplify flake functions
This commit is contained in:
parent
a015290fcf
commit
8e9d566d10
2 changed files with 11 additions and 18 deletions
17
flake.nix
17
flake.nix
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue