99 lines
2.7 KiB
Nix
99 lines
2.7 KiB
Nix
{
|
|
description = "collapse";
|
|
|
|
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}";
|
|
|
|
collapse = naersk-lib.buildPackage {
|
|
pname = "collapse";
|
|
root = ./.;
|
|
|
|
buildInputs = with pkgs; [
|
|
openssl
|
|
pkg-config
|
|
];
|
|
};
|
|
in rec {
|
|
# `nix build`
|
|
packages.collapse = collapse;
|
|
|
|
defaultPackage = packages.collapse;
|
|
|
|
# `nix run`
|
|
apps.collapse = utils.lib.mkApp {
|
|
drv = collapse;
|
|
};
|
|
defaultApp = apps.collapse;
|
|
|
|
# `nix develop`
|
|
devShell = devenv.lib.mkShell {
|
|
inherit inputs pkgs;
|
|
modules = [
|
|
{
|
|
# Configure packages to install.
|
|
# Search for package names at https://search.nixos.org/packages?channel=unstable
|
|
packages = [
|
|
fenixRustToolchain
|
|
pkgs.gcc
|
|
|
|
pkgs.openssl
|
|
pkgs.pkg-config
|
|
|
|
pkgs.mdbook
|
|
pkgs.mdbook-toc
|
|
];
|
|
|
|
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"''
|
|
];
|
|
};
|
|
}
|
|
];
|
|
};
|
|
});
|
|
}
|