diff options
-rw-r--r-- | .reuse/dep5 | 6 | ||||
-rw-r--r-- | cppcheck/default.nix (renamed from cppcheck.nix) | 0 | ||||
-rw-r--r-- | grep/default.nix (renamed from grep.nix) | 1 | ||||
-rw-r--r-- | md4c/default.nix | 67 | ||||
-rw-r--r-- | md4c/fix-pkgconfig.patch | 14 | ||||
-rw-r--r-- | shell.nix | 16 |
6 files changed, 100 insertions, 4 deletions
diff --git a/.reuse/dep5 b/.reuse/dep5 index ea56b84..866bedc 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -1,7 +1,11 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Source: https://trong.loang.org/~cnx/bux Upstream-Name: bux -Upstream-Contact: Nguyễn Gia Phong <mcsinyx@disroot.org> +Upstream-Contact: Nguyễn Gia Phong <cnx@loang.net> + +Files: md4c/fix-pkgconfig.patch +Copyright: 2023 Nguyễn Gia Phong +License: AGPL-3.0-or-later Files: README.md Copyright: N/A diff --git a/cppcheck.nix b/cppcheck/default.nix index 60991a7..60991a7 100644 --- a/cppcheck.nix +++ b/cppcheck/default.nix diff --git a/grep.nix b/grep/default.nix index b430b50..ae1e9d3 100644 --- a/grep.nix +++ b/grep/default.nix @@ -40,6 +40,5 @@ stdenv.mkDerivation rec { ''; license = licenses.gpl3Plus; platforms = platforms.all; - mainProgram = "grep"; }; } diff --git a/md4c/default.nix b/md4c/default.nix new file mode 100644 index 0000000..d5fb39e --- /dev/null +++ b/md4c/default.nix @@ -0,0 +1,67 @@ +# Recipe for building md4c at specific snapshot +# +# SPDX-FileCopyrightText: 2021 Anderson Torres +# SPDX-FileCopyrightText: 2021 Thomas Gerbet +# SPDX-FileCopyrightText: 2021 Leif Middelschulte +# SPDX-License-Identifier: MIT +# +# SPDX-FileCopyrightText: 2023 Nguyễn Gia Phong +# SPDX-License-Identifier: AGPL-3.0-or-later + +{ lib, stdenv, version, fetchFromGitHub, commit, hash +, binRenameHook, cmake, pkg-config }: + +stdenv.mkDerivation rec { + pname = "md4c"; + inherit version; + + src = fetchFromGitHub { + owner = "mity"; + repo = pname; + rev = commit; + inherit hash; + }; + + patches = [ + # We set CMAKE_INSTALL_LIBDIR to the absolute path in $out, so + # prefix and exec_prefix cannot be $out, too + # Use CMake's _FULL_ variables instead of `prefix` concatenation. + ./fix-pkgconfig.patch + ]; + + nativeBuildInputs = [ binRenameHook cmake pkg-config ]; + + meta = with lib; { + description = "Markdown parser made in C"; + longDescription = '' + MD4C is Markdown parser implementation in C, with the following features: + + - Compliance: Generally, MD4C aims to be compliant to the latest version + of CommonMark specification. Currently, we are fully compliant to + CommonMark 0.29. + - Extensions: MD4C supports some commonly requested and accepted + extensions. See below. + - Performance: MD4C is very fast. + - Compactness: MD4C parser is implemented in one source file and one + header file. There are no dependencies other than standard C library. + - Embedding: MD4C parser is easy to reuse in other projects, its API is + very straightforward: There is actually just one function, md_parse(). + - Push model: MD4C parses the complete document and calls few callback + functions provided by the application to inform it about a start/end of + every block, a start/end of every span, and with any textual contents. + - Portability: MD4C builds and works on Windows and POSIX-compliant + OSes. (It should be simple to make it run also on most other platforms, + at least as long as the platform provides C standard library, including + a heap memory management.) + - Encoding: MD4C by default expects UTF-8 encoding of the input + document. But it can be compiled to recognize ASCII-only control + characters (i.e. to disable all Unicode-specific code), or (on Windows) + to expect UTF-16 (i.e. what is on Windows commonly called just + "Unicode"). See more details below. + - Permissive license: MD4C is available under the MIT license. + ''; + homepage = "https://github.com/mity/md4c"; + license = licenses.mit; + platforms = platforms.all; + }; +} diff --git a/md4c/fix-pkgconfig.patch b/md4c/fix-pkgconfig.patch new file mode 100644 index 0000000..cf3c264 --- /dev/null +++ b/md4c/fix-pkgconfig.patch @@ -0,0 +1,14 @@ +diff --git a/md4c/md4c.pc.in b/md4c/md4c.pc.in +index 61c78d890249..72943b52d050 100644 +--- a/md4c/md4c.pc.in ++++ b/md4c/md4c.pc.in +@@ -1,7 +1,7 @@ + prefix=@CMAKE_INSTALL_PREFIX@ + exec_prefix=@CMAKE_INSTALL_PREFIX@ +-libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ ++libdir=@CMAKE_INSTALL_LIBDIR@ ++includedir=@CMAKE_INSTALL_INCLUDEDIR@ + + Name: @PROJECT_NAME@ + Description: @PROJECT_DESCRIPTION@ diff --git a/shell.nix b/shell.nix index 52541b8..8ec7eb8 100644 --- a/shell.nix +++ b/shell.nix @@ -19,7 +19,7 @@ let executable = true; destination = "/nix-support/setup-hook"; }; - cppcheck = version: commit: hash: callPackage ./cppcheck.nix { + cppcheck = version: commit: hash: callPackage ./cppcheck { inherit version; inherit commit; inherit hash; @@ -33,7 +33,7 @@ let url = "mirror://gnu/grep/grep-2.12.tar.xz"; hash = "sha256-Tc4KT7g93QEg31HgC1L6dg8u2GddTUwLCuZCumkurWQ="; }; - grep = version: base: commit: hash: callPackage ./grep.nix { + grep = version: base: commit: hash: callPackage ./grep { inherit version; inherit base; snapshot = fetchurl { @@ -42,6 +42,12 @@ let }; binRenameHook = binRenameHook version; }; + md4c = version: commit: hash: callPackage ./md4c { + inherit version; + inherit commit; + inherit hash; + binRenameHook = binRenameHook version; + }; in mkShell { packages = [ (cppcheck "9261.buggy" @@ -62,5 +68,11 @@ in mkShell { (grep "55cf7b6a" grep-2_12 "55cf7b6a1905320c36702a476b09ebb29a2934d3" "sha256-uUHEG4bDDNFiVgj/1mIkttp1B7tlZ1HOWJGPEfbCErU=") + (md4c "107.buggy" + "e278609ee06ad7f9efcb06da48188a4b837ed11b" + "sha256-UoqBSOnlfDsTHz/uLGIUEgmTSiU408iUcwAJTLdbEPM=") + (md4c "107.fixed" + "5d7c35973e5d06b46ca21b5b6e292c56dba7ca23" + "sha256-N/vIRhXuU948z0O4NXKMSKOZGAEE6UjGDT5oqrGpUy8=") ]; } |