-
Notifications
You must be signed in to change notification settings - Fork 326
/
Copy pathflake.nix
111 lines (108 loc) · 3.87 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
{
inputs = {
nixpkgs.url = github:nixos/nixpkgs/nixpkgs-unstable;
fenix.url = github:nix-community/fenix;
fenix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, fenix }:
let
forAllSystems = with nixpkgs.lib; f: foldAttrs mergeAttrs { }
(map (s: { ${s} = f s; }) systems.flakeExposed);
in
{
devShell = forAllSystems
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
rust = fenix.packages.${system}.fromToolchainFile {
dir = ./.;
sha256 = "sha256-IeUO263mdpDxBzWTY7upaZqX+ODkuK1JLTHdR3ItlkY=";
};
isOnLinux = pkgs.lib.hasInfix "linux" system;
rust-jni =
if isOnLinux then with fenix.packages.${system}; combine [
minimal.cargo
minimal.rustc
targets.x86_64-unknown-linux-musl.latest.rust-std
] else fenix.packages.${system}.minimal.toolchain;
# https://github.com/NixOS/nixpkgs/blob/618c81f7b15d3e2dd73d9d413d9e7b13fbc9520f/pkgs/development/tools/build-managers/bazel/bazel_7/default.nix#L58
defaultShellUtils = with pkgs; [
bash
coreutils
diffutils
file
findutils
gawk
gnugrep
gnupatch
gnused
gnutar
gzip
python3
unzip
which
zip
makeWrapper
];
# https://github.com/NixOS/nixpkgs/blob/618c81f7b15d3e2dd73d9d413d9e7b13fbc9520f/pkgs/development/tools/build-managers/bazel/bazel_7/default.nix#L257
defaultShellPath = pkgs.lib.makeBinPath defaultShellUtils;
in
pkgs.mkShell rec {
buildInputs = with pkgs; [
# === Bazel ===
(bazel_7.overrideAttrs (self: super: {
patches = super.patches ++ [
(substituteAll {
src = ./nix/patches/bazel_actions_path.patch;
actionsPathPatch = defaultShellPath;
})
];
}))
# === Graal dependencies ===
libxcrypt-legacy
# === Rust dependencies ===
openssl.dev
pkg-config
] ++ (if !isOnLinux then [
# === macOS-specific dependencies ===
darwin.apple_sdk.frameworks.IOKit # Required by `enso-formatter`.
darwin.apple_sdk.frameworks.Security # Required by `enso-formatter`.
] else [ ]);
packages = with pkgs; [
# === TypeScript dependencies ===
nodejs_22
corepack
# === Electron ===
electron
# === node-gyp dependencies ===
python3
gnumake
# === WASM parser dependencies ===
rust
];
shellHook = ''
SHIMS_PATH=$HOME/.local/share/enso/nix-shims
# `sccache` can be used to speed up compile times for Rust crates.
# `~/.cargo/bin/sccache` is provided by `cargo install sccache`.
# `~/.cargo/bin` must be in the `PATH` for the binary to be accessible.
export PATH=$SHIMS_PATH:$HOME/.cargo/bin:$PATH
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath buildInputs}:$LD_LIBRARY_PATH"
# `rustup` shim
mkdir -p $SHIMS_PATH
cat <<END > $SHIMS_PATH/rustup
if [ "\$3" = "x86_64-unknown-linux-musl" ]; then
echo 'Installing Nix Rust shims'
ln -s ${rust-jni.out}/bin/rustc $SHIMS_PATH
ln -s ${rust-jni.out}/bin/cargo $SHIMS_PATH
else
echo 'Uninstalling Nix Rust shims (if installed)'
rm -f $SHIMS_PATH/{rustc,cargo}
fi
END
chmod +x $SHIMS_PATH/rustup
# Uninstall shims if already installed
$SHIMS_PATH/rustup
'';
});
};
}