mirror of
https://github.com/buckley310/nixos-config.git
synced 2024-12-21 19:24:15 +00:00
move hardware stuff from getHosts to module
This commit is contained in:
parent
a117839071
commit
a118b52a02
10 changed files with 40 additions and 20 deletions
|
@ -3,6 +3,7 @@
|
|||
sconfig = {
|
||||
gnome = true;
|
||||
profile = "desktop";
|
||||
hardware = "physical";
|
||||
security-tools = true;
|
||||
i3.extraConfig = ''
|
||||
exec xrandr --output DisplayPort-0 --mode 2560x1440 --rate 165
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
pkgs = "nixpkgs";
|
||||
system = "x86_64-linux";
|
||||
hardware = "physical";
|
||||
module = ./configuration.nix;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
sconfig = {
|
||||
gnome = true;
|
||||
profile = "desktop";
|
||||
hardware = "physical";
|
||||
security-tools = true;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
pkgs = "nixpkgs";
|
||||
system = "x86_64-linux";
|
||||
hardware = "physical";
|
||||
module = ./configuration.nix;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
{
|
||||
sconfig = {
|
||||
profile = "server";
|
||||
hardware = "qemu";
|
||||
};
|
||||
|
||||
environment.persistence."/nix/persist" = {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
pkgs = "nixpkgs";
|
||||
system = "x86_64-linux";
|
||||
hardware = "qemu";
|
||||
module = ./configuration.nix;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
{
|
||||
sconfig = {
|
||||
profile = "desktop";
|
||||
hardware = "physical";
|
||||
gnome = true;
|
||||
security-tools = true;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
pkgs = "nixpkgs";
|
||||
system = "x86_64-linux";
|
||||
hardware = "physical";
|
||||
module = ./configuration.nix;
|
||||
}
|
||||
|
|
|
@ -5,21 +5,6 @@ let
|
|||
(name: _: import (path + "/${name}"))
|
||||
(builtins.readDir path);
|
||||
|
||||
hardwareModules =
|
||||
{
|
||||
physical = (x: {
|
||||
imports = [ "${x.modulesPath}/installer/scan/not-detected.nix" ];
|
||||
});
|
||||
vmware = (x: {
|
||||
virtualisation.vmware.guest.enable = true;
|
||||
boot.initrd.availableKernelModules = [ "mptspi" ];
|
||||
});
|
||||
qemu = (x: {
|
||||
services.qemuGuest.enable = true;
|
||||
imports = [ "${x.modulesPath}/profiles/qemu-guest.nix" ];
|
||||
});
|
||||
};
|
||||
|
||||
getHostConfig = hostName: hostMeta:
|
||||
inputs.${hostMeta.pkgs}.lib.nixosSystem
|
||||
{
|
||||
|
@ -27,7 +12,6 @@ let
|
|||
modules = [
|
||||
(nixosModule)
|
||||
(hostMeta.module)
|
||||
(hardwareModules.${hostMeta.hardware})
|
||||
(_: { networking.hostName = hostName; })
|
||||
(_: {
|
||||
nixpkgs.overlays = [
|
||||
|
|
36
modules/hardware.nix
Normal file
36
modules/hardware.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ config, pkgs, lib, modulesPath, ... }:
|
||||
let
|
||||
|
||||
inherit (pkgs) callPackage;
|
||||
|
||||
hardwareFor = name: cfg: lib.mkIf (config.sconfig.hardware == name) cfg;
|
||||
|
||||
hardwareModules =
|
||||
[
|
||||
(hardwareFor "qemu"
|
||||
{
|
||||
inherit (callPackage "${modulesPath}/profiles/qemu-guest.nix" { }) boot;
|
||||
services.qemuGuest.enable = true;
|
||||
})
|
||||
|
||||
(hardwareFor "vmware"
|
||||
{
|
||||
virtualisation.vmware.guest.enable = true;
|
||||
boot.initrd.availableKernelModules = [ "mptspi" ];
|
||||
})
|
||||
|
||||
(hardwareFor "physical"
|
||||
{
|
||||
inherit (callPackage "${modulesPath}/installer/scan/not-detected.nix" { }) hardware;
|
||||
})
|
||||
];
|
||||
|
||||
in
|
||||
with lib;
|
||||
{
|
||||
options.sconfig.hardware = mkOption {
|
||||
type = types.enum [ "physical" "vmware" "qemu" ];
|
||||
};
|
||||
|
||||
config = fold (a: b: a // b) { } hardwareModules;
|
||||
}
|
Loading…
Reference in a new issue