Skip to content

Commit bc9fc5d

Browse files
feat: doc .envrc parameters & allow overriding toolchain
Signed-off-by: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com>
1 parent 2f312af commit bc9fc5d

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

.envrc.example

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
use nix # --arg isIdea true --arg nixpkgs '<nixpkgs>'
1+
# isIdea: whether to write the current rust toolchain into `.idea/workspace.xml`, defaults to false
2+
# nixpkgs: the path to a nixpkgs checkout, defaults to a pinned version
3+
# mkToolchain: a function taking a fenix instance and returning a toolchain, defaults to `fenix: fenix.complete`
4+
use nix # \
5+
# --arg isIdea true \
6+
# --arg nixpkgs '<nixpkgs>' \
7+
# --arg mkToolchain 'fenix: fenix.beta'

shell.nix

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
22
nixpkgs ? fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-25.05.tar.gz",
3-
pkgs ? import nixpkgs { },
4-
fenix ?
5-
(import (fetchTarball "https://github.com/nix-community/fenix/archive/monthly.tar.gz") {
6-
inherit pkgs;
7-
}).complete,
3+
fenix-src ? fetchTarball "https://github.com/nix-community/fenix/archive/monthly.tar.gz",
4+
5+
mkToolchain ? fenix: fenix.complete,
86
isIdea ? false,
97
}:
8+
let
9+
pkgs = import nixpkgs { };
10+
fenix = import fenix-src { inherit pkgs; };
11+
toolchain = mkToolchain fenix;
12+
in
1013
pkgs.mkShell rec {
1114
buildInputs = with pkgs; [
1215
nixfmt-rfc-style
@@ -17,11 +20,11 @@ pkgs.mkShell rec {
1720

1821
openssl
1922
pkg-config
20-
fenix.toolchain
23+
toolchain.toolchain
2124
];
2225

2326
RUST_BACKTRACE = 1;
24-
RUST_SRC_PATH = "${fenix.rust-src}/lib/rustlib/src/rust/library";
27+
RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/library";
2528

2629
shellHook =
2730
let
@@ -31,7 +34,7 @@ pkgs.mkShell rec {
3134
pkgs.lib.optionalString isIdea ''
3235
sed -i \
3336
-e "s|$(${xidel} .idea/workspace.xml -e '${pathFor "explicitPathToStdlib"}')|${RUST_SRC_PATH}|" \
34-
-e "s|$(${xidel} .idea/workspace.xml -e '${pathFor "toolchainHomeDirectory"}')|${fenix.toolchain}/bin|" \
37+
-e "s|$(${xidel} .idea/workspace.xml -e '${pathFor "toolchainHomeDirectory"}')|${toolchain.toolchain}/bin|" \
3538
.idea/workspace.xml
3639
'';
3740
}

0 commit comments

Comments
 (0)