{ description = "idCoop"; inputs = { utils.url = "github:numtide/flake-utils"; naersk.url = "github:nix-community/naersk"; # Current Rust in nixpkgs is too old unfortunately — let's use the Fenix overlay's packages... fenix = { url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; }; nixpkgs.url = "nixpkgs/nixos-24.05"; devenv.url = "github:cachix/devenv/v0.6.3"; }; outputs = inputs @ { self, nixpkgs, utils, naersk, fenix, devenv }: utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages."${system}"; fenixRustToolchain = fenix.packages."${system}".stable.withComponents [ "cargo" "clippy" "rust-src" "rustc" "rustfmt" "rust-analyzer" ]; naersk-lib = naersk.lib."${system}"; idcoop = naersk-lib.buildPackage { pname = "idcoop"; root = ./.; buildInputs = with pkgs; [ openssl pkgconfig ]; }; in rec { # `nix build` packages.idcoop = idcoop; defaultPackage = packages.idcoop; # `nix run` apps.idcoop = utils.lib.mkApp { drv = idcoop; }; defaultApp = apps.idcoop; # `nix develop` devShell = devenv.lib.mkShell { inherit inputs pkgs; modules = [ { services.postgres.enable = true; # Configure packages to install. # Search for package names at https://search.nixos.org/packages?channel=unstable packages = [ fenixRustToolchain pkgs.gcc # Useful for adding migrations, running them and generating offline # support metadata pkgs.sqlx-cli # Occasionally useful for removing unused dependencies # pkgs.cargo-machete # Test coverage. Vaguely useful but not definitive. pkgs.cargo-tarpaulin # Snapshot testing pkgs.cargo-insta pkgs.grass-sass pkgs.entr pkgs.mdbook pkgs.mdbook-toc # Useful for poking at the Postgres database pkgs.postgresql # Might be useful as an example OAuth 2 / OIDC client pkgs.oauth2c # Useful for generating RSA keypairs # also needed for our JWTs pkgs.openssl pkgs.pkg-config ]; env = { # Needed for bindgen when binding to avahi LIBCLANG_PATH="${pkgs.llvmPackages_latest.libclang.lib}/lib"; # Sometimes useful for reference. RUST_SRC_PATH = "${fenixRustToolchain}/lib/rustlib/src/rust/library"; # Cargo culted: # Add to rustc search path #RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [ #]); # Add to bindgen search path BINDGEN_EXTRA_CLANG_ARGS = # Includes with normal include path (builtins.map (a: ''-I"${a}/include"'') [ pkgs.glibc.dev ]) # Includes with special directory paths ++ [ ''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"'' ]; }; } ]; }; }); }