|
2 | 2 | inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
3 | 3 | inputs.nixpkgs-mozilla.url = "github:mozilla/nixpkgs-mozilla/master"; |
4 | 4 | outputs = { self, nixpkgs, nixpkgs-mozilla, ... } @ inputs: |
5 | | - { |
| 5 | + rec { |
| 6 | + overlays.fix-rust = self: super: { |
| 7 | + # Work around the nixpkgs-mozilla equivalent of |
| 8 | + # https://github.com/NixOS/nixpkgs/issues/278508 and an |
| 9 | + # incompatibility between nixpkgs-mozilla and makeRustPlatform |
| 10 | + rustChannelOf = args: let |
| 11 | + orig = super.rustChannelOf args; |
| 12 | + patchRustPkg = pkg: (pkg.overrideAttrs (oA: { |
| 13 | + buildCommand = (builtins.replaceStrings |
| 14 | + [ "rustc,rustdoc" ] |
| 15 | + [ "rustc,rustdoc,clippy-driver,cargo-clippy,miri,cargo-miri" ] |
| 16 | + oA.buildCommand) + (let |
| 17 | + wrapperPath = self.path + "/pkgs/build-support/bintools-wrapper/ld-wrapper.sh"; |
| 18 | + baseOut = self.clangStdenv.cc.bintools.out; |
| 19 | + getStdenvAttrs = drv: (drv.overrideAttrs (oA: { |
| 20 | + passthru.origAttrs = oA; |
| 21 | + })).origAttrs; |
| 22 | + baseEnv = (getStdenvAttrs self.clangStdenv.cc.bintools).env; |
| 23 | + baseSubstitutedWrapper = self.replaceVars wrapperPath |
| 24 | + { |
| 25 | + inherit (baseEnv) |
| 26 | + shell coreutils_bin suffixSalt mktemp rm; |
| 27 | + use_response_file_by_default = "0"; |
| 28 | + prog = null; |
| 29 | + out = null; |
| 30 | + }; |
| 31 | + in '' |
| 32 | + # work around a bug in the overlay |
| 33 | + ${oA.postInstall} |
| 34 | +
|
| 35 | + # copy over helper scripts that the wrapper needs |
| 36 | + (cd "${baseOut}"; find . -type f \( -name '*.sh' -or -name '*.bash' \) -print0) | while read -d $'\0' script; do |
| 37 | + mkdir -p "$out/$(dirname "$script")" |
| 38 | + substitute "${baseOut}/$script" "$out/$script" --replace-quiet "${baseOut}" "$out" |
| 39 | + done |
| 40 | +
|
| 41 | + # TODO: Work out how to make this work with cross builds |
| 42 | + ldlld="$out/lib/rustlib/${self.clangStdenv.targetPlatform.config}/bin/gcc-ld/ld.lld"; |
| 43 | + if [ -e "$ldlld" ]; then |
| 44 | + export prog="$(readlink -f "$ldlld")" |
| 45 | + rm "$ldlld" |
| 46 | + substitute ${baseSubstitutedWrapper} "$ldlld" --subst-var "out" --subst-var "prog" |
| 47 | + chmod +x "$ldlld" |
| 48 | + fi |
| 49 | + ''); |
| 50 | + })) // { |
| 51 | + targetPlatforms = [ "x86_64-linux" ]; |
| 52 | + badTargetPlatforms = [ ]; |
| 53 | + }; |
| 54 | + overrideRustPkg = pkg: self.lib.makeOverridable (origArgs: |
| 55 | + patchRustPkg (pkg.override origArgs) |
| 56 | + ) {}; |
| 57 | + in builtins.mapAttrs (_: overrideRustPkg) orig; |
| 58 | + }; |
| 59 | + gcroots = |
| 60 | + let gcrootForShell = pkg: pkg // derivation (pkg.drvAttrs // { |
| 61 | + origArgs = pkg.drvAttrs.args; |
| 62 | + # assume the builder is bash for now (it always is for |
| 63 | + # stdenv, which is the only thing that we will encounter |
| 64 | + # in this flake). |
| 65 | + args = [ "-c" "declare > $out" ]; |
| 66 | + }); |
| 67 | + in { |
| 68 | + shells.default = gcrootForShell devShells.x86_64-linux.default; |
| 69 | + }; |
6 | 70 | devShells.x86_64-linux.default = |
7 | 71 | let pkgs = import nixpkgs { |
8 | 72 | system = "x86_64-linux"; |
9 | | - overlays = [ (import (nixpkgs-mozilla + "/rust-overlay.nix")) ]; |
| 73 | + overlays = [ (import (nixpkgs-mozilla + "/rust-overlay.nix")) overlays.fix-rust ]; |
10 | 74 | }; |
11 | 75 | in with pkgs; let |
12 | | - # Work around the nixpkgs-mozilla equivalent of |
13 | | - # https://github.com/NixOS/nixpkgs/issues/278508 and an |
14 | | - # incompatibility between nixpkgs-mozilla and makeRustPlatform |
15 | | - rustChannelOf = args: let |
16 | | - orig = pkgs.rustChannelOf args; |
17 | | - patchRustPkg = pkg: (pkg.overrideAttrs (oA: { |
18 | | - buildCommand = (builtins.replaceStrings |
19 | | - [ "rustc,rustdoc" ] |
20 | | - [ "rustc,rustdoc,clippy-driver,cargo-clippy,miri,cargo-miri" ] |
21 | | - oA.buildCommand) + (let |
22 | | - wrapperPath = pkgs.path + "/pkgs/build-support/bintools-wrapper/ld-wrapper.sh"; |
23 | | - baseOut = pkgs.clangStdenv.cc.bintools.out; |
24 | | - getStdenvAttrs = drv: (drv.overrideAttrs (oA: { |
25 | | - passthru.origAttrs = oA; |
26 | | - })).origAttrs; |
27 | | - baseEnv = (getStdenvAttrs pkgs.clangStdenv.cc.bintools).env; |
28 | | - baseSubstitutedWrapper = pkgs.replaceVars wrapperPath |
29 | | - { |
30 | | - inherit (baseEnv) |
31 | | - shell coreutils_bin suffixSalt mktemp rm; |
32 | | - use_response_file_by_default = "0"; |
33 | | - prog = null; |
34 | | - out = null; |
35 | | - }; |
36 | | - in '' |
37 | | - # work around a bug in the overlay |
38 | | - ${oA.postInstall} |
39 | | -
|
40 | | - # copy over helper scripts that the wrapper needs |
41 | | - (cd "${baseOut}"; find . -type f \( -name '*.sh' -or -name '*.bash' \) -print0) | while read -d $'\0' script; do |
42 | | - mkdir -p "$out/$(dirname "$script")" |
43 | | - substitute "${baseOut}/$script" "$out/$script" --replace-quiet "${baseOut}" "$out" |
44 | | - done |
45 | | -
|
46 | | - # TODO: Work out how to make this work with cross builds |
47 | | - ldlld="$out/lib/rustlib/${pkgs.clangStdenv.targetPlatform.config}/bin/gcc-ld/ld.lld"; |
48 | | - if [ -e "$ldlld" ]; then |
49 | | - export prog="$(readlink -f "$ldlld")" |
50 | | - rm "$ldlld" |
51 | | - substitute ${baseSubstitutedWrapper} "$ldlld" --subst-var "out" --subst-var "prog" |
52 | | - chmod +x "$ldlld" |
53 | | - fi |
54 | | - ''); |
55 | | - })) // { |
56 | | - targetPlatforms = [ "x86_64-linux" ]; |
57 | | - badTargetPlatforms = [ ]; |
58 | | - }; |
59 | | - overrideRustPkg = pkg: lib.makeOverridable (origArgs: |
60 | | - patchRustPkg (pkg.override origArgs) |
61 | | - ) {}; |
62 | | - in builtins.mapAttrs (_: overrideRustPkg) orig; |
63 | | - |
64 | 76 | customisedRustChannelOf = args: |
65 | 77 | lib.flip builtins.mapAttrs (rustChannelOf args) (_: pkg: pkg.override { |
66 | 78 | targets = [ |
|
246 | 258 | zlib |
247 | 259 | cargo-hyperlight |
248 | 260 | typos |
| 261 | + flatbuffers |
| 262 | + cargo-fuzz |
249 | 263 | ]; |
250 | 264 | buildInputs = [ |
251 | 265 | pango |
|
0 commit comments