forked from DBCDK/morph
-
Notifications
You must be signed in to change notification settings - Fork 1
/
shell.nix
62 lines (52 loc) · 1.41 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
{ pkgs ? (import <nixpkgs> {}) }:
with pkgs;
let
dep2nix = callPackage ./nix-packaging/dep2nix {};
packagingOut = "./nix-packaging";
shellHook = ''
if [[ -f ./result-bin/bin/morph ]]; then
if [[ `${which} morph 2>&1 >/dev/null` ]]; then
export PATH=$PATH:$(pwd)/result-bin/bin
fi
source <(morph --completion-script-bash)
fi
'';
makeEnv = writeScriptBin "make-env" (''
#!${bashInteractive}/bin/bash
'' + shellHook);
makeDeps = writeShellScriptBin "make-deps" ''
set -e
# Populate /vendor-dir (for convenience in local dev)
if [ "$1" == "update" ]; then
${dep}/bin/dep ensure -v -update
else
${dep}/bin/dep ensure -v -vendor-only
fi
# Write /nix-packaging/deps.nix (for use in distribution)
outpath=$(readlink -f ${packagingOut})
outpath="$outpath/deps.nix"
${dep2nix}/bin/dep2nix -i Gopkg.lock -o $outpath
'';
makeBuild = writeShellScriptBin "make-build" ''
set -e
outpath="$(readlink -f ${packagingOut})/deps.nix"
${nix}/bin/nix-build -E 'with import <nixpkgs> {};
callPackage ./nix-packaging/default.nix {}' -A bin $@
make-env
'';
in
# Change to mkShell once that hits stable!
stdenv.mkDerivation {
name = "morph-build-env";
buildInputs = [
bashInteractive
git
makeEnv
makeDeps
makeBuild
nix
nix-prefetch-git
openssh
];
inherit shellHook;
}