diff --git a/flake.lock b/flake.lock index bf8bc30e..ec833c65 100644 --- a/flake.lock +++ b/flake.lock @@ -21,6 +21,21 @@ "url": "https://git@githug.xyz/xenia/ansi-utils" } }, + "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" @@ -155,6 +170,28 @@ "type": "github" } }, + "nixos-apple-silicon": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1718588737, + "narHash": "sha256-06acqoMEYtc+/w5gWiIIuUFfdtdOBKlp1qrC/InRiBY=", + "owner": "tpwrules", + "repo": "nixos-apple-silicon", + "rev": "b0a2376f6c164a0af963d47386c064cc6fdcd5ea", + "type": "github" + }, + "original": { + "owner": "tpwrules", + "repo": "nixos-apple-silicon", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1717144377, @@ -177,11 +214,28 @@ "home-manager": "home-manager", "kak": "kak", "nix-darwin": "nix-darwin", + "nixos-apple-silicon": "nixos-apple-silicon", "nixpkgs": "nixpkgs", "unambig-path": "unambig-path", "unispect": "unispect" } }, + "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 14180623..3a622267 100644 --- a/flake.nix +++ b/flake.nix @@ -29,9 +29,13 @@ url = "git+https://git@githug.xyz/xenia/unambig-path"; inputs.nixpkgs.follows = "nixpkgs"; }; + nixos-apple-silicon = { + url = "github:tpwrules/nixos-apple-silicon"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, home-manager, nix-darwin, kak, unispect, ansi-utils, unambig-path }: + outputs = { self, nixpkgs, home-manager, nix-darwin, kak, unispect, ansi-utils, unambig-path, nixos-apple-silicon }: let mkPkgs = system: import nixpkgs { system = system; config.allowUnfree = true; }; mkHome = {username, home-dir, prompt-color, system, pkgs} : import ./home/common.nix { @@ -146,5 +150,72 @@ { home-manager.users.xenia = xenia.pc; } ]; }; - }; + + nixosConfigurations.foxhut = + let + system = "aarch64-linux"; + pkgs = mkPkgs system; + base = mkNixOsBase { + inherit system pkgs; + hostname = "foxhut"; + }; + networking = mkNixOsNetworking { + inherit pkgs; + use-iwd = true; + }; + graphical = mkNixOsGraphical { + inherit pkgs; + background = "pan-wire-3.png"; + }; + coral = + let + system = "aarch64-linux"; + pkgs = mkPkgs system; + home = mkHome { + username = "coral"; + home-dir = "/home/coral"; + prompt-color = 243; + inherit system pkgs; + }; + in { home = home; }; + xenia = + let + system = "aarch64-linux"; + pkgs = mkPkgs system; + home = mkHome { + username = "xenia"; + home-dir = "/home/xenia"; + prompt-color = 205; + inherit system pkgs; + }; + pc = mkPC { inherit system pkgs; }; + in { home = home; pc = pc; }; + asahi-firmware = builtins.fetchGit { + url = "git@githug.xyz:xenia/asahi-firmware.git"; + ref = "main"; + rev = "012d29d4b4d7148414bb649c39805479c7a4327b"; + }; + tiny-dfr = import ./nixos/tiny-dfr.nix { inherit pkgs; }; + in + nixpkgs.lib.nixosSystem { + inherit system; + modules = [ + nixos-apple-silicon.nixosModules.apple-silicon-support + ./nixos/machines/foxhut/hardware.nix + (import ./nixos/machines/foxhut/boot.nix { inherit asahi-firmware; }) + base + networking + graphical + tiny-dfr + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.coral = coral.home; + home-manager.users.xenia = xenia.home; + } + { home-manager.users.xenia = xenia.pc; } + ]; + }; + }; } diff --git a/nixos/machines/foxhut/boot.nix b/nixos/machines/foxhut/boot.nix new file mode 100644 index 00000000..053a3689 --- /dev/null +++ b/nixos/machines/foxhut/boot.nix @@ -0,0 +1,19 @@ +# 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`). + +{ asahi-firmware, ... }: + +{ + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = false; + hardware.asahi.peripheralFirmwareDirectory = asahi-firmware; + + hardware.asahi.enable = true; + hardware.asahi.setupAsahiSound = true; + + hardware.asahi.useExperimentalGPUDriver = true; + hardware.asahi.experimentalGPUInstallMode = "replace"; +} + diff --git a/nixos/machines/foxhut/hardware.nix b/nixos/machines/foxhut/hardware.nix new file mode 100644 index 00000000..c13d5312 --- /dev/null +++ b/nixos/machines/foxhut/hardware.nix @@ -0,0 +1,37 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ 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/f726ed7c-7f12-430c-b38b-e5533099fabe"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/8569-17E8"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + swapDevices = [ ]; + + # 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"; +} diff --git a/nixos/tiny-dfr.nix b/nixos/tiny-dfr.nix new file mode 100644 index 00000000..ee1fe92f --- /dev/null +++ b/nixos/tiny-dfr.nix @@ -0,0 +1,18 @@ +{ + pkgs, + tiny-dfr ? pkgs.tiny-dfr +}: { + services.udev.packages = [ tiny-dfr ]; + systemd.services.tiny-dfr = { + enable = true; + description = "tinydfr"; + after = ["systemd-user-sessions.service" "getty@tty1.service" "plymouth-quit.service" "systemd-logind.service"]; + wantedBy = ["multi-user.target"]; + startLimitIntervalSec = 30; + startLimitBurst = 2; + serviceConfig = { + ExecStart = "${tiny-dfr}/bin/tiny-dfr"; + Restart = "always"; + }; + }; +}