From 5b666b91d195a47a76c0da579463da5240c09086 Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Mon, 18 Dec 2023 14:20:44 +0800 Subject: [PATCH] flake: simplify hosts --- darwin/hosts/Plato/default.nix | 22 +++++---- darwin/hosts/Plato/hardware-configuration.nix | 13 ++++++ flake.nix | 45 +------------------ nixos/hosts/Aristotle/default.nix | 41 ++++++++++------- .../Aristotle/hardware-configuration.nix | 21 +++++++++ 5 files changed, 73 insertions(+), 69 deletions(-) create mode 100644 darwin/hosts/Plato/hardware-configuration.nix create mode 100644 nixos/hosts/Aristotle/hardware-configuration.nix diff --git a/darwin/hosts/Plato/default.nix b/darwin/hosts/Plato/default.nix index f08a03b..4f13d6e 100644 --- a/darwin/hosts/Plato/default.nix +++ b/darwin/hosts/Plato/default.nix @@ -1,13 +1,17 @@ # iMac 18,3 (2017) -_: { - networking.knownNetworkServices = [ - "Ethernet" - "Wi-Fi" - "Thunderbolt Bridge" - "Thunderbolt Bridge 2" - "iPhone USB" +{...}: { + imports = [ + ../../profiles/core + ../../profiles/device-type/desktop + + ../../../users/guanranwang/darwin/profiles/core + ../../../users/guanranwang/darwin/profiles/device-type/desktop + ../../../users/guanranwang/darwin/profiles/opt-in/clash-meta-client.nix + + ./hardware.configuration.nix + ../../hardware/apple/imac/18-3 ]; - # The platform the configuration will be used on. - nixpkgs.hostPlatform = "x86_64-darwin"; + networking.hostName = "Plato"; + time.timeZone = "Asia/Shanghai"; } diff --git a/darwin/hosts/Plato/hardware-configuration.nix b/darwin/hosts/Plato/hardware-configuration.nix new file mode 100644 index 0000000..f08a03b --- /dev/null +++ b/darwin/hosts/Plato/hardware-configuration.nix @@ -0,0 +1,13 @@ +# iMac 18,3 (2017) +_: { + networking.knownNetworkServices = [ + "Ethernet" + "Wi-Fi" + "Thunderbolt Bridge" + "Thunderbolt Bridge 2" + "iPhone USB" + ]; + + # The platform the configuration will be used on. + nixpkgs.hostPlatform = "x86_64-darwin"; +} diff --git a/flake.nix b/flake.nix index a92f51a..3fd1376 100755 --- a/flake.nix +++ b/flake.nix @@ -174,53 +174,12 @@ ### NixOS nixosConfigurations = { - "Aristotle" = mkNixOS "x86_64-linux" [ - # OS - ./nixos/profiles/core - ./nixos/profiles/device-type/laptop - ./nixos/profiles/opt-in/zram-generator.nix - ./nixos/profiles/opt-in/gaming.nix - ./nixos/profiles/opt-in/wayland.nix - ./nixos/profiles/opt-in/virt-manager.nix - - # User - ./users/guanranwang/nixos/profiles/core - ./users/guanranwang/nixos/profiles/device-type/laptop - ./users/guanranwang/nixos/profiles/opt-in/clash-meta-client.nix - ./users/guanranwang/nixos/profiles/opt-in/gaming - ./users/guanranwang/nixos/profiles/opt-in/torrenting - - # Hardware - ./nixos/hosts/Aristotle - ./nixos/profiles/opt-in/lanzaboote.nix - ./nixos/profiles/opt-in/impermanence.nix - ./nixos/profiles/opt-in/disko.nix - - { - networking.hostName = "Aristotle"; - time.timeZone = "Asia/Shanghai"; - _module.args.disks = ["/dev/nvme0n1"]; # Disko - } - ]; + "Aristotle" = mkNixOS "x86_64-linux" [./nixos/hosts/Aristotle]; }; ### Darwin darwinConfigurations = { - "Plato" = mkDarwin "x86_64-darwin" [ - ./darwin/profiles/core - ./darwin/profiles/device-type/desktop - - ./users/guanranwang/darwin/profiles/core - ./users/guanranwang/darwin/profiles/device-type/desktop - ./users/guanranwang/darwin/profiles/opt-in/clash-meta-client.nix - - ./darwin/hosts/Plato - - { - networking.hostName = "Plato"; - time.timeZone = "Asia/Shanghai"; - } - ]; + "Plato" = mkDarwin "x86_64-darwin" [./darwin/hosts/Plato]; }; }; } diff --git a/nixos/hosts/Aristotle/default.nix b/nixos/hosts/Aristotle/default.nix index 744ea9f..48613a1 100644 --- a/nixos/hosts/Aristotle/default.nix +++ b/nixos/hosts/Aristotle/default.nix @@ -1,21 +1,28 @@ -{ - modulesPath, - inputs, - ... -}: { +{...}: { imports = [ - (modulesPath + "/installer/scan/not-detected.nix") - inputs.nixos-hardware.nixosModules.lenovo-legion-y530-15ich + # OS + ../../profiles/core + ../../profiles/device-type/laptop + ../../profiles/opt-in/zram-generator.nix + ../../profiles/opt-in/gaming.nix + ../../profiles/opt-in/wayland.nix + ../../profiles/opt-in/virt-manager.nix + + # User + ../../../users/guanranwang/nixos/profiles/core + ../../../users/guanranwang/nixos/profiles/device-type/laptop + ../../../users/guanranwang/nixos/profiles/opt-in/clash-meta-client.nix + ../../../users/guanranwang/nixos/profiles/opt-in/gaming + ../../../users/guanranwang/nixos/profiles/opt-in/torrenting + + # Hardware + ./hardware-configuration.nix + ../../profiles/opt-in/lanzaboote.nix + ../../profiles/opt-in/impermanence.nix + ../../profiles/opt-in/disko.nix ]; - services.hdapsd.enable = false; - myFlake.hardware.components = { - audio.enable = true; - bluetooth.enable = true; - tpm.enable = true; - }; - - boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid"]; - boot.kernelModules = ["kvm-intel"]; - nixpkgs.hostPlatform = "x86_64-linux"; + networking.hostName = "Aristotle"; + time.timeZone = "Asia/Shanghai"; + _module.args.disks = ["/dev/nvme0n1"]; # Disko } diff --git a/nixos/hosts/Aristotle/hardware-configuration.nix b/nixos/hosts/Aristotle/hardware-configuration.nix new file mode 100644 index 0000000..744ea9f --- /dev/null +++ b/nixos/hosts/Aristotle/hardware-configuration.nix @@ -0,0 +1,21 @@ +{ + modulesPath, + inputs, + ... +}: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + inputs.nixos-hardware.nixosModules.lenovo-legion-y530-15ich + ]; + + services.hdapsd.enable = false; + myFlake.hardware.components = { + audio.enable = true; + bluetooth.enable = true; + tpm.enable = true; + }; + + boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid"]; + boot.kernelModules = ["kvm-intel"]; + nixpkgs.hostPlatform = "x86_64-linux"; +}