{ description = "HEX - a collection of terminal libraries"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; outputs = { self, nixpkgs }: let systems = [ "x86_64-linux" "aarch64-linux" ]; forAllSystems = nixpkgs.lib.genAttrs systems; # Source tree minus local-only dirs. Invoke flake commands with a # `path:` ref (`nix flake check path:.`): nix's git fetcher cannot # read this repo's sha256 object format. src = pkgs: pkgs.lib.cleanSourceWith { src = ./.; filter = name: _: let base = baseNameOf name; in !(builtins.elem base [ ".git" ".jj" ".zig-cache" "zig-out" "zig-pkg" ]); }; zigCacheDirs = '' export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig-global" export ZIG_LOCAL_CACHE_DIR="$TMPDIR/zig-local" ''; in { packages = forAllSystems (system: let pkgs = nixpkgs.legacyPackages.${system}; in { default = pkgs.stdenv.mkDerivation { pname = "hex"; version = "0.0.0"; src = src pkgs; meta.mainProgram = "hex"; nativeBuildInputs = [ pkgs.zig ]; dontConfigure = true; dontInstall = true; buildPhase = '' runHook preBuild ${zigCacheDirs} zig build --prefix "$out" runHook postBuild ''; }; }); # `nix flake check` — unit tests plus a smoke run of the exe (prints # the help text and exits 0). checks = forAllSystems (system: let pkgs = nixpkgs.legacyPackages.${system}; in { default = pkgs.stdenv.mkDerivation { pname = "hex-check"; version = "0.0.0"; src = src pkgs; nativeBuildInputs = [ pkgs.zig ]; dontConfigure = true; dontInstall = true; buildPhase = '' runHook preBuild ${zigCacheDirs} zig build test --summary all zig build run touch "$out" runHook postBuild ''; }; }); devShells = forAllSystems (system: let pkgs = nixpkgs.legacyPackages.${system}; in { default = pkgs.mkShell { name = "hex"; shellHook = '' export name=hex ''; packages = [ pkgs.zig pkgs.pkg-config pkgs.libssh ]; }; }); }; }