-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
149 lines (123 loc) · 4.26 KB
/
flake.nix
File metadata and controls
149 lines (123 loc) · 4.26 KB
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
{
description = "Provides a nix-shell environment for SIG DevOps development";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
# This is the Python version that will be used.
myPython = pkgs.python3;
pythonWithPkgs = myPython.withPackages (pythonPkgs: with pythonPkgs; [
# This list contains tools for Python development.
# You can also add other tools, like black.
#
# Note that even if you add Python packages here like PyTorch or Tensorflow,
# they will be reinstalled when running `pip -r requirements.txt` because
# virtualenv is used below in the shellHook.
ipython
pip
setuptools
virtualenvwrapper
wheel
]);
lib-path = with pkgs; lib.makeLibraryPath [
libffi
openssl
stdenv.cc.cc
# If you want to use CUDA, you should uncomment this line.
# linuxPackages.nvidia_x11
];
in
with pkgs;
{
shell = inSite:
let
features = {
aws = {
defaults = {
aws = {
enabled = false;
profile = "default";
};
};
buildInputs = [
awscli2
ssm-session-manager-plugin
git-remote-codecommit
];
env = {
AWS_PROFILE = "${site.aws.profile}";
};
};
awsSam = {
defaults = {
awsSam = {
enabled = false;
};
};
buildInputs = [
aws-sam-cli
];
};
};
defaults = features.aws.defaults // features.awsSam.defaults;
site = defaults // inSite;
featureExtras.aws = if site.aws.enabled then features.aws.buildInputs else [ ];
featureExtras.awsSam = if site.awsSam.enabled then features.awsSam.buildInputs else [ ];
extras.buildInputs = featureExtras.aws ++ featureExtras.awsSam;
mixin = if site.aws.enabled then features.aws.env else { };
glibcLocaleArchivePath = if pkgs.glibcLocales != null then "${pkgs.glibcLocales}/lib/locale/locale-archive" else "";
in
{
buildInputs = [
# Basics
git
wget
curl
nmap
dnsutils
vim
entr
jq
parallel
unzip
which
just
watchexec
# Make sure nix works within the shell
nixStatic
# other packages needed for compiling python libs
readline
libffi
openssl
glibcLocalesUtf8
# unfortunately needed because of messing with LD_LIBRARY_PATH below
openssh
rsync
# Python
pipenv
pythonWithPkgs
] ++ extras.buildInputs;
shellHook = ''
# Allow the use of wheels.
SOURCE_DATE_EPOCH=$(date +%s)
# Augment the dynamic linker path
export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${lib-path}"
PIP_IGNORE_INSTALLED=1 pipenv sync
. "$(pipenv --venv)/bin/activate"
export PS1="\n\[\033[1;32m\][nix-shell:\w] $AWS_PROFILE \$\[\033[0m\] ";
if [ -n "${glibcLocaleArchivePath}" ]; then
# This is needed to prevent ansible failing due to locale settings.
export LOCALE_ARCHIVE="${glibcLocaleArchivePath}"
[ -z "$LC_ALL" ] && export LC_ALL="en_US.utf8"
[ -z "$LC_LANG" ] && export LC_LANG="en_US.utf8"
fi
echo "Entered ${site.name} development environment."
'';
} // mixin;
}
);
}