From 18612036d79f4bb739330796e603f8089b261b48 Mon Sep 17 00:00:00 2001 From: xenia Date: Wed, 3 Jul 2024 23:53:56 -0400 Subject: [PATCH] lib: add fetchb4 --- README.md | 19 +++++++++++++++++++ default.nix | 1 + lib/fetchb4/builder.sh | 6 ++++++ lib/fetchb4/default.nix | 23 +++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 lib/fetchb4/builder.sh create mode 100644 lib/fetchb4/default.nix diff --git a/README.md b/README.md index c586e6d..4b1a25b 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,25 @@ pkgs.fetchFromSteam { } ``` +### [`fetchb4`](./lib/fetchb4) + +A fetcher that uses `b4` to download patchsets from so that they can be applied in `boot.kernelPatches` + +Usage: + +```nix +pkgs.fetchb4 { + msgid = "2024042069.1337-example@example"; + hash = pkgs.lib.fakeHash; + + # optional args + version = "3"; # default: latest + single_message = true; # default: false +} +``` + +note that not specifying a version may make cause future invocations to return different output if a newer version is sent to the thread + ### [`mkNginxServer`](./lib/dev-nginx) creates a shell script that launches nginx in the foreground as the current user. the nginx is diff --git a/default.nix b/default.nix index 49798ba..02d6a1a 100644 --- a/default.nix +++ b/default.nix @@ -8,6 +8,7 @@ nixpkgs.overlays = [ (final: prev: { fetchFromSteam = prev.callPackage ./lib/fetchsteam {}; + fetchb4 = prev.callPackage ./lib/fetchb4 {}; gitSource = prev.callPackage ./lib/git-source {}; diff --git a/lib/fetchb4/builder.sh b/lib/fetchb4/builder.sh new file mode 100644 index 0000000..8c3aad2 --- /dev/null +++ b/lib/fetchb4/builder.sh @@ -0,0 +1,6 @@ +if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi +source $stdenv/setup + +echo "Downloading kernel patch $msgid into $out" +export HOME="/tmp" +PYTHONHASHSEED=0 b4 am -C -T $b4_flags -o- "$msgid" > "$out" diff --git a/lib/fetchb4/default.nix b/lib/fetchb4/default.nix new file mode 100644 index 0000000..4f7115f --- /dev/null +++ b/lib/fetchb4/default.nix @@ -0,0 +1,23 @@ +{ lib, stdenvNoCC, b4, git, cacert }: + +{ + msgid, + hash, + single_message ? false, + version ? null +}: stdenvNoCC.mkDerivation { + name = "patch-${msgid}"; + builder = ./builder.sh; + + inherit msgid; + b4_flags = with lib.strings; concatStringsSep " " [ + (optionalString single_message "--single-message") + (optionalString (version != null) "--use-version ${version}") + ]; + + nativeBuildInputs = [ b4 git cacert ]; + SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; + + outputHash = hash; + preferLocalBuild = true; +}