diff --git a/.gitignore b/.gitignore index fd6bdeef..2d25cb52 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,5 @@ dkms.conf bin/ vendor/ + +result diff --git a/Makefile b/Makefile index a0abaec0..955d5573 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,10 @@ containerized: bin static: $(MAKE) git-vars bin/conmon PKG_CONFIG='$(PKG_CONFIG) --static' CFLAGS='-static' LDFLAGS='$(LDFLAGS) -s -w -static' LIBS='$(LIBS)' +nixpkgs: + @nix run -f channel:nixpkgs-unstable nix-prefetch-git -c nix-prefetch-git \ + --no-deepClone https://github.com/nixos/nixpkgs > nix/nixpkgs.json + bin/conmon: $(OBJS) | bin $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBS) diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 00000000..346ba5b0 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,48 @@ +{ 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 = ./..; + doCheck = false; + buildInputs = [ + glib + glibc + glibc.static + pcre + systemd + ]; + prePatch = '' + export LDFLAGS="-static-libgcc -static" + ''; + })); + }; +in self diff --git a/nix/nixpkgs.json b/nix/nixpkgs.json new file mode 100644 index 00000000..84df2d61 --- /dev/null +++ b/nix/nixpkgs.json @@ -0,0 +1,10 @@ +{ + "url": "https://github.com/nixos/nixpkgs", + "rev": "1b5925f2189dc9b4ebf7168252bf89a94b7405ba", + "date": "2020-05-27T15:03:28+02:00", + "path": "/nix/store/qdsrj7hw9wzzng9l2kfbsyi9ynprrn6p-nixpkgs", + "sha256": "0q9plknr294k4bjfqvgvp5vglfby5yn64k6ml0gqwi0dwf0qi6fv", + "fetchSubmodules": false, + "deepClone": false, + "leaveDotGit": false +} diff --git a/nix/nixpkgs.nix b/nix/nixpkgs.nix new file mode 100644 index 00000000..21e7f17a --- /dev/null +++ b/nix/nixpkgs.nix @@ -0,0 +1,8 @@ +let + json = builtins.fromJSON (builtins.readFile ./nixpkgs.json); + nixpkgs = import (builtins.fetchTarball { + name = "nixos-unstable"; + url = "${json.url}/archive/${json.rev}.tar.gz"; + inherit (json) sha256; + }); +in nixpkgs