hardware: overhaul hardware configuration
- moved nvidia prime `xxxBusId` to machines specific configuration - moved hostname config to flake.nix - added per-machine configuration (example usage: multiple machines with same model)
This commit is contained in:
parent
9f9e060584
commit
89f91afa4e
14 changed files with 134 additions and 73 deletions
33
flake.nix
33
flake.nix
|
@ -40,57 +40,66 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, berberman, home-manager, hosts, hyprland, lanzaboote, nix-darwin, sops-nix, ... } @ inputs: {
|
outputs = { self, nixpkgs, berberman, home-manager, hosts, hyprland, lanzaboote, nix-darwin, sops-nix, ... } @ inputs: {
|
||||||
|
|
||||||
|
# nix-darwin (macOS)
|
||||||
darwinConfigurations = {
|
darwinConfigurations = {
|
||||||
"iMac-macOS" = nix-darwin.lib.darwinSystem {
|
"iMac-macOS" = nix-darwin.lib.darwinSystem {
|
||||||
system = "x86_64-darwin";
|
system = "x86_64-darwin";
|
||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
modules = [
|
modules = [
|
||||||
./darwin
|
./darwin # Entrypoint
|
||||||
./machines/darwin/imac-2017.nix
|
./machines/darwin/imac-2017.nix # Hardware-specific configurations
|
||||||
./users/guanranwang/darwin.nix
|
# Machine-specific configurations (does such stuff even exist on nix-darwin)
|
||||||
./flakes/darwin/home-manager.nix
|
./users/guanranwang/darwin.nix # User-specific configurations
|
||||||
|
./flakes/darwin/home-manager.nix # Flakes
|
||||||
|
|
||||||
|
{ networking.hostName = "iMac-macOS"; }
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
# NixOS
|
||||||
|
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
"81fw-nixos" = nixpkgs.lib.nixosSystem {
|
"81fw-nixos" = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
modules = [
|
modules = [
|
||||||
./nixos # Entrypoint
|
./nixos # Entrypoint
|
||||||
./machines/nixos/81fw-lenovo-legion-y7000.nix
|
./machines/nixos/81fw-lenovo-legion-y7000 # Hardware-specific configurations
|
||||||
./users/guanranwang/nixos.nix
|
./machines/nixos/81fw-lenovo-legion-y7000/machine-1 # Machine-specific configurations
|
||||||
./flakes/nixos/berberman.nix
|
./users/guanranwang/nixos.nix # User-specific configurations
|
||||||
|
./flakes/nixos/berberman.nix # Flakes
|
||||||
./flakes/nixos/home-manager.nix
|
./flakes/nixos/home-manager.nix
|
||||||
./flakes/nixos/hosts.nix
|
./flakes/nixos/hosts.nix
|
||||||
./flakes/nixos/lanzaboote.nix
|
./flakes/nixos/lanzaboote.nix
|
||||||
./flakes/nixos/sops-nix.nix
|
./flakes/nixos/sops-nix.nix
|
||||||
|
|
||||||
|
{ networking.hostName = "81fw-nixos"; }
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Currently un-used.
|
## Currently un-used.
|
||||||
"imac-nixos" = nixpkgs.lib.nixosSystem {
|
"imac-nixos" = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
modules = [
|
modules = [
|
||||||
./nixos
|
./nixos
|
||||||
./machines/nixos/imac-2017.nix
|
./machines/nixos/imac-2017
|
||||||
|
./machines/nixos/imac-2017/machine-1
|
||||||
./users/guanranwag/nixos.nix
|
./users/guanranwag/nixos.nix
|
||||||
./flakes/nixos/berberman.nix
|
./flakes/nixos/berberman.nix
|
||||||
./flakes/nixos/home-manager.nix
|
./flakes/nixos/home-manager.nix
|
||||||
./flakes/nixos/hosts.nix
|
./flakes/nixos/hosts.nix
|
||||||
./flakes/nixos/lanzaboote.nix
|
./flakes/nixos/lanzaboote.nix
|
||||||
./flakes/nixos/sops-nix.nix
|
./flakes/nixos/sops-nix.nix
|
||||||
|
|
||||||
|
{ networking.hostName = "imac-nixos"; }
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Home-Manager
|
# Home-Manager
|
||||||
homeConfigurations = {
|
homeConfigurations = {
|
||||||
"guanranwang@81fw-nixos" = home-manager.lib.homeManagerConfiguration {
|
"guanranwang@81fw-nixos" = home-manager.lib.homeManagerConfiguration {
|
||||||
|
|
7
machines/darwin/imac-2017/default.nix
Normal file
7
machines/darwin/imac-2017/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./hardware.nix
|
||||||
|
];
|
||||||
|
}
|
|
@ -8,7 +8,6 @@
|
||||||
"Thunderbolt Bridge 2"
|
"Thunderbolt Bridge 2"
|
||||||
"iPhone USB"
|
"iPhone USB"
|
||||||
];
|
];
|
||||||
networking.hostName = "iMac-macOS";
|
|
||||||
|
|
||||||
# The platform the configuration will be used on.
|
# The platform the configuration will be used on.
|
||||||
nixpkgs.hostPlatform = "x86_64-darwin";
|
nixpkgs.hostPlatform = "x86_64-darwin";
|
7
machines/nixos/81fw-lenovo-legion-y7000/default.nix
Normal file
7
machines/nixos/81fw-lenovo-legion-y7000/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./hardware.nix
|
||||||
|
];
|
||||||
|
}
|
32
machines/nixos/81fw-lenovo-legion-y7000/hardware.nix
Executable file
32
machines/nixos/81fw-lenovo-legion-y7000/hardware.nix
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
{ lib, modulesPath, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
../hardware/misc/audio.nix
|
||||||
|
../hardware/misc/bluetooth.nix
|
||||||
|
../hardware/misc/opengl.nix
|
||||||
|
../hardware/cpu/intel.nix
|
||||||
|
../hardware/gpu/intel.nix
|
||||||
|
../hardware/gpu/nvidia.nix
|
||||||
|
../hardware/gpu/nvidia-prime.nix
|
||||||
|
../hardware/accessories/xbox.nix
|
||||||
|
(modulesPath + "/installer/scan/not-detected.nix") # what is this
|
||||||
|
];
|
||||||
|
|
||||||
|
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" ];
|
||||||
|
services.fstrim.enable = true;
|
||||||
|
|
||||||
|
# Nvidia PRIME
|
||||||
|
hardware.nvidia.prime = {
|
||||||
|
nvidiaBusId = "PCI:1:0:0";
|
||||||
|
intelBusId = "PCI:0:2:0";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||||
|
networking.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.enp7s0.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.wlan0.useDHCP = lib.mkDefault true;
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./partition.nix
|
||||||
|
];
|
||||||
|
}
|
28
machines/nixos/81fw-lenovo-legion-y7000.nix → machines/nixos/81fw-lenovo-legion-y7000/machine-1/partition.nix
Executable file → Normal file
28
machines/nixos/81fw-lenovo-legion-y7000.nix → machines/nixos/81fw-lenovo-legion-y7000/machine-1/partition.nix
Executable file → Normal file
|
@ -1,22 +1,6 @@
|
||||||
{ lib, modulesPath, ... }:
|
{ ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
|
||||||
./hardware/misc/audio.nix
|
|
||||||
./hardware/misc/bluetooth.nix
|
|
||||||
./hardware/misc/opengl.nix
|
|
||||||
./hardware/cpu/intel.nix
|
|
||||||
./hardware/gpu/intel.nix
|
|
||||||
./hardware/gpu/nvidia.nix
|
|
||||||
./hardware/gpu/nvidia-prime.nix
|
|
||||||
./hardware/accessories/xbox.nix
|
|
||||||
(modulesPath + "/installer/scan/not-detected.nix") # what is this
|
|
||||||
];
|
|
||||||
|
|
||||||
networking.hostName = "81fw-nixos";
|
|
||||||
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" ];
|
|
||||||
services.fstrim.enable = true;
|
|
||||||
|
|
||||||
fileSystems = {
|
fileSystems = {
|
||||||
"/" = {
|
"/" = {
|
||||||
device = "/dev/disk/by-uuid/6288ce7a-a153-4302-a4de-5dc71f58da79";
|
device = "/dev/disk/by-uuid/6288ce7a-a153-4302-a4de-5dc71f58da79";
|
||||||
|
@ -54,14 +38,4 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
swapDevices = [ { device = "/dev/disk/by-uuid/0ba792d3-571d-44bb-8696-82126611784d"; } ];
|
swapDevices = [ { device = "/dev/disk/by-uuid/0ba792d3-571d-44bb-8696-82126611784d"; } ];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
|
||||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
|
||||||
# still possible to use this option, but it's recommended to use it in conjunction
|
|
||||||
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
|
||||||
networking.useDHCP = lib.mkDefault true;
|
|
||||||
# networking.interfaces.enp7s0.useDHCP = lib.mkDefault true;
|
|
||||||
# networking.interfaces.wlan0.useDHCP = lib.mkDefault true;
|
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
# Following https://nixos.wiki/wiki/Intel_Graphics
|
||||||
{
|
{
|
||||||
boot.initrd.kernelModules = [ "i915" ]; # if not enabled, plymouth's distro logo wont show for some reason
|
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; }; };
|
nixpkgs.config.packageOverrides = pkgs: { vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; }; };
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
{
|
{
|
||||||
hardware.nvidia.prime = {
|
hardware.nvidia.prime = {
|
||||||
sync.enable = false;
|
sync.enable = false;
|
||||||
nvidiaBusId = "PCI:1:0:0";
|
|
||||||
intelBusId = "PCI:0:2:0";
|
### Device specific, please put those configuration in `machines/your-machine.nix`
|
||||||
|
# nvidiaBusId = "PCI:1:0:0";
|
||||||
|
# intelBusId = "PCI:0:2:0";
|
||||||
offload = {
|
offload = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableOffloadCmd = true;
|
enableOffloadCmd = true;
|
||||||
|
|
7
machines/nixos/imac-2017/default.nix
Normal file
7
machines/nixos/imac-2017/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./hardware.nix
|
||||||
|
];
|
||||||
|
}
|
|
@ -2,44 +2,21 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./hardware/misc/audio.nix
|
../hardware/misc/audio.nix
|
||||||
./hardware/misc/bluetooth.nix
|
../hardware/misc/bluetooth.nix
|
||||||
./hardware/misc/opengl.nix
|
../hardware/misc/opengl.nix
|
||||||
./hardware/cpu/intel.nix
|
../hardware/cpu/intel.nix
|
||||||
./hardware/gpu/amd.nix
|
../hardware/gpu/amd.nix
|
||||||
(modulesPath + "/hardware/network/broadcom-43xx.nix")
|
(modulesPath + "/hardware/network/broadcom-43xx.nix")
|
||||||
(modulesPath + "/installer/scan/not-detected.nix") # what is this
|
(modulesPath + "/installer/scan/not-detected.nix") # what is this
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = "imac-nixos";
|
|
||||||
|
|
||||||
# from nixos-hardware
|
# from nixos-hardware
|
||||||
boot.kernelParams = [ "hid_apple.iso_layout=0" ];
|
boot.kernelParams = [ "hid_apple.iso_layout=0" ];
|
||||||
hardware.facetimehd.enable = true; # cam already works before adding this
|
hardware.facetimehd.enable = true; # cam already works before adding this, not sure what is the point
|
||||||
|
|
||||||
# Setup keyfile
|
|
||||||
boot.initrd.secrets = {
|
|
||||||
"/crypto_keyfile.bin" = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" "sdhci_pci" ];
|
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" "sdhci_pci" ];
|
||||||
|
|
||||||
fileSystems = {
|
|
||||||
"/boot" = {
|
|
||||||
device = "/dev/disk/by-uuid/67E3-17ED";
|
|
||||||
fsType = "vfat";
|
|
||||||
};
|
|
||||||
|
|
||||||
"/" = {
|
|
||||||
device = "/dev/disk/by-uuid/571588f1-dc9c-4804-a89c-995a667e0574";
|
|
||||||
fsType = "ext4";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
boot.initrd.luks.devices."luks-998ea901-91c0-4c20-82f4-5dbcce1e1877".device = "/dev/disk/by-uuid/998ea901-91c0-4c20-82f4-5dbcce1e1877";
|
|
||||||
|
|
||||||
swapDevices = [ ];
|
|
||||||
|
|
||||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
# still possible to use this option, but it's recommended to use it in conjunction
|
# still possible to use this option, but it's recommended to use it in conjunction
|
8
machines/nixos/imac-2017/machine-1/default.nix
Normal file
8
machines/nixos/imac-2017/machine-1/default.nix
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./partition.nix
|
||||||
|
./luks.nix
|
||||||
|
];
|
||||||
|
}
|
14
machines/nixos/imac-2017/machine-1/luks.nix
Normal file
14
machines/nixos/imac-2017/machine-1/luks.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
# I have no idea what are those options
|
||||||
|
# and I dont use LUKS on my main machine...
|
||||||
|
# Assuming those are LUKS stuff :P
|
||||||
|
#
|
||||||
|
# it just works(tm)
|
||||||
|
{
|
||||||
|
# Setup keyfile
|
||||||
|
boot.initrd.secrets = {
|
||||||
|
"/crypto_keyfile.bin" = null;
|
||||||
|
};
|
||||||
|
boot.initrd.luks.devices."luks-998ea901-91c0-4c20-82f4-5dbcce1e1877".device = "/dev/disk/by-uuid/998ea901-91c0-4c20-82f4-5dbcce1e1877";
|
||||||
|
}
|
17
machines/nixos/imac-2017/machine-1/partition.nix
Normal file
17
machines/nixos/imac-2017/machine-1/partition.nix
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
fileSystems = {
|
||||||
|
"/boot" = {
|
||||||
|
device = "/dev/disk/by-uuid/67E3-17ED";
|
||||||
|
fsType = "vfat";
|
||||||
|
};
|
||||||
|
|
||||||
|
"/" = {
|
||||||
|
device = "/dev/disk/by-uuid/571588f1-dc9c-4804-a89c-995a667e0574";
|
||||||
|
fsType = "ext4";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
swapDevices = [ ];
|
||||||
|
}
|
Loading…
Reference in a new issue