create shared entrypoint nixos config for physical and vm

This commit is contained in:
Pim Kunis 2024-01-28 12:30:13 +01:00
parent 32154e7163
commit 371b851ca5
38 changed files with 8 additions and 9 deletions

View file

@ -38,7 +38,7 @@
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
machines = import ./nix/machines;
machines = import ./nixos/machines;
physicalMachines = lib.filterAttrs (n: v: v.type == "physical") machines;
# TODO: Maybe use mergeAttrLists
mkNixosSystems = systemDef:
@ -78,7 +78,7 @@
nixosConfigurations = mkNixosSystems (machine: {
inherit system;
specialArgs = { inherit machines machine kubenix dns microvm disko agenix; };
modules = [ ./nix/physical.nix ];
modules = [ ./nixos ];
});
deploy = {

View file

@ -1,11 +1,13 @@
{ pkgs, machine, disko, agenix, ... }: {
{ pkgs, lib, machine, disko, agenix, ... }: {
imports = [
./modules
./lab.nix
machine.nixosModule
disko.nixosModules.disko
agenix.nixosModules.default
];
]
++ lib.lists.optional (machine.type == "physical") ./physical.nix
++ lib.lists.optional (machine.type == "virtual") ./virtual.nix;
config = {
time.timeZone = "Europe/Amsterdam";

View file

@ -83,7 +83,7 @@
nixosModule = { pkgs, config, ... }: {
programs.bash.interactiveShellInit = ''
echo "Hello world from inside a virtual machine!" | ${pkgs.lolcat}/bin/lolcat
echo "Hello world from inside a virtual machine!!" | ${pkgs.lolcat}/bin/lolcat
'';
lab.vmMacAddress = "BA:DB:EE:F0:00:00";

View file

@ -2,7 +2,6 @@
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
microvm.nixosModules.host
./shared.nix
];
config = {
@ -69,7 +68,7 @@
specialArgs = { inherit agenix disko pkgs lib microvm; machine = vm; hypervisorConfig = config; };
config = {
imports = [
./virtual.nix
./.
];
};
};

View file

@ -1,6 +1,4 @@
{ lib, config, machine, hypervisorConfig, ... }: {
imports = [ ./shared.nix ];
options.lab.vmMacAddress = lib.mkOption {
type = lib.types.str;
description = ''