diff --git a/flake.nix b/flake.nix index 2251a62..b2d7d15 100755 --- a/flake.nix +++ b/flake.nix @@ -40,57 +40,66 @@ }; outputs = { self, nixpkgs, berberman, home-manager, hosts, hyprland, lanzaboote, nix-darwin, sops-nix, ... } @ inputs: { + + # nix-darwin (macOS) darwinConfigurations = { "iMac-macOS" = nix-darwin.lib.darwinSystem { system = "x86_64-darwin"; specialArgs = { inherit inputs; }; modules = [ - ./darwin - ./machines/darwin/imac-2017.nix - ./users/guanranwang/darwin.nix - ./flakes/darwin/home-manager.nix + ./darwin # Entrypoint + ./machines/darwin/imac-2017.nix # Hardware-specific configurations + # Machine-specific configurations (does such stuff even exist on nix-darwin) + ./users/guanranwang/darwin.nix # User-specific configurations + ./flakes/darwin/home-manager.nix # Flakes + + { networking.hostName = "iMac-macOS"; } ]; }; }; - - + # NixOS nixosConfigurations = { "81fw-nixos" = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { inherit inputs; }; modules = [ - ./nixos # Entrypoint - ./machines/nixos/81fw-lenovo-legion-y7000.nix - ./users/guanranwang/nixos.nix - ./flakes/nixos/berberman.nix + ./nixos # Entrypoint + ./machines/nixos/81fw-lenovo-legion-y7000 # Hardware-specific configurations + ./machines/nixos/81fw-lenovo-legion-y7000/machine-1 # Machine-specific configurations + ./users/guanranwang/nixos.nix # User-specific configurations + ./flakes/nixos/berberman.nix # Flakes ./flakes/nixos/home-manager.nix ./flakes/nixos/hosts.nix ./flakes/nixos/lanzaboote.nix ./flakes/nixos/sops-nix.nix + + { networking.hostName = "81fw-nixos"; } ]; }; - # Currently un-used. + ## Currently un-used. "imac-nixos" = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { inherit inputs; }; modules = [ ./nixos - ./machines/nixos/imac-2017.nix + ./machines/nixos/imac-2017 + ./machines/nixos/imac-2017/machine-1 ./users/guanranwag/nixos.nix ./flakes/nixos/berberman.nix ./flakes/nixos/home-manager.nix ./flakes/nixos/hosts.nix ./flakes/nixos/lanzaboote.nix ./flakes/nixos/sops-nix.nix + + { networking.hostName = "imac-nixos"; } ]; }; }; - # Home-Manager homeConfigurations = { "guanranwang@81fw-nixos" = home-manager.lib.homeManagerConfiguration { diff --git a/machines/darwin/imac-2017/default.nix b/machines/darwin/imac-2017/default.nix new file mode 100644 index 0000000..08c9b06 --- /dev/null +++ b/machines/darwin/imac-2017/default.nix @@ -0,0 +1,7 @@ +{ ... }: + +{ + imports = [ + ./hardware.nix + ]; +} \ No newline at end of file diff --git a/machines/darwin/imac-2017.nix b/machines/darwin/imac-2017/hardware.nix similarity index 86% rename from machines/darwin/imac-2017.nix rename to machines/darwin/imac-2017/hardware.nix index abc76a8..9246ca5 100644 --- a/machines/darwin/imac-2017.nix +++ b/machines/darwin/imac-2017/hardware.nix @@ -8,7 +8,6 @@ "Thunderbolt Bridge 2" "iPhone USB" ]; - networking.hostName = "iMac-macOS"; # The platform the configuration will be used on. nixpkgs.hostPlatform = "x86_64-darwin"; diff --git a/machines/nixos/81fw-lenovo-legion-y7000/default.nix b/machines/nixos/81fw-lenovo-legion-y7000/default.nix new file mode 100644 index 0000000..08c9b06 --- /dev/null +++ b/machines/nixos/81fw-lenovo-legion-y7000/default.nix @@ -0,0 +1,7 @@ +{ ... }: + +{ + imports = [ + ./hardware.nix + ]; +} \ No newline at end of file diff --git a/machines/nixos/81fw-lenovo-legion-y7000/hardware.nix b/machines/nixos/81fw-lenovo-legion-y7000/hardware.nix new file mode 100755 index 0000000..d55f8fd --- /dev/null +++ b/machines/nixos/81fw-lenovo-legion-y7000/hardware.nix @@ -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..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp7s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlan0.useDHCP = lib.mkDefault true; +} diff --git a/machines/nixos/81fw-lenovo-legion-y7000/machine-1/default.nix b/machines/nixos/81fw-lenovo-legion-y7000/machine-1/default.nix new file mode 100644 index 0000000..1e181dc --- /dev/null +++ b/machines/nixos/81fw-lenovo-legion-y7000/machine-1/default.nix @@ -0,0 +1,7 @@ +{ ... }: + +{ + imports = [ + ./partition.nix + ]; +} \ No newline at end of file diff --git a/machines/nixos/81fw-lenovo-legion-y7000.nix b/machines/nixos/81fw-lenovo-legion-y7000/machine-1/partition.nix old mode 100755 new mode 100644 similarity index 50% rename from machines/nixos/81fw-lenovo-legion-y7000.nix rename to machines/nixos/81fw-lenovo-legion-y7000/machine-1/partition.nix index 2915788..917a766 --- a/machines/nixos/81fw-lenovo-legion-y7000.nix +++ b/machines/nixos/81fw-lenovo-legion-y7000/machine-1/partition.nix @@ -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 = { "/" = { 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"; } ]; - - - - # 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..useDHCP`. - networking.useDHCP = lib.mkDefault true; - # networking.interfaces.enp7s0.useDHCP = lib.mkDefault true; - # networking.interfaces.wlan0.useDHCP = lib.mkDefault true; -} +} \ No newline at end of file diff --git a/machines/nixos/hardware/gpu/intel.nix b/machines/nixos/hardware/gpu/intel.nix index cb39f3b..6d755ce 100644 --- a/machines/nixos/hardware/gpu/intel.nix +++ b/machines/nixos/hardware/gpu/intel.nix @@ -1,5 +1,6 @@ { 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; }; }; diff --git a/machines/nixos/hardware/gpu/nvidia-prime.nix b/machines/nixos/hardware/gpu/nvidia-prime.nix index 582a3bd..54e5ca1 100755 --- a/machines/nixos/hardware/gpu/nvidia-prime.nix +++ b/machines/nixos/hardware/gpu/nvidia-prime.nix @@ -4,8 +4,10 @@ { hardware.nvidia.prime = { 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 = { enable = true; enableOffloadCmd = true; diff --git a/machines/nixos/imac-2017/default.nix b/machines/nixos/imac-2017/default.nix new file mode 100644 index 0000000..08c9b06 --- /dev/null +++ b/machines/nixos/imac-2017/default.nix @@ -0,0 +1,7 @@ +{ ... }: + +{ + imports = [ + ./hardware.nix + ]; +} \ No newline at end of file diff --git a/machines/nixos/imac-2017.nix b/machines/nixos/imac-2017/hardware.nix similarity index 58% rename from machines/nixos/imac-2017.nix rename to machines/nixos/imac-2017/hardware.nix index d95cfd2..906a3e3 100755 --- a/machines/nixos/imac-2017.nix +++ b/machines/nixos/imac-2017/hardware.nix @@ -2,44 +2,21 @@ { 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 ]; - networking.hostName = "imac-nixos"; - # from nixos-hardware boot.kernelParams = [ "hid_apple.iso_layout=0" ]; - hardware.facetimehd.enable = true; # cam already works before adding this - - # Setup keyfile - boot.initrd.secrets = { - "/crypto_keyfile.bin" = null; - }; + hardware.facetimehd.enable = true; # cam already works before adding this, not sure what is the point 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 # (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 diff --git a/machines/nixos/imac-2017/machine-1/default.nix b/machines/nixos/imac-2017/machine-1/default.nix new file mode 100644 index 0000000..5190f87 --- /dev/null +++ b/machines/nixos/imac-2017/machine-1/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + ./partition.nix + ./luks.nix + ]; +} \ No newline at end of file diff --git a/machines/nixos/imac-2017/machine-1/luks.nix b/machines/nixos/imac-2017/machine-1/luks.nix new file mode 100644 index 0000000..4da95a7 --- /dev/null +++ b/machines/nixos/imac-2017/machine-1/luks.nix @@ -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"; +} \ No newline at end of file diff --git a/machines/nixos/imac-2017/machine-1/partition.nix b/machines/nixos/imac-2017/machine-1/partition.nix new file mode 100644 index 0000000..eef2716 --- /dev/null +++ b/machines/nixos/imac-2017/machine-1/partition.nix @@ -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 = [ ]; +} \ No newline at end of file