From 33da03e5380ad11d5454ee65a985dffaeed461b8 Mon Sep 17 00:00:00 2001 From: xenia Date: Thu, 27 Jun 2024 11:23:57 +0200 Subject: [PATCH 1/4] Switch to pipewire --- nixos/graphical.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nixos/graphical.nix b/nixos/graphical.nix index eca8bc25..46217a68 100644 --- a/nixos/graphical.nix +++ b/nixos/graphical.nix @@ -27,9 +27,14 @@ console.useXkbConfig = true; - # Enable sound. - sound.enable = true; - hardware.pulseaudio.enable = true; + sound.enable = false; # let pipewire handle sound + services.pipewire = { + enable = true; + alsa.enable = true; + pulse.enable = true; + jack.enable = true; + wireplumber.enable = true; + }; hardware.bluetooth.enable = true; From 20883297234b1ec251c2857935b3f26fdebc71da Mon Sep 17 00:00:00 2001 From: xenia Date: Thu, 27 Jun 2024 11:24:08 +0200 Subject: [PATCH 2/4] Enable opengl --- nixos/graphical.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nixos/graphical.nix b/nixos/graphical.nix index 46217a68..60e8da90 100644 --- a/nixos/graphical.nix +++ b/nixos/graphical.nix @@ -22,6 +22,8 @@ }; }; + hardware.opengl.enable = true; + services.desktopManager.plasma6.enable = true; services.displayManager.defaultSession = "plasma"; @@ -48,5 +50,6 @@ stilo-themes firefox + glxinfo ]; } From e2049d9ad129c4c81c286f6c74fbdc49ace5472b Mon Sep 17 00:00:00 2001 From: xenia Date: Thu, 27 Jun 2024 11:24:25 +0200 Subject: [PATCH 3/4] Asahi configuration --- flake.lock | 54 +++++++++++++++++++++ flake.nix | 75 +++++++++++++++++++++++++++++- nixos/machines/foxhut/boot.nix | 19 ++++++++ nixos/machines/foxhut/hardware.nix | 37 +++++++++++++++ nixos/tiny-dfr.nix | 18 +++++++ 5 files changed, 201 insertions(+), 2 deletions(-) create mode 100644 nixos/machines/foxhut/boot.nix create mode 100644 nixos/machines/foxhut/hardware.nix create mode 100644 nixos/tiny-dfr.nix 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"; + }; + }; +} From 7957f18ecfc0c0f6bb9f9d78c5e70ba3c49259d4 Mon Sep 17 00:00:00 2001 From: xenia Date: Thu, 27 Jun 2024 12:40:22 +0200 Subject: [PATCH 4/4] Option to disable use of display manager (slightly broken) --- flake.nix | 2 ++ nixos/graphical.nix | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 3a622267..3b689dc3 100644 --- a/flake.nix +++ b/flake.nix @@ -104,6 +104,7 @@ graphical = mkNixOsGraphical { inherit pkgs; background = "pan-wire-3.png"; + use-display-manager = false; }; networking = mkNixOsNetworking { inherit pkgs; }; @@ -166,6 +167,7 @@ graphical = mkNixOsGraphical { inherit pkgs; background = "pan-wire-3.png"; + use-display-manager = true; }; coral = let diff --git a/nixos/graphical.nix b/nixos/graphical.nix index 60e8da90..32a68851 100644 --- a/nixos/graphical.nix +++ b/nixos/graphical.nix @@ -1,14 +1,18 @@ { pkgs, background-image ? "pan-wire-3.png", + use-display-manager, ... }: +let start-plasma-shortcut = pkgs.writeScriptBin "desktop" '' + ${pkgs.plasma-workspace}/libexec/plasma-dbus-run-session-if-needed ${pkgs.plasma-workspace}/bin/startplasma-wayland +''; +in { - # Enable the X11 windowing system. - services.xserver = { enable = true; - displayManager.lightdm.enable = true; + + displayManager.lightdm.enable = use-display-manager; xkb = { layout = "fox"; @@ -22,11 +26,11 @@ }; }; - hardware.opengl.enable = true; - services.desktopManager.plasma6.enable = true; services.displayManager.defaultSession = "plasma"; + hardware.opengl.enable = true; + console.useXkbConfig = true; sound.enable = false; # let pipewire handle sound @@ -51,5 +55,6 @@ firefox glxinfo + start-plasma-shortcut ]; }