1
0
Fork 0

altering flake.nix WIP

This commit is contained in:
Simon Renblad 2024-07-23 16:02:00 +08:00
parent b2b3e5c933
commit 91607ea8e8
2 changed files with 67 additions and 49 deletions

View File

@ -1,28 +1,12 @@
{ {
"nodes": { "nodes": {
"mozilla-overlay": {
"flake": false,
"locked": {
"lastModified": 1704373101,
"narHash": "sha256-+gi59LRWRQmwROrmE1E2b3mtocwueCQqZ60CwLG+gbg=",
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"rev": "9b11a87c0cc54e308fa83aac5b4ee1816d5418a2",
"type": "github"
},
"original": {
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1720386169, "lastModified": 1721548954,
"narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", "narHash": "sha256-7cCC8+Tdq1+3OPyc3+gVo9dzUNkNIQfwSDJ2HSi2u3o=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "194846768975b7ad2c4988bdb82572c00222c0d7", "rev": "63d37ccd2d178d54e7fb691d7ec76000740ea24a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -34,8 +18,28 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"mozilla-overlay": "mozilla-overlay", "nixpkgs": "nixpkgs",
"nixpkgs": "nixpkgs" "rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1721701191,
"narHash": "sha256-nM4szL90VeZHZEC5rFfaiiPNTVOmsihdtk2QSP1l37I=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "4674ff2c2e5423a0cebe16e61aa874c359306af4",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
} }
} }
}, },

View File

@ -2,37 +2,47 @@
description = "Bare-metal Rust on Zynq-7000"; description = "Bare-metal Rust on Zynq-7000";
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-24.05; inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-24.05;
inputs.mozilla-overlay = { url = github:mozilla/nixpkgs-mozilla; flake = false; }; #inputs.mozilla-overlay = { url = github:mozilla/nixpkgs-mozilla; flake = false; };
inputs.rust-overlay = {
outputs = { self, nixpkgs, mozilla-overlay }: url = "github:oxalica/rust-overlay";
let inputs.nixpkgs.follows = "nixpkgs";
pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) crosspkgs-overlay ]; };
rustManifest = pkgs.fetchurl {
url = "https://static.rust-lang.org/dist/2021-01-29/channel-rust-nightly.toml";
sha256 = "sha256-EZKgw89AH4vxaJpUHmIMzMW/80wAFQlfcxRoBD9nz0c=";
}; };
rustTargets = [];
rustChannelOfTargets = _channel: _date: targets: outputs = { self, nixpkgs, rust-overlay }:
(pkgs.lib.rustLib.fromManifestFile rustManifest { let
inherit (pkgs) stdenv lib fetchurl patchelf; pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import rust-overlay) crosspkgs-overlay ]; };
}).rust.override {
inherit targets; # rustManifest = pkgs.fetchurl {
# url = "https://static.rust-lang.org/dist/2021-01-29/channel-rust-nightly.toml";
# sha256 = "sha256-EZKgw89AH4vxaJpUHmIMzMW/80wAFQlfcxRoBD9nz0c=";
# };
# rustTargets = [];
# rustChannelOfTargets = _channel: _date: targets:
# (pkgs.lib.rustLib.fromManifestFile rustManifest {
# inherit (pkgs) stdenv lib fetchurl patchelf;
# }).rust.override {
# inherit targets;
# extensions = ["rust-src"];
# };
# rust = rustChannelOfTargets "nightly" null rustTargets;
# rustc version needs to match LLVM version, else ABI bugs
# https://doc.rust-lang.org/rustc/linker-plugin-lto.html#toolchain-compatibility
rust = pkgs.rust-bin.nightly."2023-04-20".default.override {
extensions = [ "rust-src" ]; extensions = [ "rust-src" ];
}; };
rust = rustChannelOfTargets "nightly" null rustTargets;
rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform { rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform {
rustc = rust; rustc = rust;
cargo = rust; cargo = rust;
}); });
# https://doc.rust-lang.org/rustc/linker-plugin-lto.html#toolchain-compatibility ## https://doc.rust-lang.org/rustc/linker-plugin-lto.html#toolchain-compatibility
llvmPackages_11 = pkgs.recurseIntoAttrs (pkgs.callPackage (import ./llvm/11) ({ #llvmPackages_11 = pkgs.recurseIntoAttrs (pkgs.callPackage (import ./llvm/11) ({
inherit (pkgs.stdenvAdapters) overrideCC; # inherit (pkgs.stdenvAdapters) overrideCC;
buildLlvmTools = null; # buildLlvmTools = null;
targetLlvmLibraries = null; # targetLlvmLibraries = null;
targetLlvm = null; # targetLlvm = null;
})); #}));
crosspkgs-overlay = (self: super: { crosspkgs-overlay = (self: super: {
pkgsCross = super.pkgsCross // { pkgsCross = super.pkgsCross // {
@ -104,9 +114,13 @@
dontFixup = true; dontFixup = true;
}; };
cargo-xbuild = pkgs.cargo-xbuild.overrideAttrs(oa: { cargo-xbuild = pkgs.cargo-xbuild;
postPatch = "substituteInPlace src/sysroot.rs --replace 2021 2018"; #cargo-xbuild = pkgs.cargo-xbuild.overrideAttrs(oa: {
}); # postPatch = "substituteInPlace src/sysroot.rs --replace 2021 2018";
#});
#cargo-xbuild = pkgs.cargo-xbuild.overrideAttrs(oa: {
# postPatch = "substituteInPlace src/sysroot.rs --replace 2023 2018";
#});
build-crate = name: crate: features: rustPlatform.buildRustPackage rec { build-crate = name: crate: features: rustPlatform.buildRustPackage rec {
name = "${crate}"; name = "${crate}";
@ -116,7 +130,7 @@
) ./.; ) ./.;
cargoLock = { lockFile = ./Cargo.lock; }; cargoLock = { lockFile = ./Cargo.lock; };
nativeBuildInputs = [ cargo-xbuild llvmPackages_11.clang-unwrapped ]; nativeBuildInputs = [ cargo-xbuild pkgs.llvmPackages_16.clang-unwrapped ];
buildPhase = '' buildPhase = ''
export XARGO_RUST_SRC="${rust}/lib/rustlib/src/rust/library" export XARGO_RUST_SRC="${rust}/lib/rustlib/src/rust/library"
export CARGO_HOME=$(mktemp -d cargo-home.XXX) export CARGO_HOME=$(mktemp -d cargo-home.XXX)
@ -161,7 +175,7 @@
hydraJobs = packages.x86_64-linux; hydraJobs = packages.x86_64-linux;
inherit rust rustPlatform llvmPackages_11; inherit rust rustPlatform;
devShell.x86_64-linux = pkgs.mkShell { devShell.x86_64-linux = pkgs.mkShell {
name = "zynq-rs-dev-shell"; name = "zynq-rs-dev-shell";
@ -172,7 +186,7 @@
pkgs.openocd pkgs.gdb pkgs.openocd pkgs.gdb
pkgs.openssh pkgs.rsync pkgs.openssh pkgs.rsync
llvmPackages_11.clang-unwrapped pkgs.llvmPackages_16.clang-unwrapped
(pkgs.python3.withPackages(ps: [ ps.pyftdi ])) (pkgs.python3.withPackages(ps: [ ps.pyftdi ]))
]; ];
}; };