Something went wrong. Try again.
A facial recognition login service for Linux.
Something went wrong. Try again.
pareidolia flake.nix
4.8 kB · 116 lines
Nix
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117{ description = "Pareidolia: a facial recognition login service for Linux.";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.rust-overlay.url = "github:oxalica/rust-overlay"; inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, rust-overlay, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; overlays = [ rust-overlay.overlays.default ]; };
# Pin the Rust toolchain so every contributor gets the same one. Bump # this in lockstep with rust-version in Cargo.toml. rustToolchain = pkgs.rust-bin.stable."1.90.0".default.override { extensions = [ "rust-src" "rust-analyzer" "clippy" "rustfmt" ]; };
models = import ./nix/models.nix { inherit (pkgs) fetchurl; };
# Native build inputs needed at compile time. M1 has no third-party # crate deps; this list will grow as milestones land (onnxruntime, # v4l, pam, etc). nativeBuildInputs = with pkgs; [ rustToolchain pkg-config
# bindgenHook sets up LIBCLANG_PATH and BINDGEN_EXTRA_CLANG_ARGS # correctly for the wrapped clang to find both libclang and the # surrounding C standard headers (glibc, kernel UAPI via stdenv). # The `v4l` crate's transitive `v4l2-sys-mit` build script needs # all of that to generate its FFI bindings. rustPlatform.bindgenHook ];
buildInputs = with pkgs; [ # V4L2 user-space library. The `v4l` Rust crate wraps libv4l for # capture; without this in buildInputs the crate's build script # can't find its system headers. v4l-utils
# ONNX Runtime. The `ort` crate uses `load-dynamic` so it dlopens # libonnxruntime via ORT_DYLIB_PATH at runtime; we wire that in # shellHook below. onnxruntime ]; in { devShells.default = pkgs.mkShell { inherit nativeBuildInputs buildInputs;
packages = with pkgs; [ # Disk-hygiene tooling (see CONTRIBUTING.md). cargo-sweep cargo-nextest
# Workflow conveniences. just ];
# Local builds keep incremental compilation for fast iteration. # CI sets CARGO_INCREMENTAL=0 to avoid bloating runner caches. # # ORT_DYLIB_PATH tells the `ort` crate's load-dynamic mode where # to find libonnxruntime at runtime. CI doesn't set it because # CI builds with --no-default-features (no ort dep at all). # # PAREIDOLIA_TEST_* point at the Nix-fetched model weights and # fixture images so `just test-hardware` runs without manual # asset setup. # # PAREIDOLIA_BUILD_REV is read at compile time by the CLI and # surfaced through `--version`. It's computed at shell-entry, # not at build time, so a build done immediately after `jj # commit` accurately reflects the new commit; a build done # later in the same shell session reflects whatever the rev # was when the shell was entered. Re-enter the shell (or # re-export the var) to refresh. shellHook = '' export RUST_BACKTRACE=1 export ORT_DYLIB_PATH=${pkgs.onnxruntime}/lib/libonnxruntime.so export PAREIDOLIA_TEST_MODEL=${models.scrfd_10g} export PAREIDOLIA_TEST_SCRFD=${models.scrfd_10g} export PAREIDOLIA_TEST_ARCFACE=${models.arcface_glintr100} export PAREIDOLIA_TEST_FACE=${models.face_t1} export PAREIDOLIA_BUILD_REV=$( jj log -r @ --no-graph -T 'commit_id' 2>/dev/null \ || git rev-parse HEAD 2>/dev/null \ || echo unknown ) ''; };
# Package outputs. The pareidolia binaries themselves land alongside # the NixOS module in M6; for now we expose the pinned model weights # so `nix build .#scrfd-10g` (etc.) materialises the file into the # store on demand for ad-hoc use outside the devShell. packages = { scrfd-10g = models.scrfd_10g; arcface-glintr100 = models.arcface_glintr100; };
checks = { # `nix flake check` is wired up properly in M1 by re-exporting the # devShell, which forces the toolchain + tool inputs to resolve. # Real Nix-level checks (VM tests, etc.) land in M6. devShell = self.devShells.${system}.default; }; });}