diff --git a/flake.lock b/flake.lock index 54aac8d..5e74698 100644 --- a/flake.lock +++ b/flake.lock @@ -213,11 +213,11 @@ ] }, "locked": { - "lastModified": 1730190761, - "narHash": "sha256-o5m5WzvY6cGIDupuOvjgNSS8AN6yP2iI9MtUC6q/uos=", + "lastModified": 1728334376, + "narHash": "sha256-CTKEKPzD/j8FK6H4DO3EjyixZd3HHvgAgfnCwpGFP5c=", "owner": "nix-community", "repo": "disko", - "rev": "3979285062d6781525cded0f6c4ff92e71376b55", + "rev": "d39ee334984fcdae6244f5a8e6ab857479cbaefe", "type": "github" }, "original": { @@ -489,11 +489,11 @@ ] }, "locked": { - "lastModified": 1729999765, - "narHash": "sha256-LYsavZXitFjjyETZoij8usXjTa7fa9AIF3Sk3MJSX+Y=", + "lastModified": 1728263287, + "narHash": "sha256-GJDtsxz2/zw6g/Nrp4XVWBS5IaZ7ZUkuvxPOBEDe7pg=", "owner": "Mic92", "repo": "nix-index-database", - "rev": "0e3a8778c2ee218eff8de6aacf3d2fa6c33b2d4f", + "rev": "5fce10c871bab6d7d5ac9e5e7efbb3a2783f5259", "type": "github" }, "original": { @@ -531,11 +531,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1730137625, - "narHash": "sha256-9z8oOgFZiaguj+bbi3k4QhAD6JabWrnv7fscC/mt0KE=", + "lastModified": 1728193676, + "narHash": "sha256-PbDWAIjKJdlVg+qQRhzdSor04bAPApDqIv2DofTyynk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "64b80bfb316b57cdb8919a9110ef63393d74382a", + "rev": "ecbc1ca8ffd6aea8372ad16be9ebbb39889e55b6", "type": "github" }, "original": { @@ -546,11 +546,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1729880355, - "narHash": "sha256-RP+OQ6koQQLX5nw0NmcDrzvGL8HDLnyXt/jHhL1jwjM=", + "lastModified": 1728018373, + "narHash": "sha256-NOiTvBbRLIOe5F6RbHaAh6++BNjsb149fGZd1T4+KBg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "18536bf04cd71abd345f9579158841376fdd0c5a", + "rev": "bc947f541ae55e999ffdb4013441347d83b00feb", "type": "github" }, "original": { @@ -837,11 +837,11 @@ }, "vpsadminos": { "locked": { - "lastModified": 1730290190, - "narHash": "sha256-a+op2lnWrCytuEhLOE24SKR/irRfjwDEHkpLyAL5P90=", + "lastModified": 1728335559, + "narHash": "sha256-95/KJBA449oAjf6bLwaCvDgys7yE8vKXY3wHe/uUkiw=", "owner": "vpsfreecz", "repo": "vpsadminos", - "rev": "63ac771b9667b45ab2ea87363f69ca7f85668e9b", + "rev": "c928bdec26484e99621cc76cb165abb73aa7d029", "type": "github" }, "original": { diff --git a/hosts/monolith/default.nix b/hosts/monolith/default.nix index f4fde3a..962addc 100644 --- a/hosts/monolith/default.nix +++ b/hosts/monolith/default.nix @@ -24,7 +24,6 @@ in (modulesPath + "/installer/scan/not-detected.nix") ./partition.nix ./amdgpu.nix - ./factorio-server.nix ]; boot.initrd.availableKernelModules = [ "nvme" @@ -39,7 +38,13 @@ in boot.kernelPackages = pkgs.linuxPackages_latest; - boot.extraModulePackages = with config.boot.kernelPackages; [ zenpower ]; + boot.extraModulePackages = with config.boot.kernelPackages; [ + zenpower + (pkgs.linux-bluetooth.override { + kernel = config.boot.kernelPackages.kernel; + patches = [ ../../patches/linux/v2-Bluetooth-btusb-Fix-regression-with-CSR-controllers.diff ]; + }) + ]; boot.initrd.kernelModules = [ "amdgpu" ]; boot.kernelModules = [ diff --git a/hosts/monolith/factorio-server.nix b/hosts/monolith/factorio-server.nix deleted file mode 100644 index 3c893a5..0000000 --- a/hosts/monolith/factorio-server.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ config, pkgs, ... }: -{ - services.factorio = { - enable = true; - package = pkgs.factorio-headless; # I override this in ./pkgs - public = true; - lan = true; - openFirewall = true; - admins = [ "lelgenio" ]; - extraSettingsFile = config.age.secrets.factorio-settings.path; - }; - - age.secrets.factorio-settings = { - file = ../../secrets/factorio-settings.age; - mode = "777"; - }; -} diff --git a/hosts/phantom/default.nix b/hosts/phantom/default.nix index e5570ee..6a246e4 100644 --- a/hosts/phantom/default.nix +++ b/hosts/phantom/default.nix @@ -21,6 +21,7 @@ ./invidious.nix ./davi.nix ./goofs.nix + ./factorio-server.nix ]; networking.hostName = "phantom"; diff --git a/hosts/phantom/factorio-server.nix b/hosts/phantom/factorio-server.nix new file mode 100644 index 0000000..a4b13b5 --- /dev/null +++ b/hosts/phantom/factorio-server.nix @@ -0,0 +1,24 @@ +{ config, pkgs, ... }: +{ + services.factorio = { + enable = true; + package = pkgs.unstable.factorio-headless.overrideAttrs (_: rec { + version = "2.0.12"; + src = pkgs.fetchurl { + name = "factorio_headless_x64-${version}.tar.xz"; + url = "https://www.factorio.com/get-download/${version}/headless/linux64"; + hash = "sha256-0vgg5eJ6ZEFO0TUixNsByCs8YyPGOArgqnXbT5RIjTE="; + }; + }); + public = true; + lan = true; + openFirewall = true; + admins = [ "lelgenio" ]; + extraSettingsFile = config.age.secrets.phantom-factorio-settings.path; + }; + + age.secrets.phantom-factorio-settings = { + file = ../../secrets/phantom-factorio-settings.age; + mode = "777"; + }; +} diff --git a/patches/linux/v2-Bluetooth-btusb-Fix-regression-with-CSR-controllers.diff b/patches/linux/v2-Bluetooth-btusb-Fix-regression-with-CSR-controllers.diff new file mode 100644 index 0000000..ae1adeb --- /dev/null +++ b/patches/linux/v2-Bluetooth-btusb-Fix-regression-with-CSR-controllers.diff @@ -0,0 +1,24 @@ +diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c +index c0b6ef8ee5da..f72218c1037e 100644 +--- a/drivers/bluetooth/btusb.c ++++ b/drivers/bluetooth/btusb.c +@@ -1366,10 +1366,15 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags) + if (!urb) + return -ENOMEM; + +- /* Use maximum HCI Event size so the USB stack handles +- * ZPL/short-transfer automatically. +- */ +- size = HCI_MAX_EVENT_SIZE; ++ if (le16_to_cpu(data->udev->descriptor.idVendor) == 0x0a12 && ++ le16_to_cpu(data->udev->descriptor.idProduct) == 0x0001) ++ /* Fake CSR devices don't seem to support sort-transter */ ++ size = le16_to_cpu(data->intr_ep->wMaxPacketSize); ++ else ++ /* Use maximum HCI Event size so the USB stack handles ++ * ZPL/short-transfer automatically. ++ */ ++ size = HCI_MAX_EVENT_SIZE; + + buf = kmalloc(size, mem_flags); + if (!buf) { diff --git a/pkgs/default.nix b/pkgs/default.nix index b702886..530d1cb 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -8,7 +8,5 @@ rec { emmet-cli = pkgs.callPackage ./emmet-cli.nix { }; material-wifi-icons = pkgs.callPackage ./material-wifi-icons.nix { }; gnome-pass-search-provider = pkgs.callPackage ./gnome-pass-search-provider.nix { }; - factorio-headless = pkgs.callPackage ./factorio-headless { - inherit (pkgs.unstable) factorio-headless; - }; + linux-bluetooth = pkgs.callPackage ./linux-bluetooth.nix { }; } diff --git a/pkgs/factorio-headless/default.nix b/pkgs/factorio-headless/default.nix deleted file mode 100644 index b6d34ef..0000000 --- a/pkgs/factorio-headless/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ factorio-headless, pkgs }: - -factorio-headless.overrideAttrs (_: rec { - version = "2.0.13"; - src = pkgs.fetchurl { - name = "factorio_headless_x64-${version}.tar.xz"; - url = "https://www.factorio.com/get-download/${version}/headless/linux64"; - hash = "sha256-J7NpAaOeWTrfKEGMAoYULGx6n4PRVpY8c2m9QFolx9E="; - }; -}) diff --git a/pkgs/factorio-headless/update.sh b/pkgs/factorio-headless/update.sh deleted file mode 100755 index 9f7bce9..0000000 --- a/pkgs/factorio-headless/update.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -xe - -cd "$(dirname $0)" - -current_version="$(rg '^.*?version\s*=\s*"(.+)".*?$' --replace '$1' ./default.nix)" -current_hash="$(rg '^.*?hash\s*=\s*"(.+)".*?$' --replace '$1' ./default.nix)" - -new_version="$(curl https://factorio.com/api/latest-releases | jq -r .stable.headless)" -new_hash="$(nix-hash --to-sri --type sha256 $(nix-prefetch-url --type sha256 https://www.factorio.com/get-download/${new_version}/headless/linux64))" - -sd "$current_version" "$new_version" ./default.nix -sd "$current_hash" "$new_hash" ./default.nix diff --git a/pkgs/linux-bluetooth.nix b/pkgs/linux-bluetooth.nix new file mode 100644 index 0000000..609e775 --- /dev/null +++ b/pkgs/linux-bluetooth.nix @@ -0,0 +1,47 @@ +{ + pkgs, + lib, + kernel ? pkgs.linuxPackages_latest.kernel, + patches ? [ ], +}: + +pkgs.stdenv.mkDerivation { + pname = "bluetooth-kernel-module"; + inherit (kernel) + src + version + postPatch + nativeBuildInputs + ; + + inherit patches; + + kernel_dev = kernel.dev; + kernelVersion = kernel.modDirVersion; + + modulePath = "drivers/bluetooth"; + + buildPhase = '' + BUILT_KERNEL=$kernel_dev/lib/modules/$kernelVersion/build + + cp $BUILT_KERNEL/Module.symvers . + cp $BUILT_KERNEL/.config . + cp $kernel_dev/vmlinux . + + make "-j$NIX_BUILD_CORES" modules_prepare + make "-j$NIX_BUILD_CORES" M=$modulePath modules + ''; + + installPhase = '' + make \ + INSTALL_MOD_PATH="$out" \ + XZ="xz -T$NIX_BUILD_CORES" \ + M="$modulePath" \ + modules_install + ''; + + meta = { + description = "Bluetooth kernel module"; + license = lib.licenses.gpl3; + }; +} diff --git a/secrets/factorio-settings.age b/secrets/phantom-factorio-settings.age similarity index 100% rename from secrets/factorio-settings.age rename to secrets/phantom-factorio-settings.age diff --git a/secrets/secrets.nix b/secrets/secrets.nix index f64fb4b..65f495a 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -12,7 +12,7 @@ in "monolith-forgejo-runner-token.age".publicKeys = [ main_ssh_public_key ]; "lelgenio-cachix.age".publicKeys = [ main_ssh_public_key ]; "monolith-nix-serve-privkey.age".publicKeys = [ main_ssh_public_key ]; - "factorio-settings.age".publicKeys = [ main_ssh_public_key ]; + "phantom-factorio-settings.age".publicKeys = [ main_ssh_public_key ]; "phantom-nextcloud.age".publicKeys = [ main_ssh_public_key ]; "phantom-writefreely.age".publicKeys = [ main_ssh_public_key ]; "phantom-renawiki.age".publicKeys = [ main_ssh_public_key ];