Add build scripts for binary and docker image

This commit is contained in:
Valentin Brandl 2020-02-14 15:53:53 +01:00
parent 7e3ca9c620
commit 94265ba39f
No known key found for this signature in database
GPG Key ID: 30D341DD34118D7D
2 changed files with 52 additions and 0 deletions

28
default.nix Normal file
View File

@ -0,0 +1,28 @@
# { system ? builtins.currentSystem }:
{ sources ? import ./nix/sources.nix
, pkgs ? import sources.nixpkgs { }
, callPackage ? pkgs.callPackage
}:
let
cargoNix = callPackage ./Cargo.nix { };
hoc = cargoNix.rootCrate.build;
buildInputs = [ pkgs.openssl pkgs.cacert ];
# version = hoc.version;
# in hoc.rootCrate.build
in
pkgs.symlinkJoin {
name = hoc.name;
version = hoc.crateVersion;
paths = [ hoc ];
buildInputs = [ pkgs.openssl pkgs.cacert ];
postBuild = ''
rm -rf $out/bin/hoc.d
'';
}

24
docker.nix Normal file
View File

@ -0,0 +1,24 @@
# { system ? builtins.currentSystem }:
let
# pkgs = import <nixpkgs> { inherit system; };
pkgs = import <nixpkgs> { };
callPackage = pkgs.lib.callPackageWith pkgs;
hoc = callPackage ./default.nix { };
dockerImage = pkg:
pkgs.dockerTools.buildImage {
name = "vbrandl/hits-of-code";
tag = hoc.version;
contents = [ pkg ];
config = {
Cmd = [ "/bin/hoc" ];
WorkingDir = "/";
};
};
in dockerImage hoc