106 lines
3.0 KiB
Nix
106 lines
3.0 KiB
Nix
{
|
|
description = "Labelo";
|
|
|
|
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-23.05";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, utils, naersk, fenix }:
|
|
utils.lib.eachDefaultSystem (system: let
|
|
pkgs = nixpkgs.legacyPackages."${system}";
|
|
#fenixRustToolchain = fenix.packages."${system}".minimal.toolchain
|
|
# fenixRustToolchain =
|
|
# fenix."${system}".complete.withComponents [
|
|
# "cargo"
|
|
# "clippy"
|
|
# "rust-src"
|
|
# "rustc"
|
|
# "rustfmt"
|
|
# ];
|
|
# fenixRustToolchain = fenix.packages."${system}".stable.toolchain;
|
|
fenixRustToolchain =
|
|
fenix.packages."${system}".stable.withComponents [
|
|
"cargo"
|
|
"clippy"
|
|
"rust-src"
|
|
"rustc"
|
|
"rustfmt"
|
|
"rust-analyzer"
|
|
];
|
|
# rust-toolchain = pkgs.symlinkJoin {
|
|
# name = "rust-toolchain";
|
|
# paths = [fenixRustToolchain.rustc fenixRustToolchain.cargo fenixRustToolchain.clippy fenixRustToolchain.rustfmt fenixRustToolchain.rustPlatform.rustcSrc];
|
|
# };
|
|
|
|
naersk-lib = naersk.lib."${system}";
|
|
|
|
labelo = naersk-lib.buildPackage {
|
|
pname = "labelo";
|
|
root = ./.;
|
|
|
|
buildInputs = with pkgs; [
|
|
openssl
|
|
pkgconfig
|
|
sqlite
|
|
];
|
|
};
|
|
in rec {
|
|
# `nix build`
|
|
packages.labelo = labelo;
|
|
|
|
defaultPackage = packages.labelo;
|
|
|
|
# NixOS Modules
|
|
# nixosModules = {
|
|
# yama = import ./nixos_modules/yama.nix self;
|
|
# };
|
|
|
|
# `nix run`
|
|
apps.labelo = utils.lib.mkApp {
|
|
drv = labelo;
|
|
};
|
|
defaultApp = apps.labelo;
|
|
|
|
# `nix develop`
|
|
devShell = pkgs.mkShell {
|
|
buildInputs = [
|
|
fenixRustToolchain
|
|
#rust-toolchain
|
|
|
|
pkgs.pkg-config
|
|
|
|
pkgs.libusb
|
|
];
|
|
|
|
nativeBuildInputs = [
|
|
];
|
|
|
|
# Don't know if this var does anything by itself, but you need to feed this value in to IntelliJ IDEA and it's probably easier to pull out of an env var than look it up each time.
|
|
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"''
|
|
];
|
|
#nativeBuildInputs = with pkgs; [ rustc cargo ];
|
|
};
|
|
});
|
|
}
|