From 0c48addc4b1fbb71e67769a01f14a7219e1c4c40 Mon Sep 17 00:00:00 2001 From: Nikkuss Date: Tue, 29 Jul 2025 14:56:24 +0400 Subject: [PATCH] base testing --- flake.lock | 77 +++++++++++++++++++ flake.nix | 46 +++++++++++ pkgs/by-name/at/ath-tools/package.nix | 22 ++++++ .../at/ath-tools/tools/ath12k-tools.nix | 14 ++++ pkgs/by-name/x1/x1e80100-firmware/package.nix | 58 ++++++++++++++ pkgs/default.nix | 7 ++ 6 files changed, 224 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 pkgs/by-name/at/ath-tools/package.nix create mode 100644 pkgs/by-name/at/ath-tools/tools/ath12k-tools.nix create mode 100644 pkgs/by-name/x1/x1e80100-firmware/package.nix create mode 100644 pkgs/default.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0bf6b9a --- /dev/null +++ b/flake.lock @@ -0,0 +1,77 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1753694789, + "narHash": "sha256-cKgvtz6fKuK1Xr5LQW/zOUiAC0oSQoA9nOISB0pJZqM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "dc9637876d0dcc8c9e5e22986b857632effeb727", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "systems": "systems_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6116473 --- /dev/null +++ b/flake.nix @@ -0,0 +1,46 @@ +{ + description = "Scuggo Pkgs"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + systems.url = "github:nix-systems/default"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + systems, + }: + + { + overlays.default = + final: prev: (import "${nixpkgs}/pkgs/top-level/by-name-overlay.nix" ./pkgs/by-name) final prev; + } + // + flake-utils.lib.eachSystem + [ + "x86_64-linux" + "aarch64-linux" + ] + ( + system: + let + pkgs = import nixpkgs { + inherit system; + }; + inherit (pkgs) lib; + scope = lib.makeScope pkgs.newScope (final: self.overlays.default (pkgs // final) pkgs); + workingPackages = lib.filterAttrs (_: pkg: !pkg.meta.broken) self.packages.${system}; + in + { + inherit pkgs; + packages = lib.filterAttrs ( + _: pkg: lib.isDerivation pkg && (lib.meta.availableOn pkgs.stdenv.hostPlatform pkg) + ) scope; + checks = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") workingPackages; + } + ); +} diff --git a/pkgs/by-name/at/ath-tools/package.nix b/pkgs/by-name/at/ath-tools/package.nix new file mode 100644 index 0000000..4fd5381 --- /dev/null +++ b/pkgs/by-name/at/ath-tools/package.nix @@ -0,0 +1,22 @@ +{ + lib, + newScope, + callPackage, + fetchFromGitHub, + ... +}: +let + src = fetchFromGitHub { + owner = "qca"; + repo = "qca-swiss-army-knife"; + rev = "7c191e5530d32391105653b276ab587d2af9e02a"; + hash = "sha256-iE4lqyr3zmLcgFnsrDvQ/CKUV15ijqmIbUIs9sgMECg="; + }; +in +lib.packagesFromDirectoryRecursive { + inherit callPackage newScope; + directory = ./tools; +} +# lib.makeScope newScope (self: { +# ath12k-tools = self.callPackage ./ath12k-tools.nix { inherit src; }; +# }) diff --git a/pkgs/by-name/at/ath-tools/tools/ath12k-tools.nix b/pkgs/by-name/at/ath-tools/tools/ath12k-tools.nix new file mode 100644 index 0000000..d3f7595 --- /dev/null +++ b/pkgs/by-name/at/ath-tools/tools/ath12k-tools.nix @@ -0,0 +1,14 @@ +{ src, python3, ... }: + +python3.pkgs.buildPythonApplication rec { + name = "ath12k-tools"; + pyproject = false; + inherit src; + sourceRoot = "source/tools/scripts/ath12k"; + installPhase = '' + install -Dm755 "ath12k-bdencoder" "$out/bin/ath12k-bdencoder" + install -Dm755 "ath12k-check" "$out/bin/ath12k-check" + install -Dm755 "ath12k-fw-repo" "$out/bin/ath12k-fw-repo" + install -Dm755 "ath12k-fwencoder" "$out/bin/ath12k-fwencoder" + ''; +} diff --git a/pkgs/by-name/x1/x1e80100-firmware/package.nix b/pkgs/by-name/x1/x1e80100-firmware/package.nix new file mode 100644 index 0000000..81aa358 --- /dev/null +++ b/pkgs/by-name/x1/x1e80100-firmware/package.nix @@ -0,0 +1,58 @@ +{ + msitools, + tree, + fetchurl, + lib, + stdenv, + ... +}: + +stdenv.mkDerivation ( + let + fw_files = [ + "adsp_dtbs.elf" + "adspr.jsn" + "adsps.jsn" + "adspua.jsn" + "battmgr.jsn" + "cdsp_dtbs.elf" + "cdspr.jsn" + "qcadsp8380.mbn" + "qccdsp8380.mbn" + "qcdxkmsuc8380.mbn" + ]; + + in + { + name = "x1e80100-firmware"; + src = fetchurl { + url = "https://download.microsoft.com/download/b7ca2c3f-d320-4795-be0f-529a0117abb4/SurfaceLaptop7_ARM_Win11_26100_25.061.7304.0.msi"; + sha256 = "sha256-x75NsuZZr64XfGhjghIoiymdhhb/rM0iaV9EohwPbrs="; + }; + nativeBuildInputs = [ + msitools + tree + ]; + unpackPhase = '' + msiextract -C . $src + ''; + buildPhase = '' + mkdir -p $out/lib/firmware/qcom/x1e80100/microsoft/Romulus + for file in ${lib.concatStringsSep " " fw_files}; do + echo -e "\tSearching for $file..." + fw_path=$(find . -type f -name "$file" -print | head -n 1) + if [[ -n "$fw_path" ]]; then + cp -v "$fw_path" "$out/lib/firmware/qcom/x1e80100/microsoft/Romulus/" + else + echo "Error: $file not found!" + exit 1 + fi + done + cp $out/lib/firmware/qcom/x1e80100/microsoft/Romulus/qcdxkmsuc8380.mbn $out/lib/firmware/qcom/x1e80100/microsoft/qcdxkmsuc8380.mbn + ''; + meta = { + platforms = [ "aarch64-linux" ]; + }; + + } +) diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..a2be9aa --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,7 @@ +prev: final: +builtins.listToAttrs ( + map (fn: { + name = fn; + value = prev.callPackage ./${fn} { }; + }) (builtins.filter (fn: fn != "default.nix") (builtins.attrNames (builtins.readDir ./.))) +)