-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdefault.nix
57 lines (52 loc) · 2.05 KB
/
default.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
argsOuter@{...}:
let
# specifying args defaults in this slightly non-standard way to allow us to include the default values in `args`
args = rec {
pkgs = import <nixpkgs> {};
pythonPackages = pkgs.python36Packages;
forDev = true;
localOverridesPath = ./local.nix;
withLocalES = true;
} // argsOuter;
in (with args; {
digitalMarketplaceApiEnv = (pkgs.stdenv.mkDerivation rec {
name = "digitalmarketplace-search-api-env";
shortName = "dm-search-api";
buildInputs = [
pythonPackages.python
pkgs.glibcLocales
pkgs.libffi
pkgs.libyaml
# pip requires git to fetch some of its dependencies
pkgs.git
# for `cryptography`
pkgs.openssl
pkgs.cacert
] ++ pkgs.stdenv.lib.optionals forDev [
# exotic things possibly go here
] ++ pkgs.stdenv.lib.optionals withLocalES [
((import ./es.nix) (with pkgs; {
inherit stdenv makeWrapper writeScript;
elasticsearch = elasticsearch6-oss;
homePath = (toString (./.)) + "/local_es_home";
}))
];
hardeningDisable = pkgs.stdenv.lib.optionals pkgs.stdenv.isDarwin [ "format" ];
GIT_SSL_CAINFO="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
VIRTUALENV_ROOT = (toString (./.)) + "/venv${pythonPackages.python.pythonVersion}";
VIRTUAL_ENV_DISABLE_PROMPT = "1";
SOURCE_DATE_EPOCH = "315532800";
# if we don't have this, we get unicode troubles in a --pure nix-shell
LANG="en_GB.UTF-8";
shellHook = ''
export PS1="\[\e[0;36m\](nix-shell\[\e[0m\]:\[\e[0;36m\]${shortName})\[\e[0;32m\]\u@\h\[\e[0m\]:\[\e[0m\]\[\e[0;36m\]\w\[\e[0m\]\$ "
if [ ! -e $VIRTUALENV_ROOT ]; then
${pythonPackages.python}/bin/python -m venv $VIRTUALENV_ROOT
fi
source $VIRTUALENV_ROOT/bin/activate
make -C ${toString (./.)} requirements${pkgs.stdenv.lib.optionalString forDev "-dev"}
'' + pkgs.stdenv.lib.optionalString withLocalES ''
init-local-es-home
'';
}).overrideAttrs (if builtins.pathExists localOverridesPath then (import localOverridesPath args) else (x: x));
})