Merge pull request #16 from serokell/balsoft/static-building

[INT-111] Allow to build crossref-verify statically
This commit is contained in:
Alexander Bantyev 2019-12-26 15:56:50 +03:00 committed by GitHub
commit 38bd3b7920
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 5 deletions

View File

@ -4,8 +4,16 @@
steps:
- command: nix-build crossref-verifier.nix
label: build everything
label: Library and tests
- command: nix-build
label: Executable
artifact_paths:
- "result/bin/crossref-verify"
- command: nix run -f. -c crossref-verify
label: crossref-verify itself (import as if done externally)
label: Crossref-verify itself
- command: nix run -f $(nix eval -f nix/sources.nix --raw nixpkgs) reuse -c reuse lint
label: reuse lint
label: REUSE lint
- command:
- GITHUB_TOKEN=$(cat ~/niv-bot-token) NIX_PATH=nixpkgs=$(nix eval --raw '(import ./nix/sources.nix).nixpkgs') nix-shell -p curl git gitAndTools.hub --run "curl https://raw.githubusercontent.com/serokell/scratch/release-binary/scripts/release-binary.sh | bash"
label: Create a pre-release
branches: master

View File

@ -2,10 +2,14 @@
#
# SPDX-License-Identifier: MPL-2.0
{ static ? true }:
let
sources = import ./nix/sources.nix;
nixpkgs = import sources.nixpkgs (import sources."haskell.nix");
hn = nixpkgs.haskell-nix;
hn = if static then
nixpkgs.pkgsCross.musl64.haskell-nix
else
nixpkgs.haskell-nix;
project = hn.stackProject {
src = hn.haskellLib.cleanGit { src = ./.; };
modules = [{
@ -14,6 +18,21 @@ let
postHaddock = ''
[[ -z "$(ls -A dist/doc/html)" ]] && exit 1 || echo "haddock successfully generated documentation"'';
package.ghcOptions = "-Werror";
components.exes.crossref-verify.configureFlags =
with nixpkgs.pkgsStatic;
lib.optionals static [
"--disable-executable-dynamic"
"--disable-shared"
"--ghc-option=-optl=-pthread"
"--ghc-option=-optl=-static"
"--ghc-option=-optl=-lc"
"--ghc-option=-optl=-lz"
"--ghc-option=-optl=-lgmp"
"--ghc-option=-optl=-lffi"
"--ghc-option=-optl=-L${gmp6}/lib"
"--ghc-option=-optl=-L${zlib.static}/lib"
"--ghc-option=-optl=-L${libffi}/lib"
];
};
}];
cache = with sources; [{

View File

@ -2,4 +2,4 @@
#
# SPDX-License-Identifier: MPL-2.0
(import ./crossref-verifier.nix).components.exes.crossref-verify
(import ./crossref-verifier.nix {}).components.exes.crossref-verify

20
release/default.nix Normal file
View File

@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: 2019 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: MPL-2.0
{ pkgs ? import (import ../nix/sources.nix).nixpkgs { } }:
let
executable = (import ../crossref-verifier.nix {
static = true;
}).components.exes.crossref-verify;
joinByBasename = name: paths:
pkgs.runCommandNoCC name { } (''
mkdir $out
'' + pkgs.lib.concatMapStrings (path: ''
ln -s ${path} $out/${builtins.baseNameOf path}
'') paths);
in joinByBasename "crossref-verifier-release" [
"${executable}/bin"
../LICENSES
../README.md
]