
Inspired by https://github.com/NixOS/nixpkgs/pull/387725#issuecomment-2704943777, script is based on https://github.com/NixOS/nixpkgs/pull/336172 using what i learned in https://github.com/NixOS/nixpkgs/pull/386865, part of https://github.com/NixOS/nixpkgs/issues/346453 Should be zero rebuilds. All candidates were made using: ```shell export NIXPKGS_ALLOW_UNFREE=1 export NIXPKGS_ALLOW_INSECURE=1 export NIXPKGS_ALLOW_BROKEN=1 git-wait restore . test -s packages.json || ( set -x; time nix-env --extra-experimental-features no-url-literals --option system x86_64-linux -f ./. -qaP --json --meta --drv-path --out-path --show-trace --no-allow-import-from-derivation --arg config '{ allowAliases = false; }' > packages.json ) list_attrpath_fname_col() { jq <packages.json 'to_entries[] | select(.value.meta.position==null|not) | "\(.key)\t\(.value.meta.position)"' -r | sed -e "s#\t$(realpath .)/#\t#" | sed -e 's#:\([0-9]*\)$#\t\1#' | grep . | grep -iv haskell | grep -iv /top-level/ | grep -iv chicken | grep pkgs/by-name/ | grep -iv build | grep -E '/(package|default)\.nix' } FLOCKDIR="$(mktemp -d)" N_WORKERS=4 while read attrpath fname col; do grep -qE 'repo *= *("\$\{pname\}"|pname);' "$fname" || continue echo | ( # mutex on fname flock --nonblock 200 || { >&2 echo "failed to aquire lock for $fname" exit 1 } echo "$attrpath" data="$(nix eval --impure --expr 'with import ./. {}; { inherit ('"$attrpath"') pname drvPath passthru meta; drvPath2='"$attrpath"'.src.drvPath; }' --json)" || exit test -n "$data" || exit pname="$(jq <<<"$data" .pname -r)" test -n "$pname" || exit (set -x sd -F '${pname}' "$pname" "$fname" sd -F ' = pname;' " = \"$pname\";" "$fname" ) data2="$(nix eval --impure --expr 'with import ./. {}; { inherit ('"$attrpath"') pname drvPath passthru meta; drvPath2='"$attrpath"'.src.drvPath; }' --json)" if [[ "$data" = "$data2" ]]; then (set -x; git-wait add "$fname") else (set -x; git-wait restore "$fname") exit fi (set -x sd -F ' rec {' ' {' "$fname" ) data3="$(nix eval --impure --expr 'with import ./. {}; { inherit ('"$attrpath"') pname drvPath passthru meta; drvPath2='"$attrpath"'.src.drvPath; }' --json 2>/dev/nul)" if [[ "$data" = "$data3" ]]; then (set -x; git-wait add "$fname") else (set -x; git-wait restore "$fname") fi ) 200>"$FLOCKDIR"/"$(sha256sum - <<<"$fname" | cut -d' ' -f1)".lock & while [[ $(jobs -p | wc -l) -ge $N_WORKERS ]]; do wait -n < <(jobs -p) || true done done < <(list_attrpath_fname_col) wait git restore . time nix-env --extra-experimental-features no-url-literals --option system x86_64-linux -f ./. -qaP --json --meta --drv-path --out-path --show-trace --no-allow-import-from-derivation --arg config '{ allowAliases = false; }' > packages2.json ``` `diff packages{,2}.json` is empty, indicating that no package nor src derivation has changed. I checked and cherry-picked the changes using `GIT_DIFF_OPTS='-u15' git -c interactive.singleKey=true add --patch`
71 lines
1.8 KiB
Nix
71 lines
1.8 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
fetchFromGitHub,
|
|
bmake,
|
|
docbook_xsl,
|
|
libxslt,
|
|
}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "libfsm";
|
|
version = "0.1pre2987_${builtins.substring 0 8 src.rev}";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "katef";
|
|
repo = "libfsm";
|
|
rev = "087e3389ad2cd5e5c40caeb40387e632567d7258";
|
|
hash = "sha256-XWrZxnRbMB609l+sYFf8VsXy3NxqBsBPUrHgKLIyu/I=";
|
|
fetchSubmodules = true;
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
bmake
|
|
docbook_xsl
|
|
libxslt # xsltproc
|
|
];
|
|
enableParallelBuilding = true;
|
|
enableParallelInstalling = false;
|
|
|
|
# note: build checks value of '$CC' to add some extra cflags, but we don't
|
|
# necessarily know which 'stdenv' someone chose, so we leave it alone (e.g.
|
|
# if we use stdenv vs clangStdenv, we don't know which, and CC=cc in all
|
|
# cases.) it's unclear exactly what should be done if we want those flags,
|
|
# but the defaults work fine.
|
|
makeFlags = [
|
|
"-r"
|
|
"PREFIX=$(out)"
|
|
];
|
|
|
|
# fix up multi-output install. we also have to fix the pkg-config libdir
|
|
# file; it uses prefix=$out; libdir=${prefix}/lib, which is wrong in
|
|
# our case; libdir should really be set to the $lib output.
|
|
postInstall = ''
|
|
mkdir -p $lib $dev/lib
|
|
|
|
mv $out/lib $lib/lib
|
|
mv $out/include $dev/include
|
|
mv $out/share/pkgconfig $dev/lib/pkgconfig
|
|
rmdir $out/share
|
|
|
|
for x in libfsm.pc libre.pc; do
|
|
substituteInPlace "$dev/lib/pkgconfig/$x" \
|
|
--replace 'libdir=''${prefix}/lib' "libdir=$lib/lib"
|
|
done
|
|
'';
|
|
|
|
outputs = [
|
|
"out"
|
|
"lib"
|
|
"dev"
|
|
];
|
|
|
|
meta = with lib; {
|
|
description = "DFA regular expression library & friends";
|
|
homepage = "https://github.com/katef/libfsm";
|
|
license = licenses.bsd2;
|
|
platforms = platforms.unix;
|
|
maintainers = with maintainers; [ thoughtpolice ];
|
|
};
|
|
}
|