From 3bc649b5b9b7d2e0164a07817e5940c25fd2770a Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 7 Jul 2025 09:58:25 +0800 Subject: [PATCH 1/2] refactor: rename modules/flake to flake-parts, hosts to configurations --- nix/{modules/hosts.nix => configurations.nix} | 0 nix/{modules/flake => flake-parts}/files.nix | 0 nix/{modules/flake => flake-parts}/git-hooks.nix | 0 nix/{modules/flake => flake-parts}/make-shell.nix | 0 nix/{modules/flake => flake-parts}/modules.nix | 0 nix/{modules/flake => flake-parts}/text.nix | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename nix/{modules/hosts.nix => configurations.nix} (100%) rename nix/{modules/flake => flake-parts}/files.nix (100%) rename nix/{modules/flake => flake-parts}/git-hooks.nix (100%) rename nix/{modules/flake => flake-parts}/make-shell.nix (100%) rename nix/{modules/flake => flake-parts}/modules.nix (100%) rename nix/{modules/flake => flake-parts}/text.nix (100%) diff --git a/nix/modules/hosts.nix b/nix/configurations.nix similarity index 100% rename from nix/modules/hosts.nix rename to nix/configurations.nix diff --git a/nix/modules/flake/files.nix b/nix/flake-parts/files.nix similarity index 100% rename from nix/modules/flake/files.nix rename to nix/flake-parts/files.nix diff --git a/nix/modules/flake/git-hooks.nix b/nix/flake-parts/git-hooks.nix similarity index 100% rename from nix/modules/flake/git-hooks.nix rename to nix/flake-parts/git-hooks.nix diff --git a/nix/modules/flake/make-shell.nix b/nix/flake-parts/make-shell.nix similarity index 100% rename from nix/modules/flake/make-shell.nix rename to nix/flake-parts/make-shell.nix diff --git a/nix/modules/flake/modules.nix b/nix/flake-parts/modules.nix similarity index 100% rename from nix/modules/flake/modules.nix rename to nix/flake-parts/modules.nix diff --git a/nix/modules/flake/text.nix b/nix/flake-parts/text.nix similarity index 100% rename from nix/modules/flake/text.nix rename to nix/flake-parts/text.nix From 53b88094328d0062db49c4d64a6c0b92f8f135ae Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 7 Jul 2025 10:38:17 +0800 Subject: [PATCH 2/2] feat(nixos): add platform module for different architectures --- nix/manifest.nix | 1 - nix/modules/machine/platform.nix | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 nix/modules/machine/platform.nix diff --git a/nix/manifest.nix b/nix/manifest.nix index cd305e2..f87deed 100644 --- a/nix/manifest.nix +++ b/nix/manifest.nix @@ -6,7 +6,6 @@ let device = "/dev/sda1"; fsType = "ext4"; }; - nixpkgs.hostPlatform = "x86_64-linux"; boot.loader.systemd-boot.enable = true; networking = { inherit hostName; }; }; diff --git a/nix/modules/machine/platform.nix b/nix/modules/machine/platform.nix new file mode 100644 index 0000000..ae8ab61 --- /dev/null +++ b/nix/modules/machine/platform.nix @@ -0,0 +1,14 @@ +{ config, ... }: +{ + flake.modules.nixos.default = + { hostName, ... }: + let + inherit (config.flake.manifest.hosts.nixos.${hostName}.machine) platform; + arch = if platform == "amd" || platform == "intel" then "x86_64" else "aarch64"; + in + { + hardware.cpu.${platform}.updateMicrocode = true; + boot.kernelModules = [ "kvm-${platform}" ]; + nixpkgs.hostPlatform = "${arch}-linux"; + }; +}