nixos,modules: add myFlake.nixos.hardware
This commit is contained in:
parent
f98ee5581a
commit
cb4dc0815d
32 changed files with 336 additions and 198 deletions
|
@ -202,7 +202,7 @@
|
|||
./users/guanranwang/nixos/profiles/desktop/addtional/torrenting.nix
|
||||
|
||||
# Hardware
|
||||
./nixos/hardware/81fw-lenovo-legion-y7000/Aristotle
|
||||
./nixos/hardware/lenovo/legion/81fw/Aristotle
|
||||
|
||||
{networking.hostName = "Aristotle";}
|
||||
];
|
||||
|
@ -220,7 +220,7 @@
|
|||
./users/guanranwang/darwin/profiles/desktop
|
||||
./users/guanranwang/darwin/profiles/core/addtional/networking/clash-meta-client.nix
|
||||
|
||||
./darwin/hardware/imac-2017
|
||||
./darwin/hardware/apple/imac/18-3
|
||||
|
||||
{networking.hostName = "Plato";}
|
||||
];
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./hardware.nix
|
||||
];
|
||||
}
|
10
nixos/hardware/imac-2017/hardware.nix → nixos/hardware/apple/imac/18-3/default.nix
Executable file → Normal file
10
nixos/hardware/imac-2017/hardware.nix → nixos/hardware/apple/imac/18-3/default.nix
Executable file → Normal file
|
@ -4,11 +4,11 @@
|
|||
...
|
||||
}: {
|
||||
imports = [
|
||||
../hardware/misc/audio.nix
|
||||
../hardware/misc/bluetooth.nix
|
||||
../hardware/misc/opengl.nix
|
||||
../hardware/cpu/intel.nix
|
||||
../hardware/gpu/amd.nix
|
||||
../../../hardware/misc/audio.nix
|
||||
../../../hardware/misc/bluetooth.nix
|
||||
../../../hardware/misc/opengl.nix
|
||||
../../../hardware/cpu/intel.nix
|
||||
../../../hardware/gpu/amd.nix
|
||||
(modulesPath + "/hardware/network/broadcom-43xx.nix")
|
||||
(modulesPath + "/installer/scan/not-detected.nix") # what is this
|
||||
];
|
|
@ -1,5 +0,0 @@
|
|||
{...}: {
|
||||
boot.kernelModules = ["kvm-intel"];
|
||||
hardware.cpu.intel.updateMicrocode = true;
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
{pkgs, ...}:
|
||||
# FOLLOWING https://nixos.wiki/wiki/AMD_GPU DIRECTLY
|
||||
# I HAVE NO IDEA WHAT AM I DOING
|
||||
{
|
||||
boot.initrd.kernelModules = ["amdgpu"];
|
||||
services.xserver.videoDrivers = ["amdgpu"];
|
||||
|
||||
# OpenCL
|
||||
hardware.opengl = {
|
||||
extraPackages = with pkgs; [
|
||||
amdvlk
|
||||
rocm-opencl-icd
|
||||
rocm-opencl-runtime
|
||||
];
|
||||
# Only available on unstable
|
||||
extraPackages32 = with pkgs; [
|
||||
driversi686Linux.amdvlk
|
||||
];
|
||||
};
|
||||
|
||||
# HIP
|
||||
systemd.tmpfiles.rules = [
|
||||
"L+ /opt/rocm/hip - - - - ${pkgs.hip}"
|
||||
];
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
{pkgs, ...}:
|
||||
# Following https://nixos.wiki/wiki/Intel_Graphics
|
||||
{
|
||||
boot.initrd.kernelModules = ["i915"]; # if not enabled, plymouth's distro logo wont show for some reason
|
||||
nixpkgs.config.packageOverrides = pkgs: {vaapiIntel = pkgs.vaapiIntel.override {enableHybridCodec = true;};};
|
||||
|
||||
hardware.opengl = {
|
||||
extraPackages = with pkgs; [
|
||||
intel-media-driver # libva_driver_name=ihd
|
||||
vaapiIntel # libva_driver_name=i965 (older but works better for firefox/chromium)
|
||||
vaapiVdpau
|
||||
libvdpau-va-gl
|
||||
intel-compute-runtime # intel opencl
|
||||
intel-media-driver # intel vaapi
|
||||
];
|
||||
extraPackages32 = with pkgs; [pkgsi686Linux.vaapiIntel];
|
||||
};
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
{...}:
|
||||
# Nvidia Prime ( multi gpu on laptop )
|
||||
{
|
||||
hardware.nvidia.prime = {
|
||||
sync.enable = false;
|
||||
|
||||
### Device specific, please put those configuration in `machines/your-machine.nix`
|
||||
# nvidiaBusId = "PCI:1:0:0";
|
||||
# intelBusId = "PCI:0:2:0";
|
||||
offload = {
|
||||
enable = true;
|
||||
enableOffloadCmd = true;
|
||||
};
|
||||
};
|
||||
environment.sessionVariables = {
|
||||
"GAMEMODERUNEXEC" = "env __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia __VK_LAYER_NV_optimus=NVIDIA_only"; # gamemode: nvidia offload
|
||||
};
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{config, ...}:
|
||||
# NVIDIA drivers
|
||||
# fuck you nvidia btw
|
||||
{
|
||||
services.xserver.videoDrivers = ["nvidia"]; # tell xorg to use the nvidia driver, also valid for wayland
|
||||
hardware.nvidia = {
|
||||
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
open = false;
|
||||
modesetting.enable = true;
|
||||
#dynamicboost.enable = true;
|
||||
powerManagement = {
|
||||
enable = true; # experimental power management feature
|
||||
#finegrained = true;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{lib, ...}:
|
||||
# Audio system (pipewire)
|
||||
{
|
||||
security.rtkit.enable = true;
|
||||
hardware.pulseaudio.enable = lib.mkDefault false;
|
||||
services.pipewire = {
|
||||
enable = lib.mkDefault true;
|
||||
pulse.enable = true;
|
||||
jack.enable = true;
|
||||
wireplumber.enable = true;
|
||||
alsa = {
|
||||
enable = true;
|
||||
support32Bit = true;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
{pkgs, ...}:
|
||||
# Bluetooth
|
||||
{
|
||||
# Bluetooth manager
|
||||
#services.blueman.enable = true;
|
||||
environment.systemPackages = with pkgs; [blueberry];
|
||||
|
||||
# Bluetooth service
|
||||
hardware.bluetooth = {
|
||||
enable = true;
|
||||
settings.General.FastConnectable = true;
|
||||
};
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
{...}:
|
||||
# OpenGL
|
||||
{
|
||||
hardware = {
|
||||
opengl = {
|
||||
enable = true;
|
||||
driSupport = true;
|
||||
driSupport32Bit = true;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
{...}: {
|
||||
# TPM is currently broken on latest kernel,
|
||||
# but luckily, linux-zen have a patch for it
|
||||
# UPDATE: it got fixed in 6.5.3
|
||||
security.tpm2 = {
|
||||
enable = true;
|
||||
pkcs11.enable = true; # expose /run/current-system/sw/lib/libtpm2_pkcs11.so
|
||||
tctiEnvironment.enable = true; # tpm2tools_tcti and tpm2_pkcs11_tcti env variables
|
||||
};
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./hardware.nix
|
||||
];
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
../default.nix
|
||||
../../../../nixos/flake-modules/lanzaboote.nix
|
||||
../../../../nixos/flake-modules/impermanence.nix
|
||||
../../../../nixos/flake-modules/disko.nix
|
||||
../../../../../flake-modules/lanzaboote.nix
|
||||
../../../../../flake-modules/impermanence.nix
|
||||
../../../../../flake-modules/disko.nix
|
||||
];
|
||||
|
||||
_module.args.disks = ["/dev/nvme0n1"]; # Disko
|
22
nixos/hardware/81fw-lenovo-legion-y7000/hardware.nix → nixos/hardware/lenovo/legion/81fw/default.nix
Executable file → Normal file
22
nixos/hardware/81fw-lenovo-legion-y7000/hardware.nix → nixos/hardware/lenovo/legion/81fw/default.nix
Executable file → Normal file
|
@ -4,19 +4,23 @@
|
|||
...
|
||||
}: {
|
||||
imports = [
|
||||
../hardware/misc/audio.nix
|
||||
../hardware/misc/bluetooth.nix
|
||||
../hardware/misc/opengl.nix
|
||||
../hardware/misc/tpm.nix
|
||||
../hardware/cpu/intel.nix
|
||||
../hardware/gpu/intel.nix
|
||||
../hardware/gpu/nvidia.nix
|
||||
../hardware/gpu/nvidia-prime.nix
|
||||
(modulesPath + "/installer/scan/not-detected.nix") # what is this
|
||||
];
|
||||
|
||||
myFlake.nixos.hardware = {
|
||||
cpu.intel.enable = true;
|
||||
|
||||
gpu.intel.enable = true;
|
||||
gpu.nvidia.enable = true;
|
||||
gpu.nvidia.prime = true;
|
||||
|
||||
misc.audio.enable = true;
|
||||
misc.bluetooth.enable = true;
|
||||
misc.fstrim.enable = true;
|
||||
misc.tpm.enable = true;
|
||||
};
|
||||
|
||||
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid"];
|
||||
services.fstrim.enable = true;
|
||||
|
||||
# Nvidia PRIME
|
||||
hardware.nvidia.prime = {
|
|
@ -2,23 +2,26 @@
|
|||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
}: let
|
||||
cfg = config.myFlake.nixos.boot;
|
||||
in {
|
||||
options = {
|
||||
myFlake.nixos = {
|
||||
boot = {
|
||||
silentBoot = lib.mkEnableOption "Enable silent boot";
|
||||
noLoaderMenu = lib.mkEnableOption "Disable bootloader menu";
|
||||
silentBoot = lib.mkEnableOption "Whether to enable silent boot.";
|
||||
noLoaderMenu = lib.mkEnableOption "Whether to disable bootloader menu.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
### myFlake.nixos.boot.noLoaderMenu
|
||||
config.boot.loader.timeout = lib.mkIf config.myFlake.nixos.boot.noLoaderMenu 0;
|
||||
config = {
|
||||
### cfg.noLoaderMenu
|
||||
boot.loader.timeout = lib.mkIf cfg.noLoaderMenu 0;
|
||||
|
||||
### myFlake.nixos.boot.silentBoot
|
||||
config.boot.consoleLogLevel = lib.mkIf config.myFlake.nixos.boot.silentBoot 0;
|
||||
config.boot.kernelParams =
|
||||
lib.mkIf config.myFlake.nixos.boot.silentBoot
|
||||
### cfg.silentBoot
|
||||
boot.consoleLogLevel = lib.mkIf cfg.silentBoot 0;
|
||||
boot.kernelParams =
|
||||
lib.mkIf cfg.silentBoot
|
||||
(["quiet"]
|
||||
++ lib.optionals config.boot.initrd.systemd.enable [
|
||||
"systemd.show_status=auto"
|
||||
|
@ -26,7 +29,7 @@
|
|||
]);
|
||||
|
||||
### Misc
|
||||
config.boot.loader = {
|
||||
boot.loader = {
|
||||
efi.canTouchEfiVariables = true;
|
||||
systemd-boot = {
|
||||
enable = lib.mkDefault true; # mkDefault for Lanzaboote
|
||||
|
@ -36,4 +39,5 @@
|
|||
#memtest86.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./boot
|
||||
./hardware
|
||||
./networking
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./hardware.nix
|
||||
./intel.nix
|
||||
];
|
||||
}
|
17
nixos/modules/hardware/cpu/intel.nix
Executable file
17
nixos/modules/hardware/cpu/intel.nix
Executable file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.nixos.hardware.cpu.intel;
|
||||
in {
|
||||
options = {
|
||||
myFlake.nixos.hardware.cpu.intel.enable = lib.mkEnableOption "Whether to enable Intel CPU.";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
boot.kernelModules = ["kvm-intel"];
|
||||
hardware.cpu.intel.updateMicrocode = true;
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
};
|
||||
}
|
7
nixos/modules/hardware/default.nix
Normal file
7
nixos/modules/hardware/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./cpu
|
||||
./gpu
|
||||
./misc
|
||||
];
|
||||
}
|
42
nixos/modules/hardware/gpu/amd.nix
Normal file
42
nixos/modules/hardware/gpu/amd.nix
Normal file
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.nixos.hardware.gpu.amd;
|
||||
in {
|
||||
options = {
|
||||
myFlake.nixos.hardware.gpu.amd.enable = lib.mkEnableOption "Whether to enable AMD GPU.";
|
||||
};
|
||||
|
||||
# https://nixos.wiki/wiki/AMD_GPU
|
||||
config = lib.mkIf cfg.enable {
|
||||
hardware.opengl = {
|
||||
enable = true;
|
||||
driSupport = true;
|
||||
driSupport32Bit = true;
|
||||
};
|
||||
|
||||
boot.initrd.kernelModules = ["amdgpu"];
|
||||
services.xserver.videoDrivers = ["amdgpu"];
|
||||
|
||||
# OpenCL
|
||||
hardware.opengl = {
|
||||
extraPackages = with pkgs; [
|
||||
amdvlk
|
||||
rocm-opencl-icd
|
||||
rocm-opencl-runtime
|
||||
];
|
||||
# Only available on unstable
|
||||
extraPackages32 = with pkgs; [
|
||||
driversi686Linux.amdvlk
|
||||
];
|
||||
};
|
||||
|
||||
# HIP
|
||||
systemd.tmpfiles.rules = [
|
||||
"L+ /opt/rocm/hip - - - - ${pkgs.hip}"
|
||||
];
|
||||
};
|
||||
}
|
7
nixos/modules/hardware/gpu/default.nix
Normal file
7
nixos/modules/hardware/gpu/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./amd.nix
|
||||
./intel.nix
|
||||
./nvidia.nix
|
||||
];
|
||||
}
|
36
nixos/modules/hardware/gpu/intel.nix
Normal file
36
nixos/modules/hardware/gpu/intel.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.nixos.hardware.gpu.intel;
|
||||
in {
|
||||
options = {
|
||||
myFlake.nixos.hardware.gpu.intel.enable = lib.mkEnableOption "Whether to enable Intel GPU.";
|
||||
};
|
||||
|
||||
# https://nixos.wiki/wiki/Intel_Graphics
|
||||
config = lib.mkIf cfg.enable {
|
||||
hardware.opengl = {
|
||||
enable = true;
|
||||
driSupport = true;
|
||||
driSupport32Bit = true;
|
||||
};
|
||||
|
||||
boot.initrd.kernelModules = ["i915"]; # if not enabled, plymouth's distro logo wont show for some reason
|
||||
nixpkgs.config.packageOverrides = pkgs: {vaapiIntel = pkgs.vaapiIntel.override {enableHybridCodec = true;};};
|
||||
|
||||
hardware.opengl = {
|
||||
extraPackages = with pkgs; [
|
||||
intel-media-driver # libva_driver_name=ihd
|
||||
vaapiIntel # libva_driver_name=i965 (older but works better for firefox/chromium)
|
||||
vaapiVdpau
|
||||
libvdpau-va-gl
|
||||
intel-compute-runtime # intel opencl
|
||||
intel-media-driver # intel vaapi
|
||||
];
|
||||
extraPackages32 = with pkgs; [pkgsi686Linux.vaapiIntel];
|
||||
};
|
||||
};
|
||||
}
|
48
nixos/modules/hardware/gpu/nvidia.nix
Executable file
48
nixos/modules/hardware/gpu/nvidia.nix
Executable file
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.nixos.hardware.gpu.nvidia;
|
||||
in {
|
||||
options = {
|
||||
myFlake.nixos.hardware.gpu.nvidia.enable = lib.mkEnableOption "Whether to enable NVIDIA GPU.";
|
||||
myFlake.nixos.hardware.gpu.nvidia.prime = lib.mkEnableOption "Whether to enable NVIDIA Prime.";
|
||||
};
|
||||
|
||||
# https://nixos.wiki/wiki/Nvidia
|
||||
config = lib.mkIf cfg.enable {
|
||||
hardware.opengl = {
|
||||
enable = true;
|
||||
driSupport = true;
|
||||
driSupport32Bit = true;
|
||||
};
|
||||
|
||||
services.xserver.videoDrivers = ["nvidia"]; # tell xorg to use the nvidia driver, also valid for wayland
|
||||
hardware.nvidia = {
|
||||
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
open = false;
|
||||
modesetting.enable = true;
|
||||
#dynamicboost.enable = true;
|
||||
powerManagement = {
|
||||
enable = true; # experimental power management feature
|
||||
#finegrained = true;
|
||||
};
|
||||
};
|
||||
|
||||
# cfg.prime
|
||||
hardware.nvidia.prime = lib.mkIf cfg.prime {
|
||||
sync.enable = false;
|
||||
offload = {
|
||||
enable = true;
|
||||
enableOffloadCmd = true;
|
||||
};
|
||||
### Device specific, please put those configuration in `machines/your-machine.nix`
|
||||
# nvidiaBusId = "PCI:1:0:0";
|
||||
# intelBusId = "PCI:0:2:0";
|
||||
};
|
||||
environment.sessionVariables = {
|
||||
"GAMEMODERUNEXEC" = lib.mkIf (cfg.prime || config.programs.gamemode.enable) "env __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia __VK_LAYER_NV_optimus=NVIDIA_only"; # gamemode: nvidia offload
|
||||
};
|
||||
};
|
||||
}
|
37
nixos/modules/hardware/misc/audio.nix
Executable file
37
nixos/modules/hardware/misc/audio.nix
Executable file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.nixos.hardware.misc.audio;
|
||||
in {
|
||||
options = {
|
||||
myFlake.nixos.hardware.misc.audio.enable = lib.mkEnableOption "Whether to enable audio.";
|
||||
myFlake.nixos.hardware.misc.audio.soundServer = lib.mkOption {
|
||||
type = lib.types.enum ["pipewire" "pulseaudio"];
|
||||
default = "pipewire";
|
||||
example = "pulseaudio";
|
||||
description = "Select desired sound system.";
|
||||
};
|
||||
};
|
||||
|
||||
# https://nixos.wiki/wiki/PipeWire
|
||||
# https://nixos.wiki/wiki/PulseAudio
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||
(lib.mkIf (cfg.soundServer == "pipewire") {
|
||||
security.rtkit.enable = true;
|
||||
hardware.pulseaudio.enable = false;
|
||||
services.pipewire = {
|
||||
enable = true;
|
||||
alsa.enable = true;
|
||||
alsa.support32Bit = true;
|
||||
pulse.enable = true;
|
||||
jack.enable = true;
|
||||
};
|
||||
})
|
||||
(lib.mkIf (cfg.soundServer == "pulseaudio") {
|
||||
hardware.pulseaudio.enable = true;
|
||||
hardware.pulseaudio.support32Bit = true;
|
||||
})
|
||||
]);
|
||||
}
|
25
nixos/modules/hardware/misc/bluetooth.nix
Executable file
25
nixos/modules/hardware/misc/bluetooth.nix
Executable file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.nixos.hardware.misc.bluetooth;
|
||||
in {
|
||||
options = {
|
||||
myFlake.nixos.hardware.misc.bluetooth.enable = lib.mkEnableOption "Whether to enable bluetooth.";
|
||||
};
|
||||
|
||||
# https://nixos.wiki/wiki/Bluetooth
|
||||
config = lib.mkIf cfg.enable {
|
||||
# Bluetooth manager
|
||||
#services.blueman.enable = true;
|
||||
environment.systemPackages = lib.mkIf config.services.xserver.enable (with pkgs; [blueberry]);
|
||||
|
||||
# Bluetooth service
|
||||
hardware.bluetooth = {
|
||||
enable = true;
|
||||
settings.General.FastConnectable = true;
|
||||
};
|
||||
};
|
||||
}
|
8
nixos/modules/hardware/misc/default.nix
Normal file
8
nixos/modules/hardware/misc/default.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./audio.nix
|
||||
./bluetooth.nix
|
||||
./fstrim.nix
|
||||
./tpm.nix
|
||||
];
|
||||
}
|
15
nixos/modules/hardware/misc/fstrim.nix
Normal file
15
nixos/modules/hardware/misc/fstrim.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.nixos.hardware.misc.fstrim;
|
||||
in {
|
||||
options = {
|
||||
myFlake.nixos.hardware.misc.fstrim.enable = lib.mkEnableOption "Whether to enable SSD triming in background.";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.fstrim.enable = true;
|
||||
};
|
||||
}
|
23
nixos/modules/hardware/misc/tpm.nix
Normal file
23
nixos/modules/hardware/misc/tpm.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.nixos.hardware.misc.tpm;
|
||||
in {
|
||||
options = {
|
||||
myFlake.nixos.hardware.misc.tpm.enable = lib.mkEnableOption "Whether to enable TPM.";
|
||||
};
|
||||
|
||||
# https://nixos.wiki/wiki/TPM
|
||||
config = lib.mkIf cfg.enable {
|
||||
# TPM is currently broken on latest kernel,
|
||||
# but luckily, linux-zen have a patch for it
|
||||
# UPDATE: it got fixed in 6.5.3
|
||||
security.tpm2 = {
|
||||
enable = true;
|
||||
pkcs11.enable = true; # expose /run/current-system/sw/lib/libtpm2_pkcs11.so
|
||||
tctiEnvironment.enable = true; # tpm2tools_tcti and tpm2_pkcs11_tcti env variables
|
||||
};
|
||||
};
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
type = lib.types.enum ["google" "alidns"];
|
||||
default = "google";
|
||||
example = "alidns";
|
||||
description = "Select your DNS provider";
|
||||
description = "Select desired DNS provider.";
|
||||
};
|
||||
|
||||
config.networking.nameservers = lib.mkMerge [
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.nixos.networking.network-configuration-daemon;
|
||||
cfg = config.myFlake.nixos.networking;
|
||||
in {
|
||||
options = {
|
||||
myFlake.nixos = {
|
||||
|
@ -12,20 +12,26 @@ in {
|
|||
type = lib.types.enum ["iwd" "networkmanager" "networkmanager-iwd"];
|
||||
default = "iwd";
|
||||
example = "networkmanager";
|
||||
description = "Select network configuration daemon";
|
||||
description = "Select desired network configuration daemon.";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
networking.wireless.iwd.enable = lib.mkIf (cfg == "iwd" || cfg == "networkmanager-iwd") true;
|
||||
|
||||
networking.networkmanager = lib.mkIf (cfg == "networkmanager" || cfg == "networkmanager-iwd") {
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf (cfg.network-configuration-daemon == "iwd") {
|
||||
networking.wireless.iwd.enable = true;
|
||||
})
|
||||
(lib.mkIf (cfg.network-configuration-daemon == "networkmanager" || cfg.network-configuration-daemon == "networkmanager-iwd") {
|
||||
networking.networkmanager = {
|
||||
enable = true;
|
||||
ethernet.macAddress = "random";
|
||||
wifi.macAddress = "random";
|
||||
wifi.backend = lib.mkIf (cfg == "networkmanager-iwd") "iwd";
|
||||
};
|
||||
};
|
||||
})
|
||||
(lib.mkIf (cfg.network-configuration-daemon == "networkmanager-iwd") {
|
||||
networking.wireless.iwd.enable = true;
|
||||
networking.networkmanager.wifi.backend = "iwd";
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue