aboutsummaryrefslogblamecommitdiff
path: root/flakes/libspf2/flake.nix
blob: 276b13838b6409f24bd9d651f37b6c7badecc816 (plain) (tree)





















































                                                                                                                              
{
  description = "Sender Policy Framework record checking library";

  inputs.flake-utils.url = "github:numtide/flake-utils";
  inputs.nixpkgs.url = "github:NixOS/nixpkgs";

  outputs = { self, flake-utils, nixpkgs }: flake-utils.lib.eachSystem ["aarch64-linux" "i686-linux" "x86_64-linux"] (system:
    let
      pkgs = import nixpkgs { inherit system; overlays = []; };
      inherit (pkgs) stdenv file fetchurl fetchpatch libnsl;
    in rec {
      packages.libspf2 = stdenv.mkDerivation rec {
        pname = "libspf2";
        version = "1.2.10";

        patches = [
          (fetchpatch {
            name = "fix-variadic-macros.patch";
            url = "https://git.archlinux.org/svntogit/community.git/plain/trunk/fix-variadic-macros.patch?h=packages/libspf2";
            sha256 = "00dqpcgjr9jy2qprgqv2qiyvq8y3wlz4yns9xzabf2064jzqh2ic";
          })
        ];
        preConfigure = ''
          sed -i -e "s@/usr/bin/file@${file}/bin/file@" ./configure
          '';
        configureFlags = [
          "--enable-static"
        ];
        postInstall = ''
          rm $out/bin/*_static
          '';
        src = fetchurl {
          url = "https://www.libspf2.org/spf/${pname}-${version}.tar.gz";
          sha256 = "1j91p0qiipzf89qxq4m1wqhdf01hpn1h5xj4djbs51z23bl3s7nr";
        };

        buildInputs = [ libnsl ];

        meta = {
          description = "Sender Policy Framework record checking library";
          homepage = "https://www.libspf2.org/";
          platforms = stdenv.lib.platforms.linux;
        };
      };

      defaultPackage = packages.libspf2;
      legacyPackages.libfspf2 = packages.libspf2;
      apps.libspf2 = flake-utils.lib.mkApp { drv = packages.libspf2; name = "spfquery"; };
      defaultApp = apps.libspf2;
      checks.build = defaultPackage;
      hydraJobs.build = packages.libspf2;
    }
  );
}