-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
79 lines (64 loc) · 1.55 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
{ version ? versions/2020-04-05-05f09348.nix
, repo ? "monacoremo/nix"
}:
let
config =
import version;
pinnedPkgs =
builtins.fetchTarball {
url = "https://github.com/nixos/nixpkgs/archive/${config.rev}.tar.gz";
sha256 = config.tarballHash;
};
pkgs =
import pinnedPkgs {};
base =
pkgs.callPackage ./base.nix { inherit pinnedPkgs; };
tag =
"${config.date}-${builtins.substring 0 8 config.rev}";
build =
pkgs.writeShellScriptBin "nix-docker-build"
''
set -e
echo "Importing base image..."
docker load < ${base}
docker tag nix-docker-base ${repo}:${tag}
echo "Building variants..."
for variant in $(ls variants); do
docker build -t "${repo}:${tag}-$variant" "variants/$variant"
done
'';
push =
pkgs.writeShellScriptBin "nix-docker-push"
''
docker push ${repo}:${tag}
for variant in $(ls variants); do
docker push "${repo}:${tag}-$variant"
done
'';
clean =
pkgs.writeShellScriptBin "nix-docker-clean"
''
docker rmi nix-docker-base
for variant in $(ls variants); do
docker rmi "${repo}:${tag}-$variant"
done
'';
all =
pkgs.writeShellScriptBin "nix-docker-all"
''
${build}/bin/nix-docker-build
${push}/bin/nix-docker-push
${clean}/bin/nix-docker-clean
'';
in
pkgs.stdenv.mkDerivation {
name = "nix-docker";
buildInputs = [
pkgs.jq
pkgs.curl
all
build
push
clean
];
}