{ description = "Development Nix flake for the gitara_web (kompress_eshop) loco-rs app"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, rust-overlay, ... }: let systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; forAllSystems = f: nixpkgs.lib.genAttrs systems f; # Read the version from the root Cargo.toml (single source of truth). cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); cargoVersion = cargoToml.package.version; # On a release commit Cargo.toml carries the real version. Otherwise fall # back to a dev version derived from the flake source revision. version = if cargoVersion != "0.0.0" then cargoVersion else "0.0.0-dev+${self.shortRev or "dirty"}"; in { packages = forAllSystems (system: let pkgs = import nixpkgs { inherit system; overlays = [ rust-overlay.overlays.default ]; }; rustPlatform = pkgs.makeRustPlatform { cargo = pkgs.rust-bin.stable.latest.minimal; rustc = pkgs.rust-bin.stable.latest.minimal; }; gitara-web = rustPlatform.buildRustPackage { pname = "gitara_web"; inherit version; src = ./.; cargoLock.lockFile = ./Cargo.lock; nativeBuildInputs = [ pkgs.pkg-config pkgs.cmake pkgs.llvmPackages.clang ]; buildInputs = [ pkgs.openssl ]; # Build only the application binary. cargoBuildFlags = [ "--bin" "gitara_web-cli" ]; # Tests need a database/runtime environment; skip during the build. doCheck = false; PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; }; in { gitara-web = gitara-web; default = gitara-web; } ); devShells = forAllSystems (system: let pkgs = import nixpkgs { inherit system; overlays = [ rust-overlay.overlays.default ]; }; rust = pkgs.rust-bin.stable.latest.default.override { extensions = [ "rust-src" "rust-analyzer" ]; }; in { default = pkgs.mkShell { buildInputs = [ rust pkgs.pkg-config pkgs.openssl pkgs.cmake pkgs.llvmPackages.clang pkgs.llvmPackages.libclang.lib # loco-rs CLI workflow helpers pkgs.sea-orm-cli ]; PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; # Use clang for native C deps (avoids GCC 15 warnings-as-errors) shellHook = '' export CC=clang export CXX=clang++ ''; }; } ); }; }