Restructure the interna of the flake

This commit is contained in:
Manuel Thalmann 2024-05-01 18:58:39 +02:00
parent b748dab158
commit 92a4e3d332
3 changed files with 59 additions and 55 deletions

View file

@ -8,25 +8,12 @@
outputs = { self, nixpkgs, flake-utils }: outputs = { self, nixpkgs, flake-utils }:
let let
system = import ./lib/system.nix {
inherit nixpkgs;
};
systems = [ systems = [
{ {
name = "nixos"; name = "nixos";
} }
]; ];
in { in
nixosConfigurations = builtins.listToAttrs
(
builtins.map (
{ name, ... }@config:
{
inherit name;
value = system config;
})
systems);
} //
flake-utils.lib.eachDefaultSystem ( flake-utils.lib.eachDefaultSystem (
system: system:
let let
@ -39,5 +26,37 @@
nixos-rebuild nixos-rebuild
]; ];
}); });
}); }
) //
{
nixosConfigurations = builtins.listToAttrs
(
builtins.map (
{ name, system ? "x86_64-linux", ... }@config:
{
inherit name;
value = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
({ ... }: { config._module.args = { machineConfig = config; }; })
./lib/configuration.nix
(
let
configCandidate = ./lib/machines/${name}.nix;
machineConfigPath =
if builtins.pathExists configCandidate
then
configCandidate
else
./lib/hardware/base.nix;
in
machineConfigPath)
];
};
})
systems);
};
} }

25
lib/configuration.nix Normal file
View file

@ -0,0 +1,25 @@
{ machineConfig, ... }: {
imports = [
./modules/custom-build-vm.nix
];
config = {
system.stateVersion = "23.11";
virtualisation =
let
vmConfig = {
virtualisation = {
sharedHostKeys = true;
virt-viewer = true;
};
};
in {
vmVariant = vmConfig;
vmVariantWithBootLoader = vmConfig;
};
# Networking
networking.hostName = machineConfig.name;
};
}

View file

@ -1,40 +0,0 @@
{ nixpkgs }:
{ name, dualBoot ? false } :
let
lib = nixpkgs.lib;
configPath = ./machines/${name}.nix;
machineConfig =
if builtins.pathExists configPath then
configPath
else
./hardware/base.nix;
in lib.nixosSystem {
system = "x86_64-linux";
modules = [
(
{ config, pkgs, lib, ... }: {
imports = [
machineConfig
./modules/custom-build-vm.nix
];
system.stateVersion = "23.11";
virtualisation =
let
vmConfig = {
virtualisation = {
sharedHostKeys = true;
virt-viewer = true;
};
};
in {
vmVariant = vmConfig;
vmVariantWithBootLoader = vmConfig;
};
# Networking
networking.hostName = name;
})
];
}