Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Add nix recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Fournier committed Jan 14, 2024
1 parent 06e3d69 commit d06c7f5
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
8 changes: 8 additions & 0 deletions recipes-core/libeditline/libeditline_1.17.1.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SUMMARY = "A small replacement for GNU readline() for UNIX"
LICENSE = "CLOSED"

SRC_URI = "git://github.com/troglobit/editline.git;branch=master;protocol=https"
SRCREV = "ecabef273ebf4193c5d6aff196de1c204169bc52"
S = "${WORKDIR}/git"

inherit autotools pkgconfig
29 changes: 29 additions & 0 deletions recipes-core/nix/nix/configure.ac.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/configure.ac b/configure.ac
index 281ba2c32..c58e0f2fd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -347,8 +347,23 @@ AC_ARG_ENABLE(doc-gen, AS_HELP_STRING([--disable-doc-gen],[disable documentation
doc_generate=$enableval, doc_generate=yes)
AC_SUBST(doc_generate)

+
# Look for lowdown library.
-PKG_CHECK_MODULES([LOWDOWN], [lowdown >= 0.9.0], [CXXFLAGS="$LOWDOWN_CFLAGS $CXXFLAGS"])
+AC_ARG_ENABLE([markdown], AS_HELP_STRING([--enable-markdown], [Enable Markdown rendering in the Nix binary (requires lowdown) [default=auto]]),
+ enable_markdown=$enableval, enable_markdown=auto)
+AS_CASE(["$enable_markdown"],
+ [yes | auto], [
+ PKG_CHECK_MODULES([LOWDOWN], [lowdown >= 0.9.0], [
+ CXXFLAGS="$LOWDOWN_CFLAGS $CXXFLAGS"
+ have_lowdown=1
+ AC_DEFINE(HAVE_LOWDOWN, 1, [Whether lowdown is available and should be used for Markdown rendering.])
+ ], [
+ AS_IF([test "x$enable_markdown" == "xyes"], [AC_MSG_ERROR([--enable-markdown was specified, but lowdown was not found.])])
+ ])
+ ],
+ [no], [have_lowdown=],
+ [AC_MSG_ERROR([bad value "$enable_markdown" for --enable-markdown, must be one of: yes, no, auto])])
+

# Setuid installations.
AC_CHECK_FUNCS([setresuid setreuid lchown])
32 changes: 32 additions & 0 deletions recipes-core/nix/nix/markdown.cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/src/libcmd/markdown.cc b/src/libcmd/markdown.cc
index 8b3bbc1b5..e0d5ba0fc 100644
--- a/src/libcmd/markdown.cc
+++ b/src/libcmd/markdown.cc
@@ -4,14 +4,15 @@
#include "terminal.hh"

#include <sys/queue.h>
+#if HAVE_LOWDOWN
#include <lowdown.h>
-
+#endif
namespace nix {

std::string renderMarkdownToTerminal(std::string_view markdown)
{
int windowWidth = getWindowSize().second;
-
+#if HAVE_LOWDOWN
struct lowdown_opts opts {
.type = LOWDOWN_TERM,
.maxdepth = 20,
@@ -48,6 +49,9 @@ std::string renderMarkdownToTerminal(std::string_view markdown)
throw Error("allocation error while rendering Markdown");

return filterANSIEscapes(std::string(buf->data, buf->size), !shouldANSI());
+#else
+ return std::string(markdown);
+#endif
}

}
48 changes: 48 additions & 0 deletions recipes-core/nix/nix_2.19.2.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
SUMMARY = "Nix package manager"
LICENSE = "LGPL-2.1"
LIC_FILES_CHKSUM = "file://${WORKDIR}/git/COPYING;md5=fbc093901857fcd118f065f900982c24"

FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"

SRC_URI += "git://github.com/NixOS/nix.git;branch=latest-release;protocol=https \
file://configure.ac.patch \
file://markdown.cc.patch \
"

SRCREV = "50f8f1c8bc019a4c0fd098b9ac674b94cfc6af0d"
S = "${WORKDIR}/git"

inherit autotools-brokensep pkgconfig systemd

DEPENDS += " \
bison-native \
clang-native \
autoconf-archive \
jq-native \
boost \
openssl \
libarchive \
curl \
libsodium \
brotli \
libeditline \
libseccomp \
bdwgc \
nlohmann-json \
libgit2 \
"

FILES:${PN} += "${libdir}/tmpfiles.d/* "

do_install:append(){
# Remove unneeded things that we don't want on the nao
rm -r "${D}/usr/share/"

mv "${D}/usr/lib/systemd/system/nix-daemon.{socket,service}" "${D}${systemd_unitdir}/system/"
}


SYSTEMD_SERVICE:${PN} = "nix-daemon.service nix-daemon.socket"

EXTRA_OECONF += "--disable-cpuid --disable-tests --disable-doc-gen"
PARALLEL_MAKE = "-j 16"

0 comments on commit d06c7f5

Please sign in to comment.