Skip to content

Commit d79ffe2

Browse files
committed
[nix] update, refactor, add dependencies
Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
1 parent 7f45acc commit d79ffe2

File tree

2 files changed

+74
-60
lines changed

2 files changed

+74
-60
lines changed

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 68 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,77 @@
22
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
33
inputs.nixpkgs-mozilla.url = "github:mozilla/nixpkgs-mozilla/master";
44
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+
};
670
devShells.x86_64-linux.default =
771
let pkgs = import nixpkgs {
872
system = "x86_64-linux";
9-
overlays = [ (import (nixpkgs-mozilla + "/rust-overlay.nix")) ];
73+
overlays = [ (import (nixpkgs-mozilla + "/rust-overlay.nix")) overlays.fix-rust ];
1074
};
1175
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-
6476
customisedRustChannelOf = args:
6577
lib.flip builtins.mapAttrs (rustChannelOf args) (_: pkg: pkg.override {
6678
targets = [
@@ -246,6 +258,8 @@
246258
zlib
247259
cargo-hyperlight
248260
typos
261+
flatbuffers
262+
cargo-fuzz
249263
];
250264
buildInputs = [
251265
pango

0 commit comments

Comments
 (0)