From 041bc7d3c09ddd4e5a66d2fc5b0e8e0ae241adb1 Mon Sep 17 00:00:00 2001 From: Spotlight Date: Sun, 3 Nov 2024 02:07:38 -0600 Subject: [PATCH] spotlights-macbook-air: Init Linux configuration --- .gitignore | 3 + flake.lock | 72 ++++++++++++-- flake.nix | 27 ++++++ .../spotlights-macbook-air/configuration.nix | 97 +++++++++++++++++++ .../hardware-configuration.nix | 38 ++++++++ 5 files changed, 228 insertions(+), 9 deletions(-) create mode 100644 hosts/linux/spotlights-macbook-air/configuration.nix create mode 100644 hosts/linux/spotlights-macbook-air/hardware-configuration.nix diff --git a/.gitignore b/.gitignore index 9b9ff51..7735e10 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ vim/.netrwhist keysrc + +# macOS-provided firmware +hosts/linux/spotlights-macbook-air/firmware \ No newline at end of file diff --git a/flake.lock b/flake.lock index c5d91a6..d375827 100644 --- a/flake.lock +++ b/flake.lock @@ -15,6 +15,28 @@ "type": "github" } }, + "apple-silicon-support": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1729779640, + "narHash": "sha256-M9t4Ta9d76aVqd1mkLBl8zFSWYc8pv6AZTy1SU5bVp0=", + "owner": "zzywysm", + "repo": "nixos-asahi", + "rev": "5f8823f3543cbf9566d5af49b3a3c18539681eac", + "type": "github" + }, + "original": { + "owner": "zzywysm", + "repo": "nixos-asahi", + "type": "github" + } + }, "darwin-systems": { "locked": { "lastModified": 1689347925, @@ -30,6 +52,21 @@ "type": "github" } }, + "flake-compat": { + "locked": { + "lastModified": 1688025799, + "narHash": "sha256-ktpB4dRtnksm9F5WawoIkEneh1nrEvuxb5lJFt1iOyw=", + "owner": "nix-community", + "repo": "flake-compat", + "rev": "8bf105319d44f6b9f0d764efa4fdef9f1cc9ba1c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -55,11 +92,11 @@ ] }, "locked": { - "lastModified": 1729716953, - "narHash": "sha256-FbRKGRRd0amsk/WS/UV9ukJ8jT1dZ2pJBISxkX+uq6A=", + "lastModified": 1730490306, + "narHash": "sha256-AvCVDswOUM9D368HxYD25RsSKp+5o0L0/JHADjLoD38=", "owner": "nix-community", "repo": "home-manager", - "rev": "a4353cc43d1b4dd6bdeacea90eb92a8b7b78a9d7", + "rev": "1743615b61c7285976f85b303a36cdf88a556503", "type": "github" }, "original": { @@ -90,11 +127,11 @@ ] }, "locked": { - "lastModified": 1729826725, - "narHash": "sha256-w3WNlYxqWYsuzm/jgFPyhncduoDNjot28aC8j39TW0U=", + "lastModified": 1730600078, + "narHash": "sha256-BoyFmE59HDF3uybBySsWVoyjNuHvz3Wv8row/mSb958=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "7840909b00fbd5a183008a6eb251ea307fe4a76e", + "rev": "4652874d014b82cb746173ffc64f6a70044daa7e", "type": "github" }, "original": { @@ -105,11 +142,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1729665710, - "narHash": "sha256-AlcmCXJZPIlO5dmFzV3V2XF6x/OpNWUV8Y/FMPGd8Z4=", + "lastModified": 1730200266, + "narHash": "sha256-l253w0XMT8nWHGXuXqyiIC/bMvh1VRszGXgdpQlfhvU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2768c7d042a37de65bb1b5b3268fc987e534c49d", + "rev": "807e9154dcb16384b1b765ebe9cd2bba2ac287fd", "type": "github" }, "original": { @@ -122,6 +159,7 @@ "root": { "inputs": { "all-systems": "all-systems", + "apple-silicon-support": "apple-silicon-support", "darwin-systems": "darwin-systems", "home-manager": "home-manager", "linux-systems": "linux-systems", @@ -130,6 +168,22 @@ "vscode-server": "vscode-server" } }, + "rust-overlay": { + "flake": false, + "locked": { + "lastModified": 1686795910, + "narHash": "sha256-jDa40qRZ0GRQtP9EMZdf+uCbvzuLnJglTUI2JoHfWDc=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "5c2b97c0a9bc5217fc3dfb1555aae0fb756d99f9", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index c9c47a1..9365444 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,10 @@ inputs = { # Specify the source of Home Manager and Nixpkgs. nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + apple-silicon-support = { + url = "github:zzywysm/nixos-asahi"; + inputs.nixpkgs.follows = "nixpkgs"; + }; # Allows for easy enumeration of available Darwin and Linux systems. all-systems.url = "github:nix-systems/default"; darwin-systems.url = "github:nix-systems/default-darwin"; @@ -130,6 +134,29 @@ ]; }; + nixosConfigurations = { + "spotlights-macbook-air" = nixpkgs.lib.nixosSystem { + system = "aarch64-linux"; + + modules = [ + # Asahi-specific tweaks + inputs.apple-silicon-support.nixosModules.default + ./hosts/linux/spotlights-macbook-air/configuration.nix + + home-manager.nixosModules.home-manager + { + nixpkgs.overlays = [ self.overlays.default ]; + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.spotlight = import ./home/home.nix; + extraSpecialArgs = { desktop = true; gpg = true; }; + }; + } + ]; + }; + }; + # We define a default Darwin configuration via nix-darwin. darwinConfigurations."spotlights-macbook-air" = nix-darwin.lib.darwinSystem { modules = [ diff --git a/hosts/linux/spotlights-macbook-air/configuration.nix b/hosts/linux/spotlights-macbook-air/configuration.nix new file mode 100644 index 0000000..f77a904 --- /dev/null +++ b/hosts/linux/spotlights-macbook-air/configuration.nix @@ -0,0 +1,97 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ config, lib, pkgs, ... }: + +{ + + imports = [ + ./hardware-configuration.nix + ]; + + nix.settings.experimental-features = [ "flakes" "nix-command" ]; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = false; + # GPU enablement + hardware.asahi = { + peripheralFirmwareDirectory = ./firmware; + # GPU enablement + useExperimentalGPUDriver = true; + experimentalGPUInstallMode = "replace"; + withRust = true; + }; + + networking = { + hostName = "spotlights-macbook-air"; + wireless.iwd = { + enable = true; + settings.General.EnableNetworkConfiguration = true; + }; + networkmanager.enable = true; + }; + + services = { + # Enable GNOME + xserver = { + enable = true; + displayManager.gdm.enable = true; + desktopManager.gnome.enable = true; + }; + avahi = { + enable = true; + # Enable .local resolution + nssmdns4 = true; + }; + + # Enable CUPS to print documents. + printing.enable = true; + }; + + # Our user account. + programs.zsh.enable = true; + users.users.spotlight = { + isNormalUser = true; + extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + shell = pkgs.zsh; + }; + + environment.systemPackages = with pkgs; [ + cachix + firefox + git + htop + gnomeExtensions.appindicator + legcord + minicom + nix-output-monitor + python3 + seafile-client + telegram-desktop + tmux + usbutils + vim + vscode + wget + ]; + + # :( + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "vscode" + ]; + + # Allow location services. + location.provider = "geoclue2"; + services.geoclue2.enable = true; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + programs.gnupg.agent = { + enable = true; + pinentryPackage = pkgs.pinentry-gnome3; + }; + + system.stateVersion = "24.05"; +} diff --git a/hosts/linux/spotlights-macbook-air/hardware-configuration.nix b/hosts/linux/spotlights-macbook-air/hardware-configuration.nix new file mode 100644 index 0000000..79c250f --- /dev/null +++ b/hosts/linux/spotlights-macbook-air/hardware-configuration.nix @@ -0,0 +1,38 @@ +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "usb_storage" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { + device = "/dev/disk/by-uuid/f6ce0d1f-a66d-4481-b338-611dc326efb6"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { + device = "/dev/disk/by-uuid/395D-1117"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + swapDevices = + [{ device = "/dev/disk/by-uuid/8def60e1-8298-4f5d-ac1f-52ed948aa3c1"; }]; + + # 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.wlan0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux"; +}