tpwrules / nixos-apple-silicon

Resources to install NixOS bare metal on Apple Silicon Macs
MIT License
743 stars 73 forks source link

nixos-apple-silicon works on M2 15" Macbook Air (2023) #116

Closed ingenieroariel closed 7 months ago

ingenieroariel commented 8 months ago

No issue to report, just a big thank you.

I bootstrapped NixOS from Asahi Linux (Arch) by using NIXOS_LUSTRATE by just cloning the nixos-apple-silicon repo under /etc/nixos, manually copying the firmware files to /etc/nixos, adding it to imports and following the official installation guide.

Once I booted into NixOS I configured it as a flake. Webcam worked out of the box. Fantastic!

image

/etc/nixos/flake.nix

{
  inputs.nixpkgs.url = github:NixOS/nixpkgs;

  inputs.apple-silicon = {
      url = github:tpwrules/nixos-apple-silicon;
      inputs.nixpkgs.follows = "nixpkgs";
    };

  outputs = { self, nixpkgs, apple-silicon, ... }@attrs:  let
    system = "aarch64-linux";
    pkgs = import nixpkgs {
      inherit system;
      config.allowUnfree = true;
      overlays = [ 
          apple-silicon.overlays.default
      ];
    };
    in {
    nixosConfigurations.globo = nixpkgs.lib.nixosSystem {
      specialArgs = attrs;
      modules = [
        apple-silicon.nixosModules.default
        ( { config, lib, pkgs, ... }:

        {
          boot.initrd.availableKernelModules = [ ];
          boot.initrd.kernelModules = [ ];
          boot.kernelModules = [ ];
          boot.extraModulePackages = [ ];

          fileSystems."/" =
            { device = "/dev/disk/by-uuid/ba257e07-6525-4927-a250-4c323dac2f62";
              fsType = "ext4";
            };

          fileSystems."/usr/lib/firmware/vendor" =
            { device = "vendorfw";
              fsType = "tmpfs";
            };

          fileSystems."/boot" =
            { device = "/dev/disk/by-uuid/DD5A-4EB6";
              fsType = "vfat";
            };

          swapDevices = [ ];

          networking.useDHCP = lib.mkDefault true;

          nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";

          boot.loader.systemd-boot.enable = true;
          boot.loader.efi.canTouchEfiVariables = false;

          hardware.asahi.peripheralFirmwareDirectory = ./firmware;
          networking.networkmanager.wifi.backend = "iwd";
          networking.wireless.iwd.enable = true;

          hardware.bluetooth.enable = true;
          hardware.bluetooth.powerOnBoot = true; 

          networking.hostName = "globo";
          networking.networkmanager.enable = true;

          time.timeZone = "America/New_York";

          nix.settings.experimental-features = [ "nix-command" "flakes" ];

          environment.systemPackages = with pkgs; [
             kakoune
             ripgrep
             tmux
             wget
             git

             firefox
             chromium

             glxinfo
             mesa-demos
             glmark2

             sway
             arcanPackages.all-wrapped

             fishPlugins.done
             fishPlugins.fzf-fish
             fishPlugins.forgit
             fishPlugins.hydro
             fzf
             fishPlugins.grc
             grc

             foot
             dmenu

             qgis
          ];

          users.users.x = {
           isNormalUser  = true;
           home  = "/x";
           extraGroups  = [ "networkmanager" "input" "video" ];
          };

          users.mutableUsers = true;
          programs.fish.enable = true;
          users.defaultUserShell = pkgs.fish;
          environment.binsh = "${pkgs.dash}/bin/dash";

          services.xserver.enable = true;
          services.xserver.displayManager.sddm.enable = true;
          services.xserver.desktopManager.plasma5.enable = true;

          sound.enable = true;
          hardware.pulseaudio.enable = true;
          hardware.asahi.useExperimentalGPUDriver = true;
          hardware.asahi.addEdgeKernelConfig = true;
          hardware.asahi.withRust = true;

          networking.firewall.enable = true;

          system.stateVersion = "23.11";

        })

       ];
    };
  };
}
tpwrules commented 7 months ago

Thanks for the feedback, it's nice to know that this works properly and is useful.