Skip to content

Commit

Permalink
Slightly more documented and better musl building code (#59)
Browse files Browse the repository at this point in the history
* Slightly more documented and better musl building code

* Disabling "codd musl build", since it was always a glibc dyn-linked exe

* Fixing codd.cabal after module removal
  • Loading branch information
mzabani authored Sep 6, 2021
1 parent 4a6a885 commit a3aacb1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 48 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ jobs:
- name: Build codd's library's haddocks
run: nix-build --no-out-link -A codd.components.library.doc

- name: Build codd with musl libc
run: nix-build --no-out-link nix/codd-exe-musl.nix
# It's not possible to build docker images on github CI due to lack of nested virtualization
# run: nix-build --no-out-link nix/docker/codd-exe.nix

Expand Down
3 changes: 1 addition & 2 deletions codd.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 2.0
--
-- see: https://github.com/sol/hpack
--
-- hash: abcbb0b655fed71c0a4198c34fba34ffd6bbd283d1db8b5ace08fd9630f50019
-- hash: 666e26d0254071572cb71f6cd82876a39e283bc5f783c8b5579f4ee3f9237e0e

name: codd
version: 0.1.0.0
Expand All @@ -31,7 +31,6 @@ library
Codd.Analysis
Codd.AppCommands
Codd.AppCommands.AddMigration
Codd.AppCommands.CheckMigration
Codd.AppCommands.VerifyChecksums
Codd.AppCommands.WriteChecksums
Codd.Environment
Expand Down
38 changes: 21 additions & 17 deletions nix/codd-exe-musl.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
let
pkgs = import ./nixpkgsMusl.nix;
stdenv = pkgs.stdenv;
zlib = pkgs.zlib;
gmp6 = pkgs.gmp6;
projectPkgs = import ../default.nix { inherit pkgs; };
pkgs = import ./nixpkgs.nix;
muslPkgs = import ../default.nix { pkgs = pkgs.pkgsCross.musl64; };
glibcPkgs = import ../default.nix { inherit pkgs; };
in
# The static build thing, which can be read about at https://input-output-hk.github.io/haskell.nix/tutorials/cross-compilation/#static-executables-with-musl-libc
# is not working
projectPkgs.codd.components.exes.codd.overrideAttrs (oldAttrs: {
configureFlags = [
"--disable-executable-dynamic"
"--disable-shared"
"--ghc-option=-optl=-pthread"
"--ghc-option=-optl=-static"
"--ghc-option=-optl=-L${gmp6.override { withStatic = true; }}/lib"
"--ghc-option=-optl=-L${zlib.static}/lib"
];
})
{
# Sadly postgresql doesn't build with musl yet
# See https://github.com/input-output-hk/haskell.nix/issues/782
codd-musl = muslPkgs.codd.components.exes.codd.overrideAttrs (oldAttrs: {
configureFlags = [
"--disable-executable-dynamic"
"--disable-shared"
"--ghc-option=-optl=-pthread"
"--ghc-option=-optl=-static"

# The two below don't use musl gmp6 and zlib. Is this right?
"--ghc-option=-optl=-L${pkgs.gmp6.override { withStatic = true; }}/lib"
"--ghc-option=-optl=-L${pkgs.zlib.static}/lib"
];
});

codd-glibc = glibcPkgs.codd.components.exes.codd;
}
6 changes: 4 additions & 2 deletions nix/docker/codd-exe.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
let
pkgs = import ../nixpkgsMusl.nix;
codd-exe = import ../codd-exe-musl.nix;
pkgs = import ../nixpkgs.nix;

# postgresql-lib does not build with musl yet
codd-exe = (import ../codd-exe-musl.nix).codd-glibc;

useradd = "${pkgs.shadow}/bin/useradd";
groupadd = "${pkgs.shadow}/bin/groupadd";
Expand Down
25 changes: 0 additions & 25 deletions nix/nixpkgsMusl.nix

This file was deleted.

0 comments on commit a3aacb1

Please sign in to comment.