Skip to content

Instantly share code, notes, and snippets.

@farcaller
Created September 15, 2022 10:23
Show Gist options
  • Save farcaller/b3b89baa892feda1cbb866d9e26a2d7b to your computer and use it in GitHub Desktop.
Save farcaller/b3b89baa892feda1cbb866d9e26a2d7b to your computer and use it in GitHub Desktop.
{
description = "Build a cargo project without extra checks";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, nixpkgs, crane, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
my-crate = crane.lib.${system}.buildPackage {
src = ./.;
buildInputs = with pkgs; [
openssl
];
nativeBuildInputs = with pkgs; [
pkg-config
];
};
in
{
checks = {
inherit my-crate;
};
packages.default = my-crate;
apps.default = flake-utils.lib.mkApp {
drv = my-crate;
};
contaners.default = pkgs.dockerTools.buildImage {
name = "kube-cidr-manager";
config = {
Cmd = [ "${my-crate}/bin/quick-start-simple" ];
};
};
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues self.checks;
buildInputs = my-crate.buildInputs;
nativeBuildInputs = with pkgs; [
cargo
rustc
rust-analyzer
clippy
# rust.packages.stable.rustPlatform.rustcSrc
rustfmt
rustPlatform.rustLibSrc
] ++ my-crate.nativeBuildInputs;
# RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
};
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment