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
|
# For easy cross-compilation in devShells
|
||||||
# We are just composing the pkgsCross.*.stdenv.cc together
|
# We are just composing the pkgsCross.*.stdenv.cc together
|
||||||
crossPlatforms = let
|
crossPlatforms =
|
||||||
makeCrossPlatform = crossSystem: let
|
let
|
||||||
pkgsCross =
|
makeCrossPlatform = crossSystem:
|
||||||
if crossSystem == system then pkgs
|
let
|
||||||
else import pkgs.path {
|
pkgsCross =
|
||||||
inherit system crossSystem;
|
if crossSystem == system then pkgs
|
||||||
overlays = [];
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
systems = lib.filter (s: s == system || lib.hasInfix "linux" s) supportedSystems;
|
||||||
rustTargetSpec = rust.toRustTargetSpec pkgsCross.pkgsStatic.stdenv.hostPlatform;
|
in
|
||||||
rustTargetSpecUnderscored = builtins.replaceStrings [ "-" ] [ "_" ] rustTargetSpec;
|
builtins.listToAttrs (map makeCrossPlatform systems);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
cargoTargets = lib.mapAttrsToList (_: p: p.rustTargetSpec) crossPlatforms;
|
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
|
buildFor = system:
|
||||||
crossPlatform = crossPlatforms.${system};
|
let
|
||||||
inherit (crossPlatform) pkgs;
|
crossPlatform = crossPlatforms.${system};
|
||||||
craneLib = (crane.mkLib pkgs).overrideToolchain rustNightly;
|
inherit (crossPlatform) pkgs;
|
||||||
crateName = craneLib.crateNameFromCargoToml {
|
craneLib = (crane.mkLib pkgs).overrideToolchain rustNightly;
|
||||||
cargoToml = ./Cargo.toml;
|
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"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
} // crossPlatform.env;
|
|
||||||
|
|
||||||
crate = craneLib.buildPackage (commonArgs // {
|
src = nix-gitignore.gitignoreSource [ ] ./.;
|
||||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
|
||||||
|
|
||||||
# The resulting executable must be standalone
|
commonArgs = {
|
||||||
allowedRequisites = [];
|
inherit (crateName) pname version;
|
||||||
});
|
inherit src;
|
||||||
in crate;
|
|
||||||
in {
|
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;
|
inherit crossPlatforms cargoTargets cargoCrossEnvs rustNightly;
|
||||||
|
|
||||||
flake-checker = buildFor system;
|
flake-checker = buildFor system;
|
||||||
}
|
}
|
||||||
|
74
flake.nix
74
flake.nix
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
@ -22,41 +22,45 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }: let
|
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }:
|
||||||
supportedSystems = flake-utils.lib.defaultSystems;
|
let
|
||||||
in flake-utils.lib.eachSystem supportedSystems (system: let
|
supportedSystems = flake-utils.lib.defaultSystems;
|
||||||
pkgs = import nixpkgs {
|
in
|
||||||
inherit system;
|
flake-utils.lib.eachSystem supportedSystems (system:
|
||||||
overlays = [
|
let
|
||||||
rust-overlay.overlay
|
pkgs = import nixpkgs {
|
||||||
];
|
inherit system;
|
||||||
};
|
overlays = [
|
||||||
|
rust-overlay.overlay
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
inherit (pkgs) lib;
|
inherit (pkgs) lib;
|
||||||
|
|
||||||
cranePkgs = pkgs.callPackage ./crane.nix {
|
cranePkgs = pkgs.callPackage ./crane.nix {
|
||||||
inherit crane supportedSystems;
|
inherit crane supportedSystems;
|
||||||
};
|
};
|
||||||
in {
|
in
|
||||||
packages = rec {
|
{
|
||||||
inherit (cranePkgs) flake-checker;
|
packages = rec {
|
||||||
default = flake-checker;
|
inherit (cranePkgs) flake-checker;
|
||||||
};
|
default = flake-checker;
|
||||||
devShells = {
|
};
|
||||||
default = pkgs.mkShell ({
|
devShells = {
|
||||||
inputsFrom = [ cranePkgs.flake-checker ];
|
default = pkgs.mkShell ({
|
||||||
packages = with pkgs; [
|
inputsFrom = [ cranePkgs.flake-checker ];
|
||||||
bashInteractive
|
packages = with pkgs; [
|
||||||
cranePkgs.rustNightly
|
bashInteractive
|
||||||
|
cranePkgs.rustNightly
|
||||||
|
|
||||||
cargo-bloat
|
cargo-bloat
|
||||||
cargo-edit
|
cargo-edit
|
||||||
cargo-udeps
|
cargo-udeps
|
||||||
cargo-edit
|
cargo-edit
|
||||||
cargo-watch
|
cargo-watch
|
||||||
rust-analyzer
|
rust-analyzer
|
||||||
];
|
];
|
||||||
} // cranePkgs.cargoCrossEnvs);
|
} // cranePkgs.cargoCrossEnvs);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
[toolchain]
|
|
||||||
channel = "1.69.0"
|
|
Loading…
Reference in New Issue
Block a user