From 076f9d88dde8313fe4ecc1a390f3705590259dd1 Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Mon, 26 Aug 2019 16:40:04 +0800 Subject: [PATCH] astyle: use cmake to avoid having to manually fix up LDFLAGS --- .../development/tools/misc/astyle/default.nix | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/pkgs/development/tools/misc/astyle/default.nix b/pkgs/development/tools/misc/astyle/default.nix index e66d92e34d65..66e972826cb9 100644 --- a/pkgs/development/tools/misc/astyle/default.nix +++ b/pkgs/development/tools/misc/astyle/default.nix @@ -1,32 +1,26 @@ -{ stdenv, fetchurl }: +{ stdenv, lib, fetchurl, cmake }: -let - name = "astyle"; +stdenv.mkDerivation rec { + pname = "astyle"; version = "3.1"; -in -stdenv.mkDerivation { - name = "${name}-${version}"; src = fetchurl { - url = "mirror://sourceforge/${name}/${name}_${version}_linux.tar.gz"; + url = "mirror://sourceforge/${pname}/${pname}_${version}_linux.tar.gz"; sha256 = "1ms54wcs7hg1bsywqwf2lhdfizgbk7qxc9ghasxk8i99jvwlrk6b"; }; - sourceRoot = if stdenv.cc.isClang - then "astyle/build/clang" - else "astyle/build/gcc"; + # lots of hardcoded references to /usr + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace ' /usr/' " $out/" + ''; - # -s option is obsolete on Darwin and breaks build - postPatch = if stdenv.isDarwin then '' - substituteInPlace Makefile --replace "LDFLAGSr = -s" "LDFLAGSr =" - '' else null; + nativeBuildInputs = [ cmake ]; - installFlags = "INSTALL=install prefix=$$out"; - - meta = { - homepage = http://astyle.sourceforge.net/; + meta = with lib; { description = "Source code indenter, formatter, and beautifier for C, C++, C# and Java"; - license = stdenv.lib.licenses.lgpl3; - platforms = stdenv.lib.platforms.unix; + homepage = "https://astyle.sourceforge.net/"; + license = licenses.lgpl3; + platforms = platforms.unix; }; }