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

View file

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

View file

@ -83,7 +83,7 @@
nixosModule = { pkgs, config, ... }: { nixosModule = { pkgs, config, ... }: {
programs.bash.interactiveShellInit = '' 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"; lab.vmMacAddress = "BA:DB:EE:F0:00:00";

View file

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

View file

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