Remove rust-toolchain.toml and reformat Nix sources

This commit is contained in:
Luc Perkins 2023-05-25 16:28:59 +02:00
parent 5b593d5200
commit 4776c20c2e
No known key found for this signature in database
GPG Key ID: 4F102D0C16E232F2
3 changed files with 119 additions and 109 deletions

View File

@ -19,13 +19,16 @@ let
# For easy cross-compilation in devShells
# We are just composing the pkgsCross.*.stdenv.cc together
crossPlatforms = let
makeCrossPlatform = crossSystem: let
crossPlatforms =
let
makeCrossPlatform = crossSystem:
let
pkgsCross =
if crossSystem == system then pkgs
else import pkgs.path {
else
import pkgs.path {
inherit system crossSystem;
overlays = [];
overlays = [ ];
};
rustTargetSpec = rust.toRustTargetSpec pkgsCross.pkgsStatic.stdenv.hostPlatform;
@ -35,7 +38,8 @@ let
cargoCcEnv = "CC_${rustTargetSpecUnderscored}"; # for ring
cc = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc";
in {
in
{
name = crossSystem;
value = {
inherit rustTargetSpec cc;
@ -47,12 +51,14 @@ let
};
};
systems = lib.filter (s: s == system || lib.hasInfix "linux" s) supportedSystems;
in builtins.listToAttrs (map makeCrossPlatform systems);
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
buildFor = system:
let
crossPlatform = crossPlatforms.${system};
inherit (crossPlatform) pkgs;
craneLib = (crane.mkLib pkgs).overrideToolchain rustNightly;
@ -60,18 +66,18 @@ let
cargoToml = ./Cargo.toml;
};
src = nix-gitignore.gitignoreSource [] ./.;
src = nix-gitignore.gitignoreSource [ ] ./.;
commonArgs = {
inherit (crateName) pname version;
inherit src;
buildInputs = with pkgs; []
buildInputs = with pkgs; [ ]
++ lib.optionals pkgs.stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
];
nativeBuildInputs = with pkgs; []
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 [
@ -93,10 +99,12 @@ let
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# The resulting executable must be standalone
allowedRequisites = [];
allowedRequisites = [ ];
});
in crate;
in {
in
crate;
in
{
inherit crossPlatforms cargoTargets cargoCrossEnvs rustNightly;
flake-checker = buildFor system;

View File

@ -22,9 +22,12 @@
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }: let
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }:
let
supportedSystems = flake-utils.lib.defaultSystems;
in flake-utils.lib.eachSystem supportedSystems (system: let
in
flake-utils.lib.eachSystem supportedSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
@ -37,7 +40,8 @@
cranePkgs = pkgs.callPackage ./crane.nix {
inherit crane supportedSystems;
};
in {
in
{
packages = rec {
inherit (cranePkgs) flake-checker;
default = flake-checker;

View File

@ -1,2 +0,0 @@
[toolchain]
channel = "1.69.0"