Skip to content

Commit

Permalink
nix: Refactor windows release dist
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Sep 29, 2019
1 parent 87bd494 commit 051c1d2
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 34 deletions.
24 changes: 22 additions & 2 deletions nix/jormungandr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,27 @@ let
cargoSha256 = "1kdrx4k6d3jx7d67vnmwp37vflzz9ngl2fnwsjl02vacs4g932cf";
};

windows = rec {
# URL and hash of windows binary release
url = "https://github.com/input-output-hk/jormungandr/releases/download/v${release.version}/jormungandr-v${release.version}-x86_64-pc-windows-msvc.zip";
sha256 = "0dd2b2r50kcwakn61sv7xvf2s1yl586rlk8zch2bpfw9bjqrs0hl";
};

jormungandr-win64 = pkgs.runCommand "jormungandr-win64-${release.version}" {
nativeBuildInputs = [ pkgs.buildPackages.unzip ];
} ''
mkdir -p $out/bin
cd $out/bin
unzip ${pkgs.fetchurl windows}
'';

nonWindows = pkg: if pkgs.stdenv.hostPlatform.isWindows
then jormungandr-win64
else pkg;

in {
jormungandr = iohkLib.rust-packages.pkgs.makeJormungandr release;
jormungandr-cli = iohkLib.rust-packages.pkgs.makeJcli release;
jormungandr = nonWindows (iohkLib.rust-packages.pkgs.makeJormungandr release);
jormungandr-cli = nonWindows (iohkLib.rust-packages.pkgs.makeJcli release);

inherit jormungandr-win64;
}
35 changes: 35 additions & 0 deletions nix/windows-release.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ pkgs
, cardano-wallet-jormungandr
, project
, jpkgs ? import ./jormungandr.nix { inherit pkgs; }
, jormungandr-win64 ? jpkgs.jormungandr-win64
}:

let
testData = ../lib/jormungandr/test/data/jormungandr;
name = "cardano-wallet-jormungandr-${project.version}-win64";
jm-bat = pkgs.writeText "jm.bat" ''
jormungandr.exe --config config.yaml --genesis-block block0.bin --secret secret.yaml
'';
cw-bat = pkgs.writeText "cw.bat" ''
cardano-wallet-jormungandr.exe serve --node-port 8081 --genesis-hash HASH --database c:\\cardano-wallet-jormungandr\\wallet.db
'';
in pkgs.runCommand name {
nativeBuildInputs = [ pkgs.zip pkgs.jq pkgs.gnused project.jormungandr-cli ];
} ''
mkdir -pv jm $out/nix-support
cd jm
cp -v ${cardano-wallet-jormungandr}/bin/* .
cp -v ${jormungandr-win64}/bin/* .
cp -v ${testData}/block0.bin ${testData}/secret.yaml .
cp -v ${jm-bat} jm.bat
hash="$(jcli genesis hash --input block0.bin)"
sed -e "s/HASH/$hash/" ${cw-bat} > cw.bat
sed -e 's/storage:.*/storage: "c:\\\\cardano-wallet-jormungandr\\\\storage"/' \
${testData}/config.yaml > config.yaml
chmod -R +w .
zip -r $out/${name}.zip .
echo "file binary-dist $out/${name}.zip" > $out/nix-support/hydra-build-products
''
36 changes: 4 additions & 32 deletions release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,10 @@ let
]
);

cardano-wallet-jormungandr-win64 = let
jm = pkgs.fetchurl {
url = https://github.com/input-output-hk/jormungandr/releases/download/v0.3.3/jormungandr-v0.3.3-x86_64-pc-windows-msvc.zip;
sha256 = "0psva16vq86gcld701k0fi6kk1ydnm2q3yd2mdgflb0x8zpm2i3g";
};
testData = ./lib/jormungandr/test/data/jormungandr;
name = "cardano-wallet-jormungandr-${project.version}-win64.zip";
jm-bat = pkgs.writeText "jm.bat" ''
jormungandr.exe --config config.yaml --genesis-block block0.bin --secret secret.yaml
'';
cw-bat = pkgs.writeText "cw.bat" ''
cardano-wallet-jormungandr.exe serve --node-port 8081 --genesis-hash HASH --database c:\\cardano-wallet-jormungandr\\wallet.db
'';
in pkgs.runCommand "cardano-wallet-jormungandr-win64" {
buildInputs = [ pkgs.zip pkgs.unzip pkgs.jq pkgs.gnused project.jormungandr-cli ];
} ''
mkdir -pv jm $out/nix-support
cd jm
cp -v ${jobs.x86_64-pc-mingw32.cardano-wallet-jormungandr.x86_64-linux}/bin/* .
unzip ${jm}
cp -v ${testData}/block0.bin ${testData}/secret.yaml .
cp -v ${jm-bat} jm.bat
hash="$(jcli genesis hash --input block0.bin)"
sed -e "s/HASH/$hash/" ${cw-bat} > cw.bat
sed -e 's/storage:.*/storage: "c:\\\\cardano-wallet-jormungandr\\\\storage"/' \
${testData}/config.yaml > config.yaml
chmod -R +w .
zip -r $out/${name} .
echo "file binary-dist $out/${name}" > $out/nix-support/hydra-build-products
'';
cardano-wallet-jormungandr-win64 = import ./nix/windows-release.nix {
inherit pkgs project;
cardano-wallet-jormungandr = jobs.x86_64-pc-mingw32.cardano-wallet-jormungandr.x86_64-linux;
};
}
# Build the shell derivation in Hydra so that all its dependencies
# are cached.
Expand Down

0 comments on commit 051c1d2

Please sign in to comment.