feat: mechanism for patching nixpkgs

This commit is contained in:
Patrick 2024-11-03 21:34:38 +01:00
parent 0225734af3
commit 64e4b50b5a
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
12 changed files with 151 additions and 95 deletions

View file

@ -122,6 +122,7 @@
./nix/devshell.nix ./nix/devshell.nix
./nix/hosts.nix ./nix/hosts.nix
./nix/pkgs.nix ./nix/pkgs.nix
./nix/patch.nix
nix-topology.flakeModule nix-topology.flakeModule
]; ];

View file

@ -20,6 +20,7 @@
packages = with pkgs; [ packages = with pkgs; [
# Nix # Nix
nil nil
wcurl # for fetch-prs
# Misc # Misc
shellcheck shellcheck

View file

@ -1,4 +1,4 @@
{ inputs, ... }: { inputs, self, ... }:
{ {
flake = flake =
{ config, lib, ... }: { config, lib, ... }:
@ -20,12 +20,16 @@
pkgs = config.pkgs.x86_64-linux; pkgs = config.pkgs.x86_64-linux;
stateVersion = "24.05"; stateVersion = "24.05";
in in
inputs.nixpkgs.lib.nixosSystem { (import "${self.nixpkgs-patched}/nixos/lib/eval-config.nix") {
system = null;
specialArgs = { specialArgs = {
# Use the correct instance lib that has our overlays # Use the correct instance lib that has our overlays
inherit (pkgs) lib; inherit (pkgs) lib;
inherit (config) nodes; inherit (config) nodes;
inherit inputs minimal stateVersion; inherit minimal stateVersion;
inputs = inputs // {
nixpkgs = self.nixpkgs-patched;
};
}; };
modules = [ modules = [
{ {

25
nix/patch.nix Normal file
View file

@ -0,0 +1,25 @@
{
inputs,
...
}:
{
flake = {
nixpkgs-patched =
let
system = "x86_64-linux";
pkgs = import inputs.nixpkgs { inherit system; };
in
pkgs.stdenvNoCC.mkDerivation {
name = "Nixpkgs with patches from open PRs";
src = inputs.nixpkgs;
dontConfigure = true;
dontBuild = true;
doCheck = false;
dontFixup = true;
installPhase = ''
cp -r ./ $out
'';
patches = pkgs.lib.filesystem.listFilesRecursive ../patches;
};
};
}

View file

@ -1,4 +1,4 @@
{ inputs, ... }: { inputs, self, ... }:
{ {
imports = [ imports = [
( (
@ -14,7 +14,7 @@
perSystem = perSystem =
{ pkgs, system, ... }: { pkgs, system, ... }:
{ {
_module.args.pkgs = import inputs.nixpkgs { _module.args.pkgs = import self.nixpkgs-patched {
inherit system; inherit system;
config.allowUnfree = true; config.allowUnfree = true;
overlays = (import ../pkgs inputs) ++ [ overlays = (import ../pkgs inputs) ++ [

80
patches/353230.diff Normal file
View file

@ -0,0 +1,80 @@
diff --git a/pkgs/development/python-modules/pyscard/default.nix b/pkgs/development/python-modules/pyscard/default.nix
index 4392b3cb60121..a5b4d28b4a7dc 100644
--- a/pkgs/development/python-modules/pyscard/default.nix
+++ b/pkgs/development/python-modules/pyscard/default.nix
@@ -18,14 +18,14 @@ in
buildPythonPackage rec {
pname = "pyscard";
- version = "2.1.1";
+ version = "2.2.0";
pyproject = true;
src = fetchFromGitHub {
owner = "LudovicRousseau";
repo = "pyscard";
rev = "refs/tags/${version}";
- hash = "sha256-wlw2QL1vfhXba8ok/URcd9M+F7Sa+ZtekV1w5X24owE=";
+ hash = "sha256-yZeP4Tcxnwb2My+XOsMtj+H8mNIf6JYf5tpOVUYjev0=";
};
build-system = [ setuptools ];
@@ -37,36 +37,31 @@ buildPythonPackage rec {
nativeCheckInputs = [ pytestCheckHook ];
postPatch =
- if withApplePCSC then
- ''
- substituteInPlace smartcard/scard/winscarddll.c \
- --replace-fail "/System/Library/Frameworks/PCSC.framework/PCSC" \
- "${PCSC}/Library/Frameworks/PCSC.framework/PCSC"
- ''
- else
- ''
- substituteInPlace setup.py --replace "pkg-config" "$PKG_CONFIG"
- substituteInPlace smartcard/scard/winscarddll.c \
- --replace-fail "libpcsclite.so.1" \
- "${lib.getLib pcsclite}/lib/libpcsclite${stdenv.hostPlatform.extensions.sharedLibrary}"
- '';
+ ''
+ substituteInPlace pyproject.toml \
+ --replace-fail 'requires = ["setuptools","swig"]' 'requires = ["setuptools"]'
+ ''
+ + (
+ if withApplePCSC then
+ ''
+ substituteInPlace src/smartcard/scard/winscarddll.c \
+ --replace-fail "/System/Library/Frameworks/PCSC.framework/PCSC" \
+ "${PCSC}/Library/Frameworks/PCSC.framework/PCSC"
+ ''
+ else
+ ''
+ substituteInPlace setup.py --replace-fail "pkg-config" "$PKG_CONFIG"
+ substituteInPlace src/smartcard/scard/winscarddll.c \
+ --replace-fail "libpcsclite.so.1" \
+ "${lib.getLib pcsclite}/lib/libpcsclite${stdenv.hostPlatform.extensions.sharedLibrary}"
+ ''
+ );
- preCheck = ''
- # remove src module, so tests use the installed module instead
- rm -r smartcard
- '';
-
- disabledTests = [
- # AssertionError
- "test_hresult"
- "test_low_level"
- ];
-
- meta = with lib; {
+ meta = {
description = "Smartcard library for python";
homepage = "https://pyscard.sourceforge.io/";
changelog = "https://github.com/LudovicRousseau/pyscard/releases/tag/${version}";
- license = licenses.lgpl21Plus;
- maintainers = with maintainers; [ layus ];
+ license = lib.licenses.lgpl21Plus;
+ maintainers = with lib.maintainers; [ layus ];
};
}

12
patches/353272.diff Normal file
View file

@ -0,0 +1,12 @@
diff --git a/pkgs/tools/archivers/7zz/default.nix b/pkgs/tools/archivers/7zz/default.nix
index ca8f8366f7f6b..d23ec4af02ee4 100644
--- a/pkgs/tools/archivers/7zz/default.nix
+++ b/pkgs/tools/archivers/7zz/default.nix
@@ -77,6 +77,7 @@ stdenv.mkDerivation (finalAttrs: {
"CXX=${stdenv.cc.targetPrefix}c++"
]
++ lib.optionals useUasm [ "MY_ASM=uasm" ]
+ ++ lib.optionals (!useUasm && stdenv.hostPlatform.isx86) [ "USE_ASM=" ]
# We need at minimum 10.13 here because of utimensat, however since
# we need a bump anyway, let's set the same minimum version as the one in
# aarch64-darwin so we don't need additional changes for it

View file

@ -1,85 +0,0 @@
{
lib,
stdenv,
fetchurl,
flex,
gitUpdater,
libusb1,
meson,
ninja,
pcsclite,
perl,
pkg-config,
zlib,
}:
stdenv.mkDerivation rec {
pname = "ccid";
version = "1.6.1";
src = fetchurl {
url = "https://ccid.apdu.fr/files/${pname}-${version}.tar.xz";
hash = "sha256-LsqPsH6P58DTna6sp7l81zxA7Ztyc4okrT3L38kY4eo=";
};
postPatch = ''
patchShebangs .
substituteInPlace meson.build --replace-fail \
"pcsc_dep.get_variable('usbdropdir')" \
"'$out/pcsc/drivers'"
'';
mesonFlags = [
(lib.mesonBool "serial" true)
];
# error: call to undeclared function 'InterruptRead';
# ISO C99 and later do not support implicit function declarations
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration";
};
nativeBuildInputs = [
flex
perl
pkg-config
meson
ninja
];
buildInputs = [
libusb1
pcsclite
zlib
];
postInstall = ''
install -Dm 0444 -t $out/lib/udev/rules.d ../src/92_pcscd_ccid.rules
substituteInPlace $out/lib/udev/rules.d/92_pcscd_ccid.rules \
--replace-fail "/usr/sbin/pcscd" "${pcsclite}/bin/pcscd"
'';
# The resulting shared object ends up outside of the default paths which are
# usually getting stripped.
stripDebugList = [ "pcsc" ];
passthru.updateScript = gitUpdater {
url = "https://salsa.debian.org/rousseau/CCID.git";
};
installCheckPhase = ''
[ -f $out/etc/reader.conf.d/libccidtwin ]
[ -f $out/lib/udev/rules.d/92_pcscd_ccid.rules ]
[ -f $out/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist ]
[ -f $out/pcsc/drivers/ifd-ccid.bundle/Contents/Linux/libccid.so ]
[ -f $out/pcsc/drivers/serial/libccidtwin.so ]
'';
meta = with lib; {
description = "PC/SC driver for USB CCID smart card readers";
homepage = "https://ccid.apdu.fr/";
license = licenses.lgpl21Plus;
maintainers = [ maintainers.anthonyroussel ];
platforms = platforms.unix;
};
}

View file

@ -8,7 +8,6 @@ _inputs: [
signal-to-blog = prev.callPackage ./signal-to-blog.nix { }; signal-to-blog = prev.callPackage ./signal-to-blog.nix { };
minion = prev.callPackage ./minion.nix { }; minion = prev.callPackage ./minion.nix { };
mongodb-bin = prev.callPackage ./mongodb-bin.nix { }; mongodb-bin = prev.callPackage ./mongodb-bin.nix { };
ccid = prev.callPackage ./ccid.nix { };
awakened-poe-trade = prev.callPackage ./awakened-poe-trade.nix { }; awakened-poe-trade = prev.callPackage ./awakened-poe-trade.nix { };
neovim-clean = prev.neovim-unwrapped.overrideAttrs ( neovim-clean = prev.neovim-unwrapped.overrideAttrs (
_neovimFinal: neovimPrev: { _neovimFinal: neovimPrev: {
@ -20,6 +19,7 @@ _inputs: [
''; '';
} }
); );
path-of-building = prev.path-of-building.overrideAttrs (old: { path-of-building = prev.path-of-building.overrideAttrs (old: {
postFixup = postFixup =
(old.postFixup or "") (old.postFixup or "")

View file

@ -2,7 +2,7 @@
stdenvNoCC, stdenvNoCC,
lib, lib,
fetchzip, fetchzip,
openjdk22, openjdk21,
makeDesktopItem, makeDesktopItem,
javaPackages, javaPackages,
gsettings-desktop-schemas, gsettings-desktop-schemas,
@ -10,13 +10,13 @@
}: }:
let let
openjfx = javaPackages.openjfx22.override { withWebKit = true; }; openjfx = javaPackages.openjfx21.override { withWebKit = true; };
jdk = openjdk22.override ( jdk = openjdk21.override (
prev: prev:
prev prev
// { // {
enableJavaFX = true; enableJavaFX = true;
inherit openjfx; openjfx_jdk = openjfx;
} }
); );
in in

17
pkgs/scripts/fetch-prs.sh Executable file
View file

@ -0,0 +1,17 @@
# dependencies: wcurl
PRS=("353272" "353230")
if [ ! -f flake.nix ]; then
echo "Not in a flake top level"
exit 1
fi
mkdir -p patches
echo "Removing old patches"
rm patches/*.diff
for t in "${PRS[@]}"; do
echo "Fetching PR #$t"
url="https://github.com/NixOS/nixpkgs/pull/$t"
echo "$url"
wcurl "$url.diff" --curl-options "--output-dir patches"
done

View file

@ -36,6 +36,7 @@
yt-dlp yt-dlp
zathura zathura
zotero zotero
bashInteractive
]; ];
}; };
hm.programs.bat.enable = true; hm.programs.bat.enable = true;