Something went wrong. Try again.
The Unicode Collation Algorithm (UTS #10) and CLDR locale tailorings in Zig: sort text the way people expect rather than by code point.
Something went wrong. Try again.
zig-collate flake.nix
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us># SPDX-License-Identifier: MIT
{ description = "zig-collate - the Unicode Collation Algorithm in Zig";
inputs = { nixpkgs = { url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"; }; # Turns build.zig.zon into a Nix expression, so that the dependencies are # fetched by Nix and the build itself needs no network of its own. # # An input rather than a `nix run` of it, so that the Zig it runs is this # flake's. zon2nix shells out to `zig env` for the version and to `zig # fetch` for each dependency, and looks for zig on PATH; run from a shell # without one it says "unable to execute zig, is it in your PATH?" and # stops without writing anything, so the old build.zig.zon.nix survives # looking untouched. The devshell below wraps it so that cannot happen. zon2nix = { url = "git+https://codeberg.org/jcollie/zon2nix.git"; inputs.nixpkgs.follows = "nixpkgs"; }; };
outputs = { self, nixpkgs, zon2nix, ... }:
let inherit (nixpkgs) lib; makePackages = system: import nixpkgs { inherit system; }; forAllSystems = lib.genAttrs lib.systems.flakeExposed;
in { devShells = forAllSystems ( system: let pkgs = makePackages system; zig = pkgs.zig_0_17; in { default = pkgs.mkShell { name = "zig-collate"; nativeBuildInputs = [ zig pkgs.pinact pkgs.git-pages-cli pkgs.reuse # ICU, for `zig build oracle`: it is the reference # implementation of the CLDR collation algorithm and the thing # every other collation is checked against in turn. The C++ is # compiled by Zig rather than by a toolchain of its own, so # this needs the library and pkg-config and nothing more. # `icu.dev` carries the headers and the `.pc` files that Zig # finds the library through; without pkg-config Zig looks for a # library called `libicu-i18n`, which does not exist. pkgs.pkg-config pkgs.icu.dev pkgs.icu # Regenerates build.zig.zon.nix from build.zig.zon, with the Zig # it shells out to fixed to this flake's rather than whatever # the caller happens to have. (pkgs.symlinkJoin { name = "zon2nix"; paths = [ zon2nix.packages.${pkgs.stdenv.hostPlatform.system}.zon2nix ]; nativeBuildInputs = [ pkgs.makeWrapper ]; postBuild = '' wrapProgram $out/bin/zon2nix \ --prefix PATH : ${lib.makeBinPath [ zig ]} ''; }) ] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.kcov pkgs.perf ]; }; } ); };}