mirror of https://gitlab.com/famedly/conduit
build(nix): fix flake builds
parent
d68dad580b
commit
5d913f7010
@ -1,74 +1,56 @@
|
|||||||
{
|
{
|
||||||
inputs = {
|
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs";
|
inputs.d2n.url = "github:nix-community/dream2nix";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
inputs.d2n.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
inputs.parts.url = "github:hercules-ci/flake-parts";
|
||||||
fenix = {
|
inputs.rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
url = "github:nix-community/fenix";
|
inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
outputs = inp:
|
||||||
naersk = {
|
inp.parts.lib.mkFlake {inputs = inp;} {
|
||||||
url = "github:nix-community/naersk";
|
systems = ["x86_64-linux"];
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
imports = [inp.d2n.flakeModuleBeta];
|
||||||
};
|
perSystem = {
|
||||||
};
|
config,
|
||||||
|
system,
|
||||||
outputs =
|
pkgs,
|
||||||
{ self
|
...
|
||||||
, nixpkgs
|
}: let
|
||||||
, flake-utils
|
|
||||||
|
|
||||||
, fenix
|
|
||||||
, naersk
|
|
||||||
}: flake-utils.lib.eachDefaultSystem (system:
|
|
||||||
let
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
|
|
||||||
# Nix-accessible `Cargo.toml`
|
|
||||||
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
||||||
|
pkgsWithToolchain = pkgs.appendOverlays [inp.rust-overlay.overlays.default];
|
||||||
# The Rust toolchain to use
|
|
||||||
toolchain = fenix.packages.${system}.toolchainOf {
|
toolchains = pkgsWithToolchain.rust-bin.stable."${cargoToml.package.rust-version}";
|
||||||
# Use the Rust version defined in `Cargo.toml`
|
# toolchain to use when building conduit, includes only cargo and rustc to reduce closure size
|
||||||
channel = cargoToml.package.rust-version;
|
buildToolchain = toolchains.minimal;
|
||||||
|
# toolchain to use in development shell
|
||||||
# THE rust-version HASH
|
# the "default" component set of toolchain adds rustfmt, clippy etc.
|
||||||
sha256 = "sha256-8len3i8oTwJSOJZMosGGXHBL5BVuGQnWOT2St5YAUFU=";
|
devToolchain = toolchains.default.override {
|
||||||
|
extensions = ["rust-src"];
|
||||||
};
|
};
|
||||||
|
|
||||||
builder = (pkgs.callPackage naersk {
|
# flake outputs for conduit project
|
||||||
inherit (toolchain) rustc cargo;
|
conduitOutputs = config.dream2nix.outputs.conduit;
|
||||||
}).buildPackage;
|
in {
|
||||||
in
|
dream2nix.inputs.conduit = {
|
||||||
{
|
source = inp.self;
|
||||||
packages.default = builder {
|
projects.conduit = {
|
||||||
src = ./.;
|
name = "conduit";
|
||||||
|
subsystem = "rust";
|
||||||
nativeBuildInputs = (with pkgs.rustPlatform; [
|
translator = "cargo-lock";
|
||||||
bindgenHook
|
};
|
||||||
]);
|
packageOverrides = {
|
||||||
|
"^.*".set-toolchain.overrideRustToolchain = _: {
|
||||||
|
cargo = buildToolchain;
|
||||||
|
rustc = buildToolchain;
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
|
||||||
# Rust Analyzer needs to be able to find the path to default crate
|
|
||||||
# sources, and it can read this environment variable to do so
|
|
||||||
RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/library";
|
|
||||||
|
|
||||||
# Development tools
|
|
||||||
nativeBuildInputs = (with pkgs.rustPlatform; [
|
|
||||||
bindgenHook
|
|
||||||
]) ++ (with toolchain; [
|
|
||||||
cargo
|
|
||||||
clippy
|
|
||||||
rust-src
|
|
||||||
rustc
|
|
||||||
rustfmt
|
|
||||||
]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
checks = {
|
|
||||||
packagesDefault = self.packages.${system}.default;
|
|
||||||
devShellsDefault = self.devShells.${system}.default;
|
|
||||||
};
|
};
|
||||||
|
devShells.conduit = conduitOutputs.devShells.conduit.overrideAttrs (old: {
|
||||||
|
# export default crate sources for rust-analyzer to read
|
||||||
|
RUST_SRC_PATH = "${devToolchain}/lib/rustlib/src/rust/library";
|
||||||
|
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [devToolchain];
|
||||||
});
|
});
|
||||||
|
devShells.default = config.devShells.conduit;
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue