File tree 3 files changed +111
-50
lines changed
3 files changed +111
-50
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
description = "rustc dev shell" ;
3
3
4
- inputs = {
5
- nixpkgs . url = "github:NixOS/nixpkgs/nixos-unstable" ;
6
- flake-utils . url = "github:numtide/flake-utils" ;
7
- } ;
4
+ inputs . nixpkgs . url = "github:NixOS/nixpkgs/nixos-unstable" ;
8
5
9
- outputs = { self , nixpkgs , flake-utils , ... } :
10
- flake-utils . lib . eachDefaultSystem ( system :
11
- let
12
- pkgs = import nixpkgs { inherit system ; } ;
13
- x = import ./x { inherit pkgs ; } ;
14
- in
15
- {
16
- devShells . default = with pkgs ; mkShell {
17
- name = "rustc-dev-shell" ;
18
- nativeBuildInputs = with pkgs ; [
19
- binutils cmake ninja pkg-config python3 git curl cacert patchelf nix
20
- ] ;
21
- buildInputs = with pkgs ; [
22
- openssl glibc . out glibc . static x
23
- ] ;
24
- # Avoid creating text files for ICEs.
25
- RUSTC_ICE = "0" ;
26
- # Provide `libstdc++.so.6` for the self-contained lld.
27
- # Provide `libz.so.1`.
28
- LD_LIBRARY_PATH = "${ with pkgs ; lib . makeLibraryPath [ stdenv . cc . cc . lib zlib ] } " ;
29
- } ;
30
- }
31
- ) ;
6
+ outputs =
7
+ {
8
+ self ,
9
+ nixpkgs ,
10
+ } :
11
+ let
12
+ inherit ( nixpkgs ) lib ;
13
+ forEachSystem = lib . genAttrs lib . systems . flakeExposed ;
14
+ in
15
+ {
16
+ devShells = forEachSystem ( system : {
17
+ default = nixpkgs . legacyPackages . ${ system } . callPackage ./shell.nix { } ;
18
+ } ) ;
19
+
20
+ packages = forEachSystem ( system : {
21
+ default = nixpkgs . legacyPackages . ${ system } . callPackage ./x { } ;
22
+ } ) ;
23
+ } ;
32
24
}
Original file line number Diff line number Diff line change 1
- { pkgs ? import <nixpkgs> { } } :
2
- let
3
- x = import ./x { inherit pkgs ; } ;
1
+ {
2
+ pkgs ? import <nixpkgs> { } ,
3
+ } :
4
+ let
5
+ inherit ( pkgs . lib ) lists attrsets ;
6
+
7
+ x = pkgs . callPackage ./x { } ;
8
+ inherit ( x . passthru ) cacert env ;
4
9
in
5
10
pkgs . mkShell {
6
- name = "rustc" ;
7
- nativeBuildInputs = with pkgs ; [
8
- binutils cmake ninja pkg-config python3 git curl cacert patchelf nix
9
- ] ;
10
- buildInputs = with pkgs ; [
11
- openssl glibc . out glibc . static x
12
- ] ;
13
- # Avoid creating text files for ICEs.
14
- RUSTC_ICE = "0" ;
15
- # Provide `libstdc++.so.6` for the self-contained lld.
16
- # Provide `libz.so.1`
17
- LD_LIBRARY_PATH = "${ with pkgs ; lib . makeLibraryPath [ stdenv . cc . cc . lib zlib ] } " ;
11
+ name = "rustc-shell" ;
12
+
13
+ inputsFrom = [ x ] ;
14
+ packages = [
15
+ pkgs . git
16
+ pkgs . nix
17
+ x
18
+ # Get the runtime deps of the x wrapper
19
+ ] ++ lists . flatten ( attrsets . attrValues env ) ;
20
+
21
+ env = {
22
+ # Avoid creating text files for ICEs.
23
+ RUSTC_ICE = 0 ;
24
+ SSL_CERT_FILE = cacert ;
25
+ } ;
18
26
}
Original file line number Diff line number Diff line change 1
1
{
2
- pkgs ? import <nixpkgs> { } ,
2
+ pkgs ,
3
+ lib ,
4
+ stdenv ,
5
+ rustc ,
6
+ python3 ,
7
+ makeBinaryWrapper ,
8
+ # Bootstrap
9
+ curl ,
10
+ pkg-config ,
11
+ libiconv ,
12
+ openssl ,
13
+ patchelf ,
14
+ cacert ,
15
+ zlib ,
16
+ # LLVM Deps
17
+ ninja ,
18
+ cmake ,
19
+ glibc ,
3
20
} :
4
- pkgs . stdenv . mkDerivation {
5
- name = "x" ;
21
+ stdenv . mkDerivation ( self : {
22
+ strictDeps = true ;
23
+ name = "x-none" ;
24
+
25
+ outputs = [
26
+ "out"
27
+ "unwrapped"
28
+ ] ;
6
29
7
30
src = ./x.rs ;
8
31
dontUnpack = true ;
9
32
10
- nativeBuildInputs = with pkgs ; [ rustc ] ;
33
+ nativeBuildInputs = [
34
+ rustc
35
+ makeBinaryWrapper
36
+ ] ;
11
37
38
+ env . PYTHON = python3 . interpreter ;
12
39
buildPhase = ''
13
- PYTHON= ${ pkgs . lib . getExe pkgs . python3 } rustc -Copt-level=3 --crate-name x $src --out-dir $out /bin
40
+ rustc -Copt-level=3 --crate-name x $src --out-dir $unwrapped /bin
14
41
'' ;
15
42
16
- meta = with pkgs . lib ; {
43
+ installPhase =
44
+ let
45
+ inherit ( self . passthru ) cacert env ;
46
+ in
47
+ ''
48
+ makeWrapper $unwrapped/bin/x $out/bin/x \
49
+ --set-default SSL_CERT_FILE ${ cacert } \
50
+ --prefix CPATH ";" "${ lib . makeSearchPath "include" env . cpath } " \
51
+ --prefix PATH : ${ lib . makeBinPath env . path } \
52
+ --prefix LD_LIBRARY_PATH : ${ lib . makeLibraryPath env . ldLib }
53
+ '' ;
54
+
55
+ # For accessing them in the devshell
56
+ passthru = {
57
+ env = {
58
+ cpath = [ libiconv ] ;
59
+ path = [
60
+ python3
61
+ patchelf
62
+ curl
63
+ pkg-config
64
+ cmake
65
+ ninja
66
+ stdenv . cc
67
+ ] ;
68
+ ldLib = [
69
+ openssl
70
+ zlib
71
+ stdenv . cc . cc . lib
72
+ ] ;
73
+ } ;
74
+ cacert = "${ cacert } /etc/ssl/certs/ca-bundle.crt" ;
75
+ } ;
76
+
77
+ meta = {
17
78
description = "Helper for rust-lang/rust x.py" ;
18
79
homepage = "https://github.com/rust-lang/rust/blob/master/src/tools/x" ;
19
- license = licenses . mit ;
80
+ license = lib . licenses . mit ;
20
81
mainProgram = "x" ;
21
82
} ;
22
- }
83
+ } )
You can’t perform that action at this time.
0 commit comments