refactor(nixos): move hardware config options to machine nixos module
This commit is contained in:
parent
91c2790b62
commit
8165d96d7c
15 changed files with 70 additions and 84 deletions
|
@ -6,7 +6,7 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkOption;
|
||||
inherit (lib) mkOption singleton;
|
||||
inherit (lib.types)
|
||||
listOf
|
||||
str
|
||||
|
@ -14,6 +14,7 @@ let
|
|||
submodule
|
||||
;
|
||||
inherit (lib.pantheon) mkStrOption;
|
||||
inherit (lib.snowfall.fs) get-file;
|
||||
rootDir = submodule {
|
||||
options = {
|
||||
directory = mkOption { type = str; };
|
||||
|
@ -73,24 +74,26 @@ in
|
|||
};
|
||||
time.timeZone = "Asia/Singapore";
|
||||
i18n.defaultLocale = "en_US.UTF-8";
|
||||
users.mutableUsers = false;
|
||||
users.groups.users = {
|
||||
gid = 100;
|
||||
members = [ "${config.mainUser.name}" ];
|
||||
users = {
|
||||
mutableUsers = false;
|
||||
groups.users = {
|
||||
gid = 100;
|
||||
members = [ "${config.mainUser.name}" ];
|
||||
};
|
||||
users."${config.mainUser.name}" = {
|
||||
linger = true;
|
||||
uid = 1000;
|
||||
isNormalUser = true;
|
||||
hashedPasswordFile = config.sops.secrets."${config.mainUser.name}/hashedPassword".path;
|
||||
extraGroups = [ "wheel" ];
|
||||
openssh.authorizedKeys.keys = [ config.mainUser.publicKey ];
|
||||
};
|
||||
users.root.openssh.authorizedKeys.keys = singleton config.mainUser.publicKey;
|
||||
};
|
||||
users.users."${config.mainUser.name}" = {
|
||||
linger = true;
|
||||
uid = 1000;
|
||||
isNormalUser = true;
|
||||
hashedPasswordFile = config.sops.secrets."${config.mainUser.name}/hashedPassword".path;
|
||||
extraGroups = [ "wheel" ];
|
||||
openssh.authorizedKeys.keys = [ config.mainUser.publicKey ];
|
||||
};
|
||||
users.users.root.openssh.authorizedKeys.keys = lib.singleton config.mainUser.publicKey;
|
||||
services.getty.autologinUser = config.mainUser.name;
|
||||
security.sudo.wheelNeedsPassword = false;
|
||||
sops = {
|
||||
defaultSopsFile = lib.snowfall.fs.get-file "secrets/secrets.yaml";
|
||||
defaultSopsFile = get-file "secrets/secrets.yaml";
|
||||
age.sshKeyPaths = [ "/persist/home/rafiq/.ssh/id_ed25519" ];
|
||||
secrets = {
|
||||
"keys/openrouter" = { };
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
imports = [ ./x86_64.nix ];
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
inherit (lib) singleton mkOption;
|
||||
inherit (lib.types) enum;
|
||||
cfg = config.hardware.platform;
|
||||
in
|
||||
{
|
||||
options.hardware.platform = mkOption {
|
||||
type = enum [
|
||||
"amd"
|
||||
"intel"
|
||||
];
|
||||
};
|
||||
config = {
|
||||
hardware.cpu.${cfg}.updateMicrocode = true;
|
||||
boot.kernelModules = singleton "kvm-${cfg}";
|
||||
};
|
||||
}
|
|
@ -1,13 +1,16 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib.pantheon) mkStrOption;
|
||||
cfg = config.machine.bootloader;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
options.machine.bootloader = {
|
||||
type = mkStrOption;
|
||||
};
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
boot.initrd.availableKernelModules = [
|
||||
|
@ -20,7 +23,7 @@
|
|||
];
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
}
|
||||
(lib.mkIf (config.system.bootloader == "systemd-boot") {
|
||||
(lib.mkIf (config.machine.bootloader.type == "systemd-boot") {
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
})
|
||||
];
|
|
@ -1,8 +1,12 @@
|
|||
{ lib, ... }:
|
||||
{ lib, modulesPath, ... }:
|
||||
let
|
||||
inherit (lib) singleton;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
config = {
|
||||
services.fwupd.enable = true;
|
||||
persistDirs = singleton "/var/lib/bluetooth";
|
|
@ -2,7 +2,7 @@
|
|||
let
|
||||
inherit (lib) mkIf mkEnableOption;
|
||||
inherit (lib.pantheon) mkStrOption;
|
||||
cfg = config.hardware.drives.btrfs;
|
||||
cfg = config.machine.drives.btrfs;
|
||||
ephemeralRootCfg = {
|
||||
boot.initrd.postDeviceCommands = lib.mkAfter ''
|
||||
mkdir /btrfs_tmp
|
||||
|
@ -44,7 +44,7 @@ let
|
|||
};
|
||||
in
|
||||
{
|
||||
options.hardware.drives.btrfs = {
|
||||
options.machine.drives.btrfs = {
|
||||
enable = mkEnableOption "";
|
||||
drive = mkStrOption;
|
||||
ephemeralRoot = mkEnableOption "";
|
|
@ -11,10 +11,10 @@ let
|
|||
mkEnableOption
|
||||
singleton
|
||||
;
|
||||
cfg = config.hardware.gpu;
|
||||
cfg = config.machine.gpu;
|
||||
in
|
||||
{
|
||||
options.hardware.gpu = {
|
||||
options.machine.gpu = {
|
||||
nvidia.enable = mkEnableOption "";
|
||||
};
|
||||
config = mkMerge [
|
21
modules/nixos/machine/platform/default.nix
Normal file
21
modules/nixos/machine/platform/default.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
inherit (lib) singleton mkOption;
|
||||
inherit (lib.types) enum;
|
||||
cfg = config.machine.platform;
|
||||
in
|
||||
{
|
||||
options.machine.platform = {
|
||||
type = mkOption {
|
||||
type = enum [
|
||||
"amd"
|
||||
"intel"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
hardware.cpu.${cfg.type}.updateMicrocode = true;
|
||||
boot.kernelModules = singleton "kvm-${cfg.type}";
|
||||
};
|
||||
}
|
|
@ -11,10 +11,10 @@ let
|
|||
mkMerge
|
||||
singleton
|
||||
;
|
||||
cfg = config.hardware.usb;
|
||||
cfg = config.machine.usb;
|
||||
in
|
||||
{
|
||||
options.hardware.usb = {
|
||||
options.machine.usb = {
|
||||
automount = mkEnableOption "";
|
||||
enableQmk = mkEnableOption "";
|
||||
};
|
|
@ -15,7 +15,7 @@ mkWebApp {
|
|||
};
|
||||
extraConfig = {
|
||||
assertions = singleton {
|
||||
assertion = config.hardware.gpu.nvidia.enable;
|
||||
assertion = config.machine.gpu.nvidia.enable;
|
||||
message = "You must run the sd-webui-forge service only with an nvidia gpu.";
|
||||
};
|
||||
services.sd-webui-forge = {
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
./boot.nix
|
||||
];
|
||||
|
||||
options.system = {
|
||||
bootloader = lib.pantheon.mkStrOption;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue