mirror of
https://github.com/DeterminateSystems/flake-checker.git
synced 2024-08-16 17:40:22 +03:00
Remove rust-toolchain.toml and reformat Nix sources
This commit is contained in:
parent
5b593d5200
commit
4776c20c2e
152
crane.nix
152
crane.nix
@ -19,85 +19,93 @@ let
|
||||
|
||||
# For easy cross-compilation in devShells
|
||||
# We are just composing the pkgsCross.*.stdenv.cc together
|
||||
crossPlatforms = let
|
||||
makeCrossPlatform = crossSystem: let
|
||||
pkgsCross =
|
||||
if crossSystem == system then pkgs
|
||||
else import pkgs.path {
|
||||
inherit system crossSystem;
|
||||
overlays = [];
|
||||
crossPlatforms =
|
||||
let
|
||||
makeCrossPlatform = crossSystem:
|
||||
let
|
||||
pkgsCross =
|
||||
if crossSystem == system then pkgs
|
||||
else
|
||||
import pkgs.path {
|
||||
inherit system crossSystem;
|
||||
overlays = [ ];
|
||||
};
|
||||
|
||||
rustTargetSpec = rust.toRustTargetSpec pkgsCross.pkgsStatic.stdenv.hostPlatform;
|
||||
rustTargetSpecUnderscored = builtins.replaceStrings [ "-" ] [ "_" ] rustTargetSpec;
|
||||
|
||||
cargoLinkerEnv = lib.strings.toUpper "CARGO_TARGET_${rustTargetSpecUnderscored}_LINKER";
|
||||
cargoCcEnv = "CC_${rustTargetSpecUnderscored}"; # for ring
|
||||
|
||||
cc = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc";
|
||||
in
|
||||
{
|
||||
name = crossSystem;
|
||||
value = {
|
||||
inherit rustTargetSpec cc;
|
||||
pkgs = pkgsCross;
|
||||
env = {
|
||||
"${cargoLinkerEnv}" = cc;
|
||||
"${cargoCcEnv}" = cc;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
rustTargetSpec = rust.toRustTargetSpec pkgsCross.pkgsStatic.stdenv.hostPlatform;
|
||||
rustTargetSpecUnderscored = builtins.replaceStrings [ "-" ] [ "_" ] rustTargetSpec;
|
||||
|
||||
cargoLinkerEnv = lib.strings.toUpper "CARGO_TARGET_${rustTargetSpecUnderscored}_LINKER";
|
||||
cargoCcEnv = "CC_${rustTargetSpecUnderscored}"; # for ring
|
||||
|
||||
cc = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc";
|
||||
in {
|
||||
name = crossSystem;
|
||||
value = {
|
||||
inherit rustTargetSpec cc;
|
||||
pkgs = pkgsCross;
|
||||
env = {
|
||||
"${cargoLinkerEnv}" = cc;
|
||||
"${cargoCcEnv}" = cc;
|
||||
};
|
||||
};
|
||||
};
|
||||
systems = lib.filter (s: s == system || lib.hasInfix "linux" s) supportedSystems;
|
||||
in builtins.listToAttrs (map makeCrossPlatform systems);
|
||||
systems = lib.filter (s: s == system || lib.hasInfix "linux" s) supportedSystems;
|
||||
in
|
||||
builtins.listToAttrs (map makeCrossPlatform systems);
|
||||
|
||||
cargoTargets = lib.mapAttrsToList (_: p: p.rustTargetSpec) crossPlatforms;
|
||||
cargoCrossEnvs = lib.foldl (acc: p: acc // p.env) {} (builtins.attrValues crossPlatforms);
|
||||
cargoCrossEnvs = lib.foldl (acc: p: acc // p.env) { } (builtins.attrValues crossPlatforms);
|
||||
|
||||
buildFor = system: let
|
||||
crossPlatform = crossPlatforms.${system};
|
||||
inherit (crossPlatform) pkgs;
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain rustNightly;
|
||||
crateName = craneLib.crateNameFromCargoToml {
|
||||
cargoToml = ./Cargo.toml;
|
||||
};
|
||||
|
||||
src = nix-gitignore.gitignoreSource [] ./.;
|
||||
|
||||
commonArgs = {
|
||||
inherit (crateName) pname version;
|
||||
inherit src;
|
||||
|
||||
buildInputs = with pkgs; []
|
||||
++ lib.optionals pkgs.stdenv.isDarwin [
|
||||
darwin.apple_sdk.frameworks.Security
|
||||
];
|
||||
|
||||
nativeBuildInputs = with pkgs; []
|
||||
# The Rust toolchain from rust-overlay has a dynamic libiconv in depsTargetTargetPropagated
|
||||
# Our static libiconv needs to take precedence
|
||||
++ lib.optionals pkgs.stdenv.isDarwin [
|
||||
(libiconv.override { enableStatic = true; enableShared = false; })
|
||||
];
|
||||
|
||||
cargoExtraArgs = "--target ${crossPlatform.rustTargetSpec}";
|
||||
|
||||
cargoVendorDir = craneLib.vendorMultipleCargoDeps {
|
||||
inherit (craneLib.findCargoFiles src) cargoConfigs;
|
||||
cargoLockList = [
|
||||
./Cargo.lock
|
||||
"${rustNightly.passthru.availableComponents.rust-src}/lib/rustlib/src/rust/Cargo.lock"
|
||||
];
|
||||
buildFor = system:
|
||||
let
|
||||
crossPlatform = crossPlatforms.${system};
|
||||
inherit (crossPlatform) pkgs;
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain rustNightly;
|
||||
crateName = craneLib.crateNameFromCargoToml {
|
||||
cargoToml = ./Cargo.toml;
|
||||
};
|
||||
} // crossPlatform.env;
|
||||
|
||||
crate = craneLib.buildPackage (commonArgs // {
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
src = nix-gitignore.gitignoreSource [ ] ./.;
|
||||
|
||||
# The resulting executable must be standalone
|
||||
allowedRequisites = [];
|
||||
});
|
||||
in crate;
|
||||
in {
|
||||
commonArgs = {
|
||||
inherit (crateName) pname version;
|
||||
inherit src;
|
||||
|
||||
buildInputs = with pkgs; [ ]
|
||||
++ lib.optionals pkgs.stdenv.isDarwin [
|
||||
darwin.apple_sdk.frameworks.Security
|
||||
];
|
||||
|
||||
nativeBuildInputs = with pkgs; [ ]
|
||||
# The Rust toolchain from rust-overlay has a dynamic libiconv in depsTargetTargetPropagated
|
||||
# Our static libiconv needs to take precedence
|
||||
++ lib.optionals pkgs.stdenv.isDarwin [
|
||||
(libiconv.override { enableStatic = true; enableShared = false; })
|
||||
];
|
||||
|
||||
cargoExtraArgs = "--target ${crossPlatform.rustTargetSpec}";
|
||||
|
||||
cargoVendorDir = craneLib.vendorMultipleCargoDeps {
|
||||
inherit (craneLib.findCargoFiles src) cargoConfigs;
|
||||
cargoLockList = [
|
||||
./Cargo.lock
|
||||
"${rustNightly.passthru.availableComponents.rust-src}/lib/rustlib/src/rust/Cargo.lock"
|
||||
];
|
||||
};
|
||||
} // crossPlatform.env;
|
||||
|
||||
crate = craneLib.buildPackage (commonArgs // {
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
|
||||
# The resulting executable must be standalone
|
||||
allowedRequisites = [ ];
|
||||
});
|
||||
in
|
||||
crate;
|
||||
in
|
||||
{
|
||||
inherit crossPlatforms cargoTargets cargoCrossEnvs rustNightly;
|
||||
|
||||
flake-checker = buildFor system;
|
||||
}
|
||||
}
|
||||
|
74
flake.nix
74
flake.nix
@ -1,5 +1,5 @@
|
||||
{
|
||||
inputs = {
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
@ -22,41 +22,45 @@
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }: let
|
||||
supportedSystems = flake-utils.lib.defaultSystems;
|
||||
in flake-utils.lib.eachSystem supportedSystems (system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
rust-overlay.overlay
|
||||
];
|
||||
};
|
||||
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }:
|
||||
let
|
||||
supportedSystems = flake-utils.lib.defaultSystems;
|
||||
in
|
||||
flake-utils.lib.eachSystem supportedSystems (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
rust-overlay.overlay
|
||||
];
|
||||
};
|
||||
|
||||
inherit (pkgs) lib;
|
||||
inherit (pkgs) lib;
|
||||
|
||||
cranePkgs = pkgs.callPackage ./crane.nix {
|
||||
inherit crane supportedSystems;
|
||||
};
|
||||
in {
|
||||
packages = rec {
|
||||
inherit (cranePkgs) flake-checker;
|
||||
default = flake-checker;
|
||||
};
|
||||
devShells = {
|
||||
default = pkgs.mkShell ({
|
||||
inputsFrom = [ cranePkgs.flake-checker ];
|
||||
packages = with pkgs; [
|
||||
bashInteractive
|
||||
cranePkgs.rustNightly
|
||||
cranePkgs = pkgs.callPackage ./crane.nix {
|
||||
inherit crane supportedSystems;
|
||||
};
|
||||
in
|
||||
{
|
||||
packages = rec {
|
||||
inherit (cranePkgs) flake-checker;
|
||||
default = flake-checker;
|
||||
};
|
||||
devShells = {
|
||||
default = pkgs.mkShell ({
|
||||
inputsFrom = [ cranePkgs.flake-checker ];
|
||||
packages = with pkgs; [
|
||||
bashInteractive
|
||||
cranePkgs.rustNightly
|
||||
|
||||
cargo-bloat
|
||||
cargo-edit
|
||||
cargo-udeps
|
||||
cargo-edit
|
||||
cargo-watch
|
||||
rust-analyzer
|
||||
];
|
||||
} // cranePkgs.cargoCrossEnvs);
|
||||
};
|
||||
});
|
||||
cargo-bloat
|
||||
cargo-edit
|
||||
cargo-udeps
|
||||
cargo-edit
|
||||
cargo-watch
|
||||
rust-analyzer
|
||||
];
|
||||
} // cranePkgs.cargoCrossEnvs);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -1,2 +0,0 @@
|
||||
[toolchain]
|
||||
channel = "1.69.0"
|
Loading…
Reference in New Issue
Block a user