about summary refs log tree commit diff
path: root/src/tools/nix-dev-shell
diff options
context:
space:
mode:
authorMaybe Lapkin <waffle.lapkin@gmail.com>2024-09-21 11:44:38 +0200
committerMaybe Lapkin <waffle.lapkin@gmail.com>2024-09-21 11:44:38 +0200
commit002a6b134f910be617722f9d25e0ea8016c2a54e (patch)
treeabc71212b9a7da8dbabc209b00b5d3e9d9ed56d1 /src/tools/nix-dev-shell
parenta31ef1059f5f9e1a08d52ced7f7e171f8ec474a3 (diff)
downloadrust-002a6b134f910be617722f9d25e0ea8016c2a54e.tar.gz
rust-002a6b134f910be617722f9d25e0ea8016c2a54e.zip
Add an option of using nix-shell instead of nix flake
Diffstat (limited to 'src/tools/nix-dev-shell')
-rw-r--r--src/tools/nix-dev-shell/envrc-flake8
-rw-r--r--src/tools/nix-dev-shell/envrc-shell7
-rw-r--r--src/tools/nix-dev-shell/shell.nix19
3 files changed, 34 insertions, 0 deletions
diff --git a/src/tools/nix-dev-shell/envrc-flake b/src/tools/nix-dev-shell/envrc-flake
new file mode 100644
index 00000000000..218d88d8721
--- /dev/null
+++ b/src/tools/nix-dev-shell/envrc-flake
@@ -0,0 +1,8 @@
+# If you want to use this as an .envrc file to create a shell with necessery components 
+# to develop rustc, use the following command in the root of the rusr checkout:
+#	
+# ln -s ./src/tools/nix-dev-shell/envrc-flake ./.envrc && echo .envrc >> .git/info/exclude
+
+if nix flake show path:./src/tools/nix-dev-shell &> /dev/null; then
+  use flake path:./src/tools/nix-dev-shell
+fi
diff --git a/src/tools/nix-dev-shell/envrc-shell b/src/tools/nix-dev-shell/envrc-shell
new file mode 100644
index 00000000000..fb7231a6c30
--- /dev/null
+++ b/src/tools/nix-dev-shell/envrc-shell
@@ -0,0 +1,7 @@
+# If you want to use this as an .envrc file to create a shell with necessery components 
+# to develop rustc, use the following command in the root of the rusr checkout:
+#	
+# ln -s ./src/tools/nix-dev-shell/envrc-shell ./.envrc && echo .envrc >> .git/info/exclude
+
+use nix ./src/tools/nix-dev-shell/shell.nix
+  
diff --git a/src/tools/nix-dev-shell/shell.nix b/src/tools/nix-dev-shell/shell.nix
new file mode 100644
index 00000000000..8a5cbb7c89e
--- /dev/null
+++ b/src/tools/nix-dev-shell/shell.nix
@@ -0,0 +1,19 @@
+{ pkgs ? import <nixpkgs> {} }:
+let 
+  x = import ./x { inherit pkgs; };
+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.
+  LD_LIBRARY_PATH = "${with pkgs; lib.makeLibraryPath [
+    stdenv.cc.cc.lib
+  ]}";
+}