Skip to content

Commit

Permalink
default.nix: link statically.
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Nov 11, 2024
1 parent d797f5f commit b510bae
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
{ nixpkgs ? import <nixpkgs> {} }:
(nixpkgs.pkgs.haskellPackages.callCabal2nix "remarks" ./. {})
# This default.nix produces a statically linked executable with no
# library dependencies.
let pkgs = import <nixpkgs> {};
in pkgs.haskell.lib.overrideCabal
(pkgs.haskell.packages.ghc910.callCabal2nix "remarks" ./. {})
( _drv: {
isLibrary = false;
isExecutable = true;
enableSharedExecutables = false;
enableSharedLibraries = false;
configureFlags = [
"--ghc-option=-split-sections"
"--ghc-option=-optl=-static"
"--ghc-option=-optl=-lbz2"
"--ghc-option=-optl=-lz"
"--ghc-option=-optl=-lelf"
"--ghc-option=-optl=-llzma"
"--ghc-option=-optl=-lzstd"
"--extra-lib-dirs=${pkgs.glibc.static}/lib"
"--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib"
"--extra-lib-dirs=${pkgs.zlib.static}/lib"
"--extra-lib-dirs=${(pkgs.xz.override { enableStatic = true; }).out}/lib"
"--extra-lib-dirs=${(pkgs.zstd.override { enableStatic = true; }).out}/lib"
"--extra-lib-dirs=${(pkgs.bzip2.override { enableStatic = true; }).out}/lib"
"--extra-lib-dirs=${(pkgs.elfutils.overrideAttrs (old: { dontDisableStatic = true; })).out}/lib"
"--extra-lib-dirs=${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib"
];
}
)

0 comments on commit b510bae

Please sign in to comment.