forked from NixOS/nixops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.nix
150 lines (117 loc) · 5.04 KB
/
release.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
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
150
{ nixopsSrc ? { outPath = ./.; revCount = 0; shortRev = "abcdef"; rev = "HEAD"; }
, officialRelease ? false
, nixpkgs ? <nixpkgs>
}:
let
pkgs = import nixpkgs { };
version = "1.6.1" + (if officialRelease then "" else "pre${toString nixopsSrc.revCount}_${nixopsSrc.shortRev}");
in
rec {
tarball = pkgs.releaseTools.sourceTarball {
name = "nixops-tarball";
src = nixopsSrc;
inherit version;
officialRelease = true; # hack
buildInputs = [ pkgs.git pkgs.libxslt pkgs.docbook5_xsl ];
nativeBuildInputs = [ pkgs.mypy ];
postUnpack = ''
# Clean up when building from a working tree.
if [ -d $sourceRoot/.git ]; then
(cd $sourceRoot && (git ls-files -o | xargs -r rm -v))
fi
'';
distPhase =
''
# Generate the manual and the man page.
cp ${import ./doc/manual { revision = nixopsSrc.rev; inherit nixpkgs; }} doc/manual/machine-options.xml
# IMPORTANT: when adding a file here, also populate doc/manual/manual.xml
${pkgs.lib.concatMapStrings (fn: ''
cp ${import ./doc/manual/resource.nix { revision = nixopsSrc.rev; module = ./nix + ("/" + fn + ".nix"); inherit nixpkgs; }} doc/manual/${fn}-options.xml
'') [ "ebs-volume" "sns-topic" "sqs-queue" "ec2-keypair" "s3-bucket" "iam-role" "ssh-keypair" "ec2-security-group" "elastic-ip"
"cloudwatch-log-group" "cloudwatch-log-stream" "elastic-file-system" "elastic-file-system-mount-target"
"gce-disk" "gce-image" "gce-forwarding-rule" "gce-http-health-check" "gce-network"
"gce-static-ip" "gce-target-pool" "gse-bucket"
"datadog-monitor" "datadog-timeboard" "datadog-screenboard"
"azure-availability-set" "azure-blob-container" "azure-blob" "azure-directory"
"azure-dns-record-set" "azure-dns-zone" "azure-express-route-circuit"
"azure-file" "azure-gateway-connection" "azure-load-balancer" "azure-local-network-gateway"
"azure-network-security-group" "azure-queue" "azure-reserved-ip-address"
"azure-resource-group" "azure-share" "azure-storage" "azure-table"
"azure-traffic-manager-profile"
"azure-virtual-network" "azure-virtual-network-gateway"]}
for i in scripts/nixops setup.py doc/manual/manual.xml; do
substituteInPlace $i --subst-var-by version ${version}
done
make -C doc/manual install docdir=$out/manual mandir=$TMPDIR/man
releaseName=nixops-$VERSION
mkdir ../$releaseName
cp -prd . ../$releaseName
rm -rf ../$releaseName/.git
mkdir $out/tarballs
tar cvfj $out/tarballs/$releaseName.tar.bz2 -C .. $releaseName
echo "doc manual $out/manual manual.html" >> $out/nix-support/hydra-build-products
'';
};
build = pkgs.lib.genAttrs [ "x86_64-linux" "i686-linux" "x86_64-darwin" ] (system:
with import nixpkgs { inherit system; };
python2Packages.buildPythonApplication rec {
name = "nixops-${version}";
src = "${tarball}/tarballs/*.tar.bz2";
buildInputs = [ python2Packages.nose python2Packages.coverage ];
propagatedBuildInputs = with python2Packages;
[ prettytable
boto
boto3
hetzner
libcloud
libvirt
azure-storage
azure-mgmt-compute
azure-mgmt-network
azure-mgmt-resource
azure-mgmt-storage
adal
# Go back to sqlite once Python 2.7.13 is released
pysqlite
datadog
digital-ocean
typing
];
# For "nix-build --run-env".
shellHook = ''
export PYTHONPATH=$(pwd):$PYTHONPATH
export PATH=$(pwd)/scripts:${openssh}/bin:$PATH
'';
doCheck = true;
postCheck = ''
mypy --cache-dir=/dev/null nixops
'';
# Needed by libcloud during tests
SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
# Add openssh to nixops' PATH. On some platforms, e.g. CentOS and RHEL
# the version of openssh is causing errors when have big networks (40+)
makeWrapperArgs = ["--prefix" "PATH" ":" "${openssh}/bin" "--set" "PYTHONPATH" ":"];
postInstall =
''
# Backward compatibility symlink.
ln -s nixops $out/bin/charon
make -C doc/manual install \
docdir=$out/share/doc/nixops mandir=$out/share/man
mkdir -p $out/share/nix/nixops
cp -av nix/* $out/share/nix/nixops
'';
meta.description = "Nix package for ${stdenv.system}";
});
# This is included here, so it's easier to fetch by the newly installed
# Hetzner machine directly instead of waiting for ages if you have a
# connection with slow upload speed.
hetznerBootstrap = import ./nix/hetzner-bootstrap.nix;
tests.none_backend = (import ./tests/none-backend.nix {
nixops = build.x86_64-linux;
system = "x86_64-linux";
}).test;
tests.hetzner_backend = (import ./tests/hetzner-backend {
nixops = build.x86_64-linux;
system = "x86_64-linux";
}).test;
}