mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 05:26:47 +00:00
Deduplicate nix code
And clean it up a little.
This commit is contained in:
parent
ae9173d7dd
commit
4dae758f7f
@ -1,32 +1,24 @@
|
||||
{
|
||||
description = "rustc dev shell";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
x = import ./x { inherit pkgs; };
|
||||
in
|
||||
{
|
||||
devShells.default = with pkgs; mkShell {
|
||||
name = "rustc-dev-shell";
|
||||
nativeBuildInputs = with pkgs; [
|
||||
binutils cmake ninja pkg-config python3 git curl cacert patchelf nix
|
||||
];
|
||||
buildInputs = with pkgs; [
|
||||
openssl glibc.out glibc.static x
|
||||
];
|
||||
# Avoid creating text files for ICEs.
|
||||
RUSTC_ICE = "0";
|
||||
# Provide `libstdc++.so.6` for the self-contained lld.
|
||||
# Provide `libz.so.1`.
|
||||
LD_LIBRARY_PATH = "${with pkgs; lib.makeLibraryPath [stdenv.cc.cc.lib zlib]}";
|
||||
};
|
||||
}
|
||||
);
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
}:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
forEachSystem = lib.genAttrs lib.systems.flakeExposed;
|
||||
in
|
||||
{
|
||||
devShells = forEachSystem (system: {
|
||||
default = nixpkgs.legacyPackages.${system}.callPackage ./shell.nix { };
|
||||
});
|
||||
|
||||
packages = forEachSystem (system: {
|
||||
default = nixpkgs.legacyPackages.${system}.callPackage ./x { };
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -1,18 +1,27 @@
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
let
|
||||
x = import ./x { inherit pkgs; };
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
let
|
||||
inherit (pkgs.lib) lists attrsets;
|
||||
|
||||
x = pkgs.callPackage ./x { };
|
||||
inherit (x.passthru) cacert env;
|
||||
in
|
||||
pkgs.mkShell {
|
||||
name = "rustc";
|
||||
nativeBuildInputs = with pkgs; [
|
||||
binutils cmake ninja pkg-config python3 git curl cacert patchelf nix
|
||||
];
|
||||
buildInputs = with pkgs; [
|
||||
openssl glibc.out glibc.static x
|
||||
];
|
||||
# Avoid creating text files for ICEs.
|
||||
RUSTC_ICE = "0";
|
||||
# Provide `libstdc++.so.6` for the self-contained lld.
|
||||
# Provide `libz.so.1`
|
||||
LD_LIBRARY_PATH = "${with pkgs; lib.makeLibraryPath [stdenv.cc.cc.lib zlib]}";
|
||||
name = "rustc-shell";
|
||||
|
||||
inputsFrom = [ x ];
|
||||
packages = [
|
||||
pkgs.git
|
||||
pkgs.nix
|
||||
pkgs.glibc
|
||||
x
|
||||
# Get the runtime deps of the x wrapper
|
||||
] ++ lists.flatten (attrsets.attrValues env);
|
||||
|
||||
env = {
|
||||
# Avoid creating text files for ICEs.
|
||||
RUSTC_ICE = 0;
|
||||
SSL_CERT_FILE = cacert;
|
||||
};
|
||||
}
|
||||
|
@ -1,22 +1,83 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
pkgs,
|
||||
lib,
|
||||
stdenv,
|
||||
rustc,
|
||||
python3,
|
||||
makeBinaryWrapper,
|
||||
# Bootstrap
|
||||
curl,
|
||||
pkg-config,
|
||||
libiconv,
|
||||
openssl,
|
||||
patchelf,
|
||||
cacert,
|
||||
zlib,
|
||||
# LLVM Deps
|
||||
ninja,
|
||||
cmake,
|
||||
glibc,
|
||||
}:
|
||||
pkgs.stdenv.mkDerivation {
|
||||
name = "x";
|
||||
stdenv.mkDerivation (self: {
|
||||
strictDeps = true;
|
||||
name = "x-none";
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"unwrapped"
|
||||
];
|
||||
|
||||
src = ./x.rs;
|
||||
dontUnpack = true;
|
||||
|
||||
nativeBuildInputs = with pkgs; [ rustc ];
|
||||
nativeBuildInputs = [
|
||||
rustc
|
||||
makeBinaryWrapper
|
||||
];
|
||||
|
||||
env.PYTHON = python3.interpreter;
|
||||
buildPhase = ''
|
||||
PYTHON=${pkgs.lib.getExe pkgs.python3} rustc -Copt-level=3 --crate-name x $src --out-dir $out/bin
|
||||
rustc -Copt-level=3 --crate-name x $src --out-dir $unwrapped/bin
|
||||
'';
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
installPhase =
|
||||
let
|
||||
inherit (self.passthru) cacert env;
|
||||
in
|
||||
''
|
||||
makeWrapper $unwrapped/bin/x $out/bin/x \
|
||||
--set-default SSL_CERT_FILE ${cacert} \
|
||||
--prefix CPATH ";" "${lib.makeSearchPath "include" env.cpath}" \
|
||||
--prefix PATH : ${lib.makeBinPath env.path} \
|
||||
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath env.ldLib}
|
||||
'';
|
||||
|
||||
# For accessing them in the devshell
|
||||
passthru = {
|
||||
env = {
|
||||
cpath = [ libiconv ];
|
||||
path = [
|
||||
python3
|
||||
patchelf
|
||||
curl
|
||||
pkg-config
|
||||
cmake
|
||||
ninja
|
||||
];
|
||||
ldLib = [
|
||||
openssl
|
||||
glibc.static
|
||||
zlib
|
||||
stdenv.cc.cc.lib
|
||||
];
|
||||
};
|
||||
cacert = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Helper for rust-lang/rust x.py";
|
||||
homepage = "https://github.com/rust-lang/rust/blob/master/src/tools/x";
|
||||
license = licenses.mit;
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "x";
|
||||
};
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user