-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathci.nix
60 lines (54 loc) · 1.68 KB
/
ci.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
{ src ? { rev = null; }, labels ? {}, releaseVersion ? "latest" }:
let
nixpkgs = import ./nix { };
inject-rev = drv: drv.overrideAttrs (attrs: { rev = src.rev; });
linux = import ./default.nix { system = "x86_64-linux"; };
darwin = import ./default.nix { system = "x86_64-darwin"; };
as_tarball = dir: derivations:
nixpkgs.runCommandNoCC "motoko-${releaseVersion}.tar.gz" {
allowedRequisites = [];
meta = {
path = "${dir}/motoko-${releaseVersion}.tar.gz";
content-type = "application/gzip";
};
} ''
tmp=$(mktemp -d)
${nixpkgs.lib.concatMapStringsSep "\n" (d: "cp -v ${d}/bin/* $tmp") derivations}
chmod 0755 $tmp/*
tar -czf "$out" -C $tmp/ .
'';
as_js = name: derivation:
nixpkgs.runCommandNoCC "${name}-${releaseVersion}.js" {
allowedRequisites = [];
meta = {
path = "js/${name}-${releaseVersion}.js";
content-type = "application/javascript";
};
} ''
cp -v ${derivation}/bin/* $out
'';
release = import ./nix/publish.nix
{ pkgs = nixpkgs;
inherit releaseVersion;
derivations = [
(as_tarball "x86_64-linux" (with linux; [ mo-ide mo-doc moc ]))
(as_tarball "x86_64-darwin"(with darwin; [ mo-ide mo-doc moc ]))
(as_js "moc" linux.js.moc)
(as_js "moc-interpreter" linux.js.moc_interpreter)
];
};
all-systems-go =
nixpkgs.releaseTools.aggregate {
name = "all-systems-go";
constituents = [
release.motoko
linux.all-systems-go
darwin.all-systems-go
];
};
in
linux // {
inherit release;
darwin = darwin.all-systems-go;
all-systems-go = inject-rev all-systems-go;
}