diff --git a/.gitignore b/.gitignore index ee12b0ab..3a650651 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ src/*.obj src/msmtp src/msmtp.exe stamp-h1 +result diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 00000000..959590bc --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,29 @@ +{ system ? builtins.currentSystem }: +let + pkgs = (import ./nixpkgs.nix {}).pkgsStatic; + + self = with pkgs; stdenv.mkDerivation rec { + name = "msmtmp"; + src = ./..; + doCheck = false; + enableParallelBuilding = true; + nativeBuildInputs = [ autoreconfHook gettext pkg-config texinfo ]; + buildInputs = [ openssl ]; + configureFlags = [ + "--prefix=/usr" + "--sysconfdir=/etc" + "--mandir=/usr/share/man" + "--localstatedir=/var" + "--with-tls=openssl" + "--with-msmtpd" + ]; + prePatch = '' + export LDFLAGS='-static -s -w' + export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"' + ''; + installPhase = '' + install -Dm755 src/msmtp $out/bin/msmtp + install -Dm755 src/msmtpd $out/bin/msmtpd + ''; + }; +in self diff --git a/nix/nixpkgs.json b/nix/nixpkgs.json new file mode 100644 index 00000000..f1798551 --- /dev/null +++ b/nix/nixpkgs.json @@ -0,0 +1,10 @@ +{ + "url": "https://github.com/nixos/nixpkgs", + "rev": "0f114432d4a9399e0b225d5be1599c7ebc5e2772", + "date": "2020-05-29T19:54:08-05:00", + "path": "/nix/store/ds31sjj3ppsk0xclkficx9p3w6qslmdc-nixpkgs", + "sha256": "1qd2dlc5dk98y0xdahv9k72ibv5dsy10jg25xqvj38sadxbs3g0j", + "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