-
Notifications
You must be signed in to change notification settings - Fork 0
/
fhs.nix
182 lines (125 loc) · 5.94 KB
/
fhs.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
let
pkgs = import <nixpkgs> { };
inherit (import ./common/pythonlib.nix {
python = pkgs.python3;
version = "python3.9";
})
mypy mypy_v;
publibs = import ./common/otherlib.nix { inherit pkgs; };
xlibs = import ./common/xorglib.nix { inherit pkgs; };
qtlibs = import ./common/qtlib.nix { inherit pkgs; };
libsforbin = import ./common/bin.nix { inherit pkgs; };
LibsBinPath = with pkgs; lib.makeBinPath libsforbin;
# C#
dotnet-combined = with pkgs.dotnetCorePackages;
combinePackages [ sdk_6_0 sdk_5_0 ];
dotnetRoot = "${dotnet-combined}";
dotnetSdk = "${dotnet-combined}/sdk";
dotnetBinary = "${dotnetRoot}/bin/dotnet";
# packages = [ dotnet-combined ];
buildInputs = [ mypy dotnet-combined ] ++ publibs ++ xlibs ++ qtlibs;
libs = buildInputs;
toollibs = import ./common/devtools.nix { inherit pkgs; };
nativeBuildInputs = toollibs;
ld = with pkgs;
lib.makeLibraryPath
([ stdenv.cc.cc.lib fontconfig.lib ] ++ libs ++ toollibs);
GOROOT = "${pkgs.go.out}/share/go";
CFLAGS = "-I${pkgs.glibc.dev}/include";
hardeningDisable = [
"all"
]; # 为了解决cgo warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
LDFLAGS = "-L${pkgs.glibc}/lib";
LIBCLANG_PATH = with pkgs; lib.makeLibraryPath [ libclang_x.lib ];
HISTFILE = toString ./.history;
RUSTC_VERSION = "nightly"; # stable
# Add libvmi precompiled library to rustc search path
RUSTFLAGS = with pkgs; (builtins.map (a: "-L ${a}/lib") [ libvmi ]);
# Add libvmi, glibc, clang, glib headers to bindgen search path
BINDGEN_EXTRA_CLANG_ARGS = with pkgs;
# Includes with normal include path
(builtins.map (a: ''-I"${a}/include"'') [ libvmi glibc.dev ])
# Includes with special directory paths
++ [
''-I"${libclang_x.lib}/lib/clang/${libclang_x.version}/include"''
''-I"${glib.dev}/include/glib-2.0"''
"-I${glib.out}/lib/glib-2.0/include/"
];
fhs = with pkgs;
buildFHSUserEnv {
name = "fhs";
targetPkgs = pkgs: (buildInputs ++ nativeBuildInputs);
runScript = " bash\n";
profile = ''
export PATH="$HOME/.local/bin":"$HOME/.local/usr/bin":"/ah/prehonor/.npm/bin:/gh/prehonor/gitproject/wasmtime/target/debug:/gh/prehonor/gitproject/vcpkg":$PATH
export PATH=$PATH:/home/prehonor/.roswell/bin # lem 一个 lisp IDE
# export PATH=$PATH:${LibsBinPath} # ocmal环境
export PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH" # haskell环境
export MATLABROOT=/ah/prehonor/Programmers/MATLAB/R2021b
export ANDROID_HOME="/gh/prehonor/Android/Sdk"
export MAVEN_OPTS='-Xms300m -Xmx300m'
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/emulator:$HOME/doom-emacs/bin
export JAVA_CPPFLAGS=-I${jdk}/include/
export JAVA_HOME=${jdk.home}
export ANT_HOME="/ah/prehonor/Programmers/apache-ant-1.10.8"
export CARGO_HOME="$HOME/.cargo/"
export RUSTUP_DIST_SERVER=http://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=http://mirrors.ustc.edu.cn/rust-static/rustup
export RUST_SRC_PATH="$(rustc --print sysroot)/lib/rustlib/src/rust/src"
export PATH=$PATH:"$(rustc --print sysroot)/bin/":"$CARGO_HOME/bin"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${ld}:/home/prehonor/Public/test:${cudaPackages.cudatoolkit}/lib
export LIBCLANG_PATH=${LIBCLANG_PATH}
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/prehonor/.local/usr/lib/pkgconfig
# idea 调试 rust 会下载本地调试插件和lldb调试器 ,需要patchelf
# export LD_LIBRARY_PATH=/home/prehonor/.cache/JetBrains/IntelliJIdea2021.2/intellij-rust/lldb/lib::$LD_LIBRARY_PATH
# autoPatchelf /home/prehonor/.cache/JetBrains/IntelliJIdea2021.2/intellij-rust/lldb/bin
# autoPatchelf /ah/prehonor/.npm
export CUDA_HOME=${cudaPackages.cudatoolkit}
export CUDA_PATH=${cudaPackages.cudatoolkit}
export EXTRA_LDFLAGS="-L/lib -L${linuxPackages.nvidia_x11}/lib"
export EXTRA_CCFLAGS="-I/usr/include"
export PYTHON_LIBRARY=${mypy}/lib
export PYTHON_INCLUDE_DIRS=${mypy}/include/${mypy_v}
export NCCL_ROOT=${cudaPackages.nccl.dev}
export CUDNN_ROOT=${cudaPackages.cudnn}
# export PIP_PREFIX=/home/prehonor/.local/pythonEnvs/pip_packages
# export PYTHONPATH="$PIP_PREFIX/${python.sitePackages}:$PYTHONPATH"
# export PATH="$PIP_PREFIX/bin:$PATH"
# unset SOURCE_DATE_EPOCH
export GOROOT=${GOROOT}
export GOPATH="$HOME/go"
export GOPROXY="https://goproxy.io,direct"
export JULIA_PKG_SERVER=https://mirrors.tuna.tsinghua.edu.cn/julia
export GUROBI_HOME="/gh/prehonor/opt/gurobi810/linux64"
export GRB_LICENSE_FILE="/gh/prehonor/opt/gurobi810/gurobi.lic"
export PATH=$PATH:$GUROBI_HOME/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GUROBI_HOME/lib
export LIBPATH=${ld}
export XDG_DATA_DIRS=$XDG_DATA_DIRS:"${gtk3}/share/gsettings-schemas/${gtk3.name}"
# C#
export PATH="$PATH:/home/prehonor/.dotnet/tools"
export DOTNET_ROOT=${dotnetRoot}
# dotnetBase=${dotnetSdk}/$(${dotnetBinary} --version)
# export MSBuildSdksPath=$dotnetBase/Sdks
# export MSBUILD_EXE_PATH=$dotnetBase/MSBuild.dll
unset http_proxy
unset https_proxy
unset ftp_proxy
unset all_proxy
LIBRARY_PATH=""
for b in ${toString (map lib.getLib libs)}; do
if [[ -d "$b/lib" ]]; then
LIBRARY_PATH="$b/lib''${LIBRARY_PATH:+:}$LIBRARY_PATH"
fi
done
export LIBRARY_PATH
source /home/prehonor/.local/pythonEnvs/spider/bin/activate
eval $(opam env) # 必要的opam环境设置
'';
};
in with pkgs;
stdenv.mkDerivation {
name = "fhsenv";
nativeBuildInputs = [ fhs ];
shellHook = "\n exec fhs\n\n";
}