forked from NixOS/nixops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.nix
120 lines (89 loc) · 3.68 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
{ nixopsSrc ? { outPath = ./.; revCount = 0; shortRev = "abcdef"; rev = "HEAD"; }
, officialRelease ? false
}:
let
pkgs = import <nixpkgs> { };
version = "1.3.2" + (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 ];
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; }} doc/manual/machine-options.xml
${pkgs.lib.concatMapStrings (fn: ''
cp ${import ./doc/manual/resource.nix { revision = nixopsSrc.rev; module = ./nix + ("/" + fn + ".nix"); }} doc/manual/${fn}-options.xml
'') [ "ebs-volume" "sqs-queue" "ec2-keypair" "s3-bucket" "iam-role" "ssh-keypair" "ec2-security-group" "elastic-ip"
"gce-disk" "gce-image" "gce-forwarding-rule" "gce-http-health-check" "gce-network"
"gce-static-ip" "gce-target-pool" "gse-bucket" ]}
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; };
pythonPackages.buildPythonPackage rec {
name = "nixops-${version}";
namePrefix = "";
src = "${tarball}/tarballs/*.tar.bz2";
buildInputs = [ pythonPackages.nose pythonPackages.coverage ];
propagatedBuildInputs =
[ pythonPackages.prettytable
pythonPackages.boto
pythonPackages.hetzner
pythonPackages.libcloud
pythonPackages.sqlite3
];
# For "nix-build --run-env".
shellHook = ''
export PYTHONPATH=$(pwd):$PYTHONPATH
export PATH=$(pwd)/scripts:$PATH
'';
doCheck = true;
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
# 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+)
wrapProgram $out/bin/nixops --prefix PATH : "${openssh}/bin"
''; # */
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;
}