-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathshell.nix
104 lines (91 loc) · 2.52 KB
/
shell.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
let
# Mozilla Overlay
moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
nixpkgs = import <nixpkgs> {
overlays = [ moz_overlay ];
config.android_sdk.accept_license = true;
};
frameworks = nixpkgs.darwin.apple_sdk.frameworks;
rust =
(nixpkgs.rustChannelOf {
rustToolchain = ./rust-toolchain;
}).rust.override {
targets = [
"aarch64-linux-android"
"armv7-linux-androideabi"
"x86_64-linux-android"
"i686-linux-android"
] ++ (
nixpkgs.lib.optionals nixpkgs.stdenv.isDarwin [
"aarch64-apple-ios"
"x86_64-apple-ios"
]
);
extensions = [
"clippy-preview"
"rust-src"
"rust-analysis"
];
};
environment.systemPackages = with nixpkgs; [
(neovim.override {
configure = {
customRC = ''
if filereadable($HOME . "/.vimrc")
source ~/.vimrc
endif
'';
packages.nixbundle.start = with vimPlugins; [
nvim-completion-manager
nvim-cm-racer
];
};
})
];
androidComposition = nixpkgs.androidenv.composeAndroidPackages {
platformVersions = [ "28" ];
includeNDK = true;
};
in
with nixpkgs;
stdenv.mkDerivation {
name = "rust-env";
buildInputs = [
rust
androidComposition.androidsdk
neovim
];
nativeBuildInputs = [
clang
llvm
flatbuffers
libiconv
cargo-make
] ++ (
lib.optionals stdenv.isDarwin [
frameworks.Security
frameworks.CoreServices
frameworks.CoreFoundation
frameworks.Foundation
]
);
# ENV Variables
RUST_BACKTRACE = 1;
LIBCLANG_PATH = "${llvmPackages.libclang}/lib";
ANDROID_HOME = androidComposition.androidsdk;
ANDROID_NDK_HOME = "${androidComposition.androidsdk}/libexec/android-sdk/ndk-bundle";
RUST_PATH = "${rust}";
RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust";
# Post Shell Hook
shellHook = ''
echo "Using ${rust.name}"
export PS1="\e[0;32m [$name] \[$txtgrn\]\u@\h\[$txtwht\]:\[$bldpur\]\w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty \[$bldylw\]\$aws_env\[$txtrst\]\\e[m \n$ "
'' + (
if !pkgs.stdenv.isDarwin then
""
else ''
# Cargo wasn't able to find CF during a `cargo test` run on Darwin.
export NIX_LDFLAGS="-F${frameworks.CoreFoundation}/Library/Frameworks -framework CoreFoundation $NIX_LDFLAGS";
''
);
}