···4343 libarchive
4444 ];
45454646+ patches = [
4747+ # Fix corruption in hijack and zpoline libraries when building in parallel,
4848+ # because both hijack and zpoline share object files, which may result in
4949+ # missing symbols.
5050+ # https://github.com/lkl/linux/pull/612/commits/4ee5d9b78ca1425b4473ede98602b656f28027e8
5151+ ./fix-hijack-and-zpoline-parallel-builds.patch
5252+ ];
5353+4654 postPatch = ''
4755 # Fix a /usr/bin/env reference in here that breaks sandboxed builds
4856 patchShebangs arch/lkl/scripts
···11+#!/usr/bin/env nix-shell
22+#! nix-shell -i nu -p nushell nix
33+44+use std/log
55+66+def replace [ p: path old: string new: string ] {
77+ open $p
88+ | str replace $old $new
99+ | save -f $p
1010+}
1111+1212+def eval [ attr: string ] {
1313+ with-env {
1414+ NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM: 1
1515+ } {
1616+ nix eval -f ./. $attr --json
1717+ }
1818+ | from json
1919+}
2020+2121+def main [] {
2222+ # List of all the link in the RSS feed for
2323+ # https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/
2424+ let links = http get https://sourceforge.net/projects/mingw-w64/rss?path=/mingw-w64/mingw-w64-release/
2525+ | from xml
2626+ | get content.content.0
2727+ | where tag == item
2828+ | get content
2929+ | flatten
3030+ | where tag == title
3131+ | get content
3232+ | flatten
3333+ | get content
3434+3535+ # Select only files ending in "tar.bz2", then select the largest value
3636+ # We only consider values with at least two digits cause they are at
3737+ # 13.0 and sorting strings doesn't work well if they aren't the same length
3838+ let newest = $links
3939+ | where { ($in | str ends-with "tar.bz2") and ($in =~ v[0-9][0-9]\.) }
4040+ | sort -r
4141+ | get 0
4242+4343+ # Extract the newest version out of the URL
4444+ let new_version = $newest
4545+ | split column /
4646+ | get column4.0
4747+ | split column -
4848+ | get column3.0
4949+ | str replace .tar.bz2 ""
5050+ | str trim -c v
5151+5252+ # Get the current version in the drv
5353+ let current_version = eval "windows.mingw_w64_headers.version"
5454+5555+ if $new_version == $current_version {
5656+ log info "Current mingw-w64 version matches the latest, exiting..."
5757+ return
5858+ } else {
5959+ log info $"Current version is ($current_version)\nLatest version is ($new_version)"
6060+ }
6161+6262+ # Get the current hash
6363+ let current_hash = eval "windows.mingw_w64_headers.src.outputHash"
6464+6565+ # Set to the new version
6666+ replace ./pkgs/os-specific/windows/mingw-w64/headers.nix $current_version $new_version
6767+6868+ # The nix derivation creates the URL from the version, so just grab that.
6969+ let new_url = eval "windows.mingw_w64_headers.src.url"
7070+7171+ # Prefetch to get the new hash
7272+ let new_hash = nix-prefetch-url --type sha256 $new_url
7373+ | nix hash to-sri --type sha256 $in
7474+7575+ # Set the hash
7676+ replace ./pkgs/os-specific/windows/mingw-w64/headers.nix $current_hash $new_hash
7777+}