Something went wrong. Try again.
passlib's password hash schemes, ported to Zig 0.16
Something went wrong. Try again.
zig-passlib build.zig.zon.nix
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138# generated by zon2nix (https://github.com/jcollie/zon2nix){ lib, fetchgit, fetchurl, fetchzip, runCommandLocal, zig_0_16, zstd, name ? "zig-packages", # Accepted and ignored. Expressions from zon2nix before 0.8 built the # packages with `linkFarm`, and some callers override it with a version that # copies, to work around Zig mishandling symlinked package directories # (https://codeberg.org/ziglang/zig/issues/32121). The packages are real # directories now, so the override is not needed, and is taken here only so # that passing it is not an error. linkFarm ? null,}:let # A git repository, checked out the way Zig reads it: every file as # committed. An ordinary checkout applies the repository's `.gitattributes`, # which can rewrite a file's line endings or run it through a filter, and # the package would then no longer match its hash. Pointing git at its # built-in empty tree for attributes turns them all off, and `core.autocrlf` # is turned off too, since it converts line endings even without them. # zon2nix computes the hash with exactly these settings. fetchZigGit = args: fetchgit ( args // { fetchSubmodules = false; preFetch = '' export GIT_ATTR_SOURCE=4b825dc642cb6eb9a060e54bf8d69288fbee4904 export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=core.autocrlf GIT_CONFIG_VALUE_0=false ''; } );
# Every package, by the hash Zig knows it by, as Nix fetches it. packages = { "N-V-__8AAM9FGQDkwJ56__CpfY0eUvYj5Qh4IBttCsz20Md7" = fetchZigGit { name = "cpace_draft"; url = "https://github.com/cfrg/draft-irtf-cfrg-cpace"; rev = "8fb4056e1b9201927d9f651b9970d9d5660c7892"; hash = "sha256-mSgM4GbB0omOoepowMXndvWCuydsp5WunVJBjCIrnHI="; }; "sasl-0.0.0-s3YcOMMUAgA7-HtfM-XSdyJoxdYCrrg-oG66c9qZHEcp" = fetchZigGit { name = "sasl"; url = "https://git.jcollie.dev/jeff/zig-sasl.git"; rev = "ed616574a3f9842e1e6e25761d98bb78fc7e7292"; hash = "sha256-qPY/qDbrK2O/s+0GoZyqfVHSny9qqDA6u6jyh5v5pJw="; }; "scram-0.0.0-TbREmiREAwCRvJLijWMrugBAQc3GgkrEbwPQ54SaFx97" = fetchZigGit { name = "scram"; url = "https://git.jcollie.dev/jeff/zig-scram.git"; rev = "b65a6473e1c1b40fc4e2ae06ab1a458092fbe454"; hash = "sha256-BQdAeGn4d0NJDqLo/BuMTEG10dvueRYRqavDsvCYumo="; }; "std_crypto_ext-0.0.0-zmlw4RVfBgAvIR3lTJMyDSBcPZVCgUbAy4HmzzsZYCcG" = fetchZigGit { name = "std_crypto_ext"; url = "https://git.jcollie.dev/jeff/zig-std-crypto-ext.git"; rev = "3897d6136cc68e00ec2f400afa0a4856d4173efe"; hash = "sha256-rSqhgI5GfDX2FdfY7MnZhte30UjBFh/ffA3n2cbeTzE="; }; "uucode-0.2.0-ZZjBPh-6VADBlunHbwABTPng0DH6uJqd4CvvtjZ19tny" = fetchZigGit { name = "uucode"; url = "https://github.com/jacobsandlund/uucode"; rev = "61e54266895f833b307de81a0e3038cf1f1bebd4"; hash = "sha256-6Riz1CowKgQr70YAcfozHETUqfOR4gYIwUE5txjX70o="; }; };
# The packages whose own manifest declares a dependency by `.path`. Zig # 0.16.0 cannot build these through `zig build --system`: it spins in # userspace forever, because a `.path` dependency's hash is computed against # the system package directory during the fetch and against the real global # cache afterwards, and in that mode the two disagree. A package that wants # `--system` copies each of these into its build root and passes `--fork=`; # see the README. pathDependencyPackages = [ ];in# One directory holding every package the way Zig unpacks it -- filtered by# its manifest's `.paths` and checked against its hash -- which is what# `zig build --system` wants.## They have to be real directories holding real files, not links into each# package's own store path. Zig runs a dependency's build steps from inside# it and counts its way back out through `..`, which lands in the wrong place# when the directory is a symlink; and `installHeadersDirectory` copies only# what the directory walk calls a file, so symlinked headers are skipped# without a word. Building them all in one derivation gives real files from# the start, without a second copy of everything.runCommandLocal name { nativeBuildInputs = [ zig_0_16 ]; passthru = { inherit pathDependencyPackages; }; } '' mkdir "$out"
# Each package gets a directory of its own to work in, since `zig fetch` # leaves what it unpacked in `zig-pkg/` under the directory it ran in. unpack() { local work="$TMPDIR/work/$1" mkdir -p "$work/src" "$work/cache/tmp" # workaround https://codeberg.org/ziglang/zig/issues/31866 # https://github.com/Cloudef/zig2nix/issues/54 touch "$work/src/build.zig" # `zig fetch` recompresses every package into `p/` at gzip level 9 for # its own cache, which is nearly all of its time and of no use here. # With `p` a file rather than a directory that step fails at once -- # Zig warns, and carries on -- and the package is left in `zig-pkg/`. touch "$work/cache/p"
local hash if ! hash="$(cd "$work/src" && zig fetch --global-cache-dir "$work/cache" "$2" 2>"$work/log")"; then cat "$work/log" >&2 return 1 fi if [ "$hash" != "$1" ]; then echo "$2 is $hash to Zig, not $1" >&2 return 1 fi mv "$work/src/zig-pkg/$1" "$out/$1" rm -rf "$work" } export -f unpack
# Several at a time: `zig fetch` spends most of a package on one core. cores="''${NIX_BUILD_CORES:-0}" if [ "$cores" -le 0 ]; then cores="$(nproc)"; fi xargs -P "$cores" -n 2 bash -c 'unpack "$@"' unpack <<'EOF' ${lib.concatStrings (lib.mapAttrsToList (hash: src: "${hash} ${src}\n") packages)} EOF ''