this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: initial Apple Silicon support

Khue Doan 25c95cfd 51144453

+191 -8
+1
Makefile
··· 6 6 build: 7 7 sudo nixos-rebuild \ 8 8 --flake '.#${host}' \ 9 + ${flags} \ 9 10 switch 10 11 11 12 test:
+64
README.md
··· 38 38 make install host=HOSTNAME disk=/dev/DISK 39 39 ``` 40 40 41 + ### Install on Apple Silicon MacBook Pro 42 + 43 + The `macbookpro` host uses [nixos-apple-silicon](https://github.com/nix-community/nixos-apple-silicon) 44 + for Apple Silicon support. Partitioning is managed by the Asahi installer 45 + (shared with macOS), not disko, so the installation process differs from x86 hosts. 46 + 47 + 1. In macOS, run the Asahi installer to set up a UEFI boot environment: 48 + 49 + ```sh 50 + curl https://alx.sh | sh 51 + ``` 52 + 53 + Choose "Resize an existing partition" to make room (at least 20GB), then 54 + "UEFI environment only". Name it NixOS. Follow the prompts to set permissive 55 + security and reboot. 56 + 57 + 2. Download the latest installer ISO from the 58 + [nixos-apple-silicon releases](https://github.com/nix-community/nixos-apple-silicon/releases) 59 + page and write it to a USB drive: 60 + 61 + ```sh 62 + sudo dd bs=4M if=/path/to/nixos-apple-silicon.iso of=/dev/sdX conv=fsync oflag=direct status=progress 63 + ``` 64 + 65 + 3. Shut down the Mac, insert the USB drive, and power on. U-Boot should boot 66 + from USB automatically. If it boots the internal disk instead, hit a key to 67 + stop autoboot, run `bootmenu`, and select the `usb 0` entry. 68 + 69 + 4. Partition and format the free space: 70 + 71 + ```sh 72 + sudo -i 73 + sgdisk /dev/nvme0n1 -n 0:0 -s 74 + # Check the partition table to identify the new partition number (type 8300) 75 + sgdisk /dev/nvme0n1 -p 76 + mkfs.ext4 -L nixos /dev/nvme0n1pN # replace N with actual partition number 77 + ``` 78 + 79 + 5. Mount the partitions: 80 + 81 + ```sh 82 + mount /dev/disk/by-label/nixos /mnt 83 + mkdir -p /mnt/boot 84 + mount /dev/disk/by-partuuid/$(cat /proc/device-tree/chosen/asahi,efi-system-partition) /mnt/boot 85 + ``` 86 + 87 + 6. Connect to Wi-Fi and install: 88 + 89 + ```sh 90 + iwctl station wlan0 connect YOUR_SSID 91 + systemctl restart systemd-timesyncd 92 + nix-shell -p git gnumake 93 + git clone https://github.com/khuedoan/nixos-setup 94 + cd nixos-setup 95 + nixos-install --flake '.#macbookpro' --impure 96 + ``` 97 + 98 + 7. After rebooting into the new system, update the `/boot` PARTUUID in 99 + `hosts/macbookpro/default.nix` with the actual value from step 5 and rebuild: 100 + 101 + ```sh 102 + make build host=macbookpro flags=--impure 103 + ``` 104 + 41 105 ### Apply changes 42 106 43 107 After installation, clone your repository again and apply changes to the
+58 -7
flake.lock
··· 20 20 "type": "github" 21 21 } 22 22 }, 23 + "flake-compat": { 24 + "locked": { 25 + "lastModified": 1761640442, 26 + "narHash": "sha256-AtrEP6Jmdvrqiv4x2xa5mrtaIp3OEe8uBYCDZDS+hu8=", 27 + "owner": "nix-community", 28 + "repo": "flake-compat", 29 + "rev": "4a56054d8ffc173222d09dad23adf4ba946c8884", 30 + "type": "github" 31 + }, 32 + "original": { 33 + "owner": "nix-community", 34 + "repo": "flake-compat", 35 + "type": "github" 36 + } 37 + }, 23 38 "home-manager": { 24 39 "inputs": { 25 40 "nixpkgs": [ ··· 41 56 "type": "github" 42 57 } 43 58 }, 59 + "nixos-apple-silicon": { 60 + "inputs": { 61 + "flake-compat": "flake-compat", 62 + "nixpkgs": "nixpkgs" 63 + }, 64 + "locked": { 65 + "lastModified": 1772616144, 66 + "narHash": "sha256-PpvyCx2GY/0S3i3HFgZ7M1/w1gpoV+on4dgP7CiUh/Y=", 67 + "owner": "nix-community", 68 + "repo": "nixos-apple-silicon", 69 + "rev": "0adc6d6a5fffc0b33ba612d8b5b61bdd35ecd350", 70 + "type": "github" 71 + }, 72 + "original": { 73 + "owner": "nix-community", 74 + "repo": "nixos-apple-silicon", 75 + "type": "github" 76 + } 77 + }, 44 78 "nixos-hardware": { 45 79 "locked": { 46 80 "lastModified": 1771423359, ··· 59 93 }, 60 94 "nixpkgs": { 61 95 "locked": { 62 - "lastModified": 1771574726, 63 - "narHash": "sha256-D1PA3xQv/s4W3lnR9yJFSld8UOLr0a/cBWMQMXS+1Qg=", 64 - "owner": "nixos", 96 + "lastModified": 1768305791, 97 + "narHash": "sha256-AIdl6WAn9aymeaH/NvBj0H9qM+XuAuYbGMZaP0zcXAQ=", 98 + "owner": "NixOS", 65 99 "repo": "nixpkgs", 66 - "rev": "c217913993d6c6f6805c3b1a3bda5e639adfde6d", 100 + "rev": "1412caf7bf9e660f2f962917c14b1ea1c3bc695e", 67 101 "type": "github" 68 102 }, 69 103 "original": { 70 - "owner": "nixos", 71 - "ref": "nixos-25.11", 104 + "owner": "NixOS", 105 + "ref": "nixos-unstable", 72 106 "repo": "nixpkgs", 73 107 "type": "github" 74 108 } ··· 89 123 "type": "github" 90 124 } 91 125 }, 126 + "nixpkgs_2": { 127 + "locked": { 128 + "lastModified": 1771574726, 129 + "narHash": "sha256-D1PA3xQv/s4W3lnR9yJFSld8UOLr0a/cBWMQMXS+1Qg=", 130 + "owner": "nixos", 131 + "repo": "nixpkgs", 132 + "rev": "c217913993d6c6f6805c3b1a3bda5e639adfde6d", 133 + "type": "github" 134 + }, 135 + "original": { 136 + "owner": "nixos", 137 + "ref": "nixos-25.11", 138 + "repo": "nixpkgs", 139 + "type": "github" 140 + } 141 + }, 92 142 "root": { 93 143 "inputs": { 94 144 "disko": "disko", 95 145 "home-manager": "home-manager", 146 + "nixos-apple-silicon": "nixos-apple-silicon", 96 147 "nixos-hardware": "nixos-hardware", 97 - "nixpkgs": "nixpkgs", 148 + "nixpkgs": "nixpkgs_2", 98 149 "nixpkgs-unstable": "nixpkgs-unstable" 99 150 } 100 151 }
+12 -1
flake.nix
··· 15 15 nixos-hardware = { 16 16 url = "github:NixOS/nixos-hardware/master"; 17 17 }; 18 + nixos-apple-silicon = { 19 + url = "github:nix-community/nixos-apple-silicon"; 20 + }; 18 21 home-manager = { 19 22 url = "github:nix-community/home-manager/release-25.11"; 20 23 inputs.nixpkgs.follows = "nixpkgs"; 21 24 }; 22 25 }; 23 26 24 - outputs = { self, nixpkgs, nixpkgs-unstable, disko, nixos-hardware, home-manager }: 27 + outputs = { self, nixpkgs, nixpkgs-unstable, disko, nixos-hardware, nixos-apple-silicon, home-manager }: 25 28 let 26 29 baseModules = [ 27 30 disko.nixosModules.disko ··· 57 60 codeserver = nixpkgs.lib.nixosSystem { 58 61 modules = baseModules ++ [ 59 62 ./hosts/codeserver 63 + ]; 64 + }; 65 + macbookpro = nixpkgs.lib.nixosSystem { 66 + modules = baseModules ++ [ 67 + nixos-apple-silicon.nixosModules.apple-silicon-support 68 + { nixpkgs.overlays = [ nixos-apple-silicon.overlays.apple-silicon-overlay ]; } 69 + ./graphical.nix 70 + ./hosts/macbookpro 60 71 ]; 61 72 }; 62 73 };
+56
hosts/macbookpro/default.nix
··· 1 + { lib, ... }: 2 + 3 + { 4 + nixpkgs.hostPlatform = "aarch64-linux"; 5 + 6 + networking.hostName = "macbookpro"; 7 + 8 + # Override shared x86 disko layout, Asahi installer manages partitioning 9 + disko.devices = lib.mkForce {}; 10 + 11 + boot = { 12 + loader = { 13 + systemd-boot.enable = true; 14 + efi.canTouchEfiVariables = lib.mkForce false; 15 + }; 16 + binfmt.emulatedSystems = lib.mkForce []; 17 + }; 18 + 19 + # Filesystem mounts (update UUIDs after install) 20 + # Root partition labeled during mkfs.ext4 -L nixos 21 + # Boot partition PARTUUID from: cat /proc/device-tree/chosen/asahi,efi-system-partition 22 + fileSystems = { 23 + "/" = { 24 + device = "/dev/disk/by-label/nixos"; 25 + fsType = "ext4"; 26 + }; 27 + "/boot" = { 28 + device = lib.mkDefault "/dev/disk/by-partuuid/PLACEHOLDER"; 29 + fsType = "vfat"; 30 + }; 31 + }; 32 + 33 + # Peripheral firmware from EFI partition (requires --impure flag when building) 34 + hardware.asahi.peripheralFirmwareDirectory = /boot/asahi; 35 + 36 + # Binary cache for Asahi kernel 37 + nix.settings = { 38 + extra-substituters = [ 39 + "https://nixos-apple-silicon.cachix.org" 40 + ]; 41 + extra-trusted-public-keys = [ 42 + "nixos-apple-silicon.cachix.org-1:8psDu5SA5dAD7qA0zMy5UT292TxeEPzIz8VVEr2Js20=" 43 + ]; 44 + }; 45 + 46 + home-manager.users.khuedoan.home.file = { 47 + ".config/sway/config.d/hardware".text = '' 48 + output "eDP-1" { 49 + scale 2 50 + } 51 + 52 + bindswitch --reload --locked lid:on output eDP-1 disable 53 + bindswitch --reload --locked lid:off output eDP-1 enable 54 + ''; 55 + }; 56 + }