kon-cli/flake.nix

92 lines
2.4 KiB
Nix
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
rust-overlay,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [rust-overlay.overlays.default];
};
osxDependencies = with pkgs;
lib.optionals stdenv.isDarwin
[
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.CoreServices
darwin.apple_sdk.frameworks.SystemConfiguration
];
cargoTomlContents = builtins.readFile ./Cargo.toml;
version = (builtins.fromTOML cargoTomlContents).workspace.package.version;
rustVersion = (builtins.fromTOML cargoTomlContents).workspace.package."rust-version";
rustToolchain = pkgs.rust-bin.stable.${rustVersion}.default;
rustPlatform = pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};
my-crate = rustPlatform.buildRustPackage {
inherit version;
name = "my-crate";
buildInputs = with pkgs; [openssl] ++ osxDependencies;
nativeBuildInputs = with pkgs; [pkg-config openssl.dev];
src = pkgs.lib.cleanSourceWith {src = ./crates/cardano-tx-builder;};
doCheck = false; # dont run cargo test
CARGO_BUILD_TESTS = "false"; # dont even compile test binaries
cargoLock.lockFile = ./Cargo.lock;
GIT_COMMIT_HASH_SHORT = self.shortRev or "unknown";
};
packages = {
my-crate = my-crate;
default = packages.my-crate;
};
overlays.default = final: prev: {my-crate = packages.my-crate;};
gitRev =
if (builtins.hasAttr "rev" self)
then self.rev
else "dirty";
in {
inherit packages overlays;
devShell = pkgs.mkShell {
buildInputs = with pkgs;
[
pkg-config
openssl
cargo-insta
(rustToolchain.override {
extensions = ["rust-src" "clippy" "rustfmt" "rust-analyzer"];
})
]
++ osxDependencies;
shellHook = ''
export GIT_REVISION=${gitRev}
'';
};
});
}