build: fix rust-toolchain
This commit is contained in:
parent
b458b99c82
commit
587471f36a
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -125,9 +125,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.19.0"
|
||||
version = "1.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d"
|
||||
checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
@ -490,9 +490,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.161"
|
||||
version = "0.2.164"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1"
|
||||
checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f"
|
||||
|
||||
[[package]]
|
||||
name = "libfuzzer-sys"
|
||||
@ -1188,9 +1188,9 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
|
||||
|
||||
[[package]]
|
||||
name = "wide"
|
||||
version = "0.7.28"
|
||||
version = "0.7.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b828f995bf1e9622031f8009f8481a85406ce1f4d4588ff746d872043e855690"
|
||||
checksum = "58e6db2670d2be78525979e9a5f9c69d296fd7d670549fe9ebf70f8708cb5019"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"safe_arch",
|
||||
|
||||
117
flake.lock
generated
117
flake.lock
generated
@ -101,15 +101,17 @@
|
||||
"flake-compat": "flake-compat_3",
|
||||
"flake-parts": "flake-parts_3",
|
||||
"nix-test-runner": "nix-test-runner_3",
|
||||
"nixpkgs": "nixpkgs_6",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"pre-commit-hooks": "pre-commit-hooks_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1730277369,
|
||||
"narHash": "sha256-yvQbeJbnnwCB68yv7uZXdGb+P7NMn5JMGBw0aBHymDI=",
|
||||
"lastModified": 1732039290,
|
||||
"narHash": "sha256-LQKY7bShf2H9kJouxa9ZspfdrulnZF9o4kLTqGqCDYM=",
|
||||
"owner": "nix-community",
|
||||
"repo": "crate2nix",
|
||||
"rev": "151122427d030874ebef3517cda766a6984e6ed6",
|
||||
"rev": "9ff208ce7f5a482272b1bcefbe363c772d7ff914",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -258,26 +260,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"devshell_4": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1728330715,
|
||||
"narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=",
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
@ -386,26 +368,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts_4": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1730504689,
|
||||
"narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "506278e768c2a08bec68eb62932193e341f55c90",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
@ -496,6 +458,24 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_6": {
|
||||
"inputs": {
|
||||
"systems": "systems_6"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
@ -689,30 +669,16 @@
|
||||
},
|
||||
"nixpkgs_6": {
|
||||
"locked": {
|
||||
"lastModified": 1712026416,
|
||||
"narHash": "sha256-N/3VR/9e1NlN49p7kCiATiEY6Tzdo+CbrAG8kqCQKcI=",
|
||||
"lastModified": 1717179513,
|
||||
"narHash": "sha256-vboIEwIQojofItm2xGCdZCzW96U85l9nDW3ifMuAIdM=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "080a4a27f206d07724b88da096e27ef63401a504",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_7": {
|
||||
"locked": {
|
||||
"lastModified": 1731763621,
|
||||
"narHash": "sha256-ddcX4lQL0X05AYkrkV2LMFgGdRvgap7Ho8kgon3iWZk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c69a9bffbecde46b4b939465422ddc59493d3e4d",
|
||||
"rev": "63dacb46bf939521bdc93981b4cbb7ecb58427a0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"ref": "24.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
@ -820,9 +786,8 @@
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crate2nix": "crate2nix",
|
||||
"devshell": "devshell_4",
|
||||
"flake-parts": "flake-parts_4",
|
||||
"nixpkgs": "nixpkgs_7",
|
||||
"flake-utils": "flake-utils_6",
|
||||
"nixpkgs": "nixpkgs_6",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
@ -833,17 +798,16 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1725575741,
|
||||
"narHash": "sha256-LaW4WaeNIaju+bo7F7/+TK073JqcuoUvhcxzWp/9OrE=",
|
||||
"lastModified": 1731983527,
|
||||
"narHash": "sha256-JECaBgC0pQ91Hq3W4unH6K9to8s2Zl2sPNu7bLOv4ek=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "6bf986d20552384209907fa0d5f3fa9a34d00995",
|
||||
"rev": "71287228d96e9568e1e70c6bbfa3f992d145947b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "6bf986d20552384209907fa0d5f3fa9a34d00995",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
@ -921,6 +885,21 @@
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_6": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
||||
99
flake.nix
99
flake.nix
@ -2,21 +2,14 @@
|
||||
description = "Rust-Nix";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-parts = {
|
||||
url = "github:hercules-ci/flake-parts";
|
||||
inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||
};
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/24.05";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay/6bf986d20552384209907fa0d5f3fa9a34d00995";
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
crate2nix.url = "github:nix-community/crate2nix";
|
||||
|
||||
# Development
|
||||
|
||||
devshell = {
|
||||
url = "github:numtide/devshell";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
crate2nix = {
|
||||
url = "github:nix-community/crate2nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
@ -28,44 +21,47 @@
|
||||
};
|
||||
|
||||
outputs = inputs @ {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-parts,
|
||||
rust-overlay,
|
||||
crate2nix,
|
||||
flake-utils,
|
||||
nixpkgs,
|
||||
rust-overlay,
|
||||
...
|
||||
}:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
# Overlay pkgs with rust-bin
|
||||
overlays = [(import rust-overlay)];
|
||||
pkgs = import nixpkgs {
|
||||
inherit system overlays;
|
||||
};
|
||||
|
||||
imports = [
|
||||
./nix/rust-overlay/flake-module.nix
|
||||
./nix/devshell/flake-module.nix
|
||||
];
|
||||
# Use rust-bin to generate the toolchain from rust-toolchain.toml
|
||||
rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
|
||||
perSystem = {
|
||||
system,
|
||||
pkgs,
|
||||
lib,
|
||||
inputs',
|
||||
...
|
||||
}: let
|
||||
cargoNix = inputs.crate2nix.tools.${system}.appliedCargoNix {
|
||||
buildRustCrateForPkgs = pkgs:
|
||||
pkgs.buildRustCrate.override {
|
||||
rustc = rust-toolchain; # Use rustc from toolchain
|
||||
cargo = rust-toolchain; # Use cargo from toolchain
|
||||
defaultCrateOverrides =
|
||||
pkgs.defaultCrateOverrides
|
||||
// {
|
||||
# Fix rav1e build.rs:278 error when no CARGO_ENCODED_RUSTFLAGS is set
|
||||
rav1e = attrs: {
|
||||
CARGO_ENCODED_RUSTFLAGS = "";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Cargo.nix for IFD
|
||||
generatedCargoNix = crate2nix.tools.${system}.generatedCargoNix {
|
||||
name = "rustnix";
|
||||
src = ./.;
|
||||
};
|
||||
in rec {
|
||||
checks = {
|
||||
rustnix = cargoNix.rootCrate.build.override {
|
||||
runTests = true;
|
||||
};
|
||||
};
|
||||
|
||||
cargoNix = import generatedCargoNix {
|
||||
inherit pkgs buildRustCrateForPkgs;
|
||||
};
|
||||
in rec {
|
||||
apps = rec {
|
||||
demo = {
|
||||
type = "app";
|
||||
@ -81,18 +77,13 @@
|
||||
};
|
||||
default = demo;
|
||||
};
|
||||
|
||||
packages = {
|
||||
rustnix = cargoNix.rootCrate.build;
|
||||
default = packages.rustnix;
|
||||
|
||||
inherit (pkgs) rust-toolchain;
|
||||
|
||||
rust-toolchain-versions = pkgs.writeScriptBin "rust-toolchain-versions" ''
|
||||
${pkgs.rust-toolchain}/bin/cargo --version
|
||||
${pkgs.rust-toolchain}/bin/rustc --version
|
||||
'';
|
||||
packages = rec {
|
||||
lispers = cargoNix.rootCrate.build;
|
||||
default = lispers;
|
||||
};
|
||||
};
|
||||
};
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = [rust-toolchain];
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
{ inputs, lib, ... }: {
|
||||
imports = [
|
||||
inputs.devshell.flakeModule
|
||||
];
|
||||
|
||||
config.perSystem =
|
||||
{ pkgs
|
||||
, ...
|
||||
}: {
|
||||
config.devshells.default = {
|
||||
imports = [
|
||||
"${inputs.devshell}/extra/language/c.nix"
|
||||
# "${inputs.devshell}/extra/language/rust.nix"
|
||||
];
|
||||
|
||||
commands = with pkgs; [
|
||||
{ package = rust-toolchain; category = "rust"; }
|
||||
];
|
||||
|
||||
language.c = {
|
||||
libraries = lib.optional pkgs.stdenv.isDarwin pkgs.libiconv;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
{ inputs, ... }:
|
||||
let
|
||||
overlays = [
|
||||
(import inputs.rust-overlay)
|
||||
(self: super: assert !(super ? rust-toolchain); rec {
|
||||
rust-toolchain = super.rust-bin.fromRustupToolchainFile ../../rust-toolchain.toml;
|
||||
|
||||
# buildRustCrate/crate2nix depend on this.
|
||||
rustc = rust-toolchain;
|
||||
cargo = rust-toolchain;
|
||||
})
|
||||
];
|
||||
in
|
||||
{
|
||||
perSystem = { system, ... }: {
|
||||
_module.args.pkgs = import inputs.nixpkgs { inherit system overlays; config = { }; };
|
||||
};
|
||||
}
|
||||
@ -1,3 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "stable"
|
||||
channel = "nightly"
|
||||
components = [ "rustfmt", "rustc-dev", "rust-analyzer", "rust-src"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user