Skip to content

Commit

Permalink
Add nix derivation for static builds
Browse files Browse the repository at this point in the history
  • Loading branch information
hswong3i committed May 27, 2020
1 parent 27bb67e commit 608621e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ dkms.conf
bin/

vendor/

result
47 changes: 47 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{ system ? builtins.currentSystem }:
let
pkgs = (import ./nixpkgs.nix {
overlays = [ (final: prev: {
pcre = prev.pcre.overrideAttrs (x: {
configureFlags = x.configureFlags ++ [ "--enable-static" ];
});
})];
config = {
packageOverrides = pkg: {
glib = pkg.glib.overrideAttrs(x: {
outputs = [ "bin" "out" "dev" ];
mesonFlags = [
"-Ddefault_library=static"
"-Ddevbindir=${placeholder ''dev''}/bin"
"-Dgtk_doc=false"
"-Dnls=disabled"
];
});
systemd = pkg.systemd.overrideAttrs(x: {
mesonFlags = x.mesonFlags ++ [ "-Dstatic-libsystemd=true" ];
postFixup = ''
${x.postFixup}
sed -ri "s;$out/(.*);$nukedRef/\1;g" $lib/lib/libsystemd.a
'';
});
};
};
});

self = with pkgs; {
conmon-static = conmon.overrideAttrs(x: {
name = "conmon-static";
src = ./..;
buildInputs = [
glib
glibc
glibc.static
pcre
systemd
];
prePatch = ''
export LDFLAGS="-static-libgcc -static"
'';
});
};
in self
7 changes: 7 additions & 0 deletions nix/nixpkgs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let
nixpkgs = import (builtins.fetchTarball {
name = "nixos-unstable";
url = "https://github.com/NixOS/nixpkgs/archive/260b2af29281cfc1e5d2ea7ae8dbb1e38a16e896.tar.gz";
sha256 = "0h70dn8sx60976gycifg5c0dd1pfgclw1vdhazbcniywb1bdsll3";
});
in nixpkgs

0 comments on commit 608621e

Please sign in to comment.