push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
From 2c7829aec41f6915bda2a23af57f0b39b075a70b Mon Sep 17 00:00:00 2001
From: C4 Patino <c4patino@gmail.com>
Date: Wed, 3 Sep 2025 22:43:05 -0500
Subject: [PATCH] path changes for nix
---
books/build/features.sh | 1 +
books/centaur/ipasir/load-ipasir-sharedlib-raw.lsp | 6 +-----
.../bundle/software/cl+ssl-20231021-git/src/reload.lisp | 2 ++
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/books/build/features.sh b/books/build/features.sh
index 20ef1f1cc7..e8a16396e3 100755
--- a/books/build/features.sh
+++ b/books/build/features.sh
@@ -125,6 +125,7 @@ EOF
fi
echo "Determining whether an ipasir shared library is installed" 1>&2
+IPASIR_SHARED_LIBRARY=${IPASIR_SHARED_LIBRARY:-@libipasir@}
if check_ipasir; then
cat >> Makefile-features <<EOF
export OS_HAS_IPASIR ?= 1
diff --git a/books/centaur/ipasir/load-ipasir-sharedlib-raw.lsp b/books/centaur/ipasir/load-ipasir-sharedlib-raw.lsp
index 762e4ad4c0..abc95d0ad8 100644
--- a/books/centaur/ipasir/load-ipasir-sharedlib-raw.lsp
+++ b/books/centaur/ipasir/load-ipasir-sharedlib-raw.lsp
@@ -30,11 +30,7 @@
(er-let* ((libname (acl2::getenv$ "IPASIR_SHARED_LIBRARY" acl2::*the-live-state*)))
(handler-case
- (cffi::load-foreign-library
- (or libname
- (cw "WARNING: $IPASIR_SHARED_LIBRARY not specified, ~
- defaulting to \"libipasirglucose4.so\"")
- "libipasirglucose4.so"))
+(cffi::load-foreign-library (or libname "@libipasir@"))
(error () (er hard? 'load-ipasir-shardlib-raw
"Couldn't load ipasir shared library from ~s0."
libname))))
diff --git a/books/quicklisp/bundle/software/cl+ssl-20231021-git/src/reload.lisp b/books/quicklisp/bundle/software/cl+ssl-20231021-git/src/reload.lisp
index 05ab8837d0..fb60937580 100644
--- a/books/quicklisp/bundle/software/cl+ssl-20231021-git/src/reload.lisp
+++ b/books/quicklisp/bundle/software/cl+ssl-20231021-git/src/reload.lisp
@@ -14,6 +14,8 @@
;;; put this directly into ffi.lisp
(in-package :cl+ssl)
+(cl+ssl/config:define-libssl-path "@libssl@")
+(cl+ssl/config:define-libcrypto-path "@libcrypto@")
;; The default OS-X libssl seems have had insufficient crypto algos
;; (missing TLSv1_[1,2]_XXX methods,
--
2.50.1

View File

@@ -0,0 +1,201 @@
{
lib,
stdenv,
callPackage,
fetchFromGitHub,
runCommandLocal,
makeWrapper,
replaceVars,
sbcl,
which,
perl,
hostname,
openssl,
glucose,
minisat,
abc-verifier,
z3,
python3,
certifyBooks ? true,
}@args:
let
# Disable immobile space so we don't run out of memory on large books, and
# supply 2GB of dynamic space to avoid exhausting the heap while building the
# ACL2 system itself; see
# https://www.cs.utexas.edu/users/moore/acl2/current/HTML/installation/requirements.html#Obtaining-SBCL
sbcl' = args.sbcl.overrideAttrs { disableImmobileSpace = true; };
sbcl = runCommandLocal args.sbcl.name { nativeBuildInputs = [ makeWrapper ]; } ''
makeWrapper ${sbcl'}/bin/sbcl $out/bin/sbcl \
--add-flags "--dynamic-space-size 2000"
'';
in
stdenv.mkDerivation rec {
pname = "acl2";
version = "8.6";
src = fetchFromGitHub {
owner = "acl2-devel";
repo = "acl2-devel";
rev = version;
sha256 = "sha256-fF9bbEacwCHP1m/eVgFrTD4Ne7L2mzq0K9vJ1tiy9go=";
};
# You can swap this out with any other IPASIR implementation at
# build time by using overrideAttrs (make sure the derivation you
# use has a "libname" attribute so we can plug it into the patch
# below). Or, you can override it at runtime by setting the
# $IPASIR_SHARED_LIBRARY environment variable.
libipasir = callPackage ./libipasirglucose4 { };
patches = [
(replaceVars ./0001-path-changes-for-nix.patch {
libipasir = "${libipasir}/lib/${libipasir.libname}";
libssl = "${lib.getLib openssl}/lib/libssl${stdenv.hostPlatform.extensions.sharedLibrary}";
libcrypto = "${lib.getLib openssl}/lib/libcrypto${stdenv.hostPlatform.extensions.sharedLibrary}";
})
];
# We need the timestamps on the source tree to be stable for certification to
# work properly, so reset them here as necessary after patching
postPatch = ''
find . -type f -newer "$src" -execdir touch -r "$src" {} +
'';
nativeBuildInputs = lib.optional certifyBooks makeWrapper;
buildInputs = [
# ACL2 itself only needs a Common Lisp compiler/interpreter:
sbcl
]
++ lib.optionals certifyBooks [
# To build community books, we need Perl and a couple of utilities:
which
perl
hostname
# Some of the books require one or more of these external tools:
glucose
minisat
abc-verifier
libipasir
z3
(python3.withPackages (ps: [ ps.z3-solver ]))
];
# NOTE: Parallel building can be memory-intensive depending on the number of
# concurrent jobs. For example, this build has been seen to use >120GB of
# RAM on an 85 core machine.
enableParallelBuilding = true;
preConfigure = ''
# When certifying books, ACL2 doesn't like $HOME not existing.
export HOME=$(pwd)/fake-home
''
+ lib.optionalString certifyBooks ''
# Some books also care about $USER being nonempty.
export USER=nobody
'';
postConfigure = ''
# ACL2 and its books need to be built in place in the out directory because
# the proof artifacts are not relocatable. Since ACL2 mostly expects
# everything to exist in the original source tree layout, we put it in
# $out/share/${pname} and create symlinks in $out/bin as necessary.
mkdir -p $out/share/${pname}
cp -pR . $out/share/${pname}
cd $out/share/${pname}
'';
preBuild = "mkdir -p $HOME";
makeFlags = [
"LISP=${sbcl}/bin/sbcl"
"ACL2_MAKE_LOG=NONE"
];
doCheck = true;
checkTarget = "mini-proveall";
installPhase = ''
mkdir -p $out/bin
ln -s $out/share/${pname}/saved_acl2 $out/bin/${pname}
''
+ lib.optionalString certifyBooks ''
ln -s $out/share/${pname}/books/build/cert.pl $out/bin/${pname}-cert
ln -s $out/share/${pname}/books/build/clean.pl $out/bin/${pname}-clean
'';
preDistPhases = [ (if certifyBooks then "certifyBooksPhase" else "removeBooksPhase") ];
certifyBooksPhase = ''
# Certify the community books
pushd $out/share/${pname}/books
makeFlags="ACL2=$out/share/${pname}/saved_acl2"
buildFlags="all"
buildPhase
# Clean up some stuff to save space
find -name '*@useless-runes.lsp' -execdir rm {} + # saves ~1GB of space
find -name '*.cert.out' -execdir gzip {} + # saves ~400MB of space
popd
'';
removeBooksPhase = ''
# Delete the community books
rm -rf $out/share/${pname}/books
'';
meta = with lib; {
description = "Interpreter and prover for a Lisp dialect";
mainProgram = "acl2";
longDescription = ''
ACL2 is a logic and programming language in which you can model computer
systems, together with a tool to help you prove properties of those
models. "ACL2" denotes "A Computational Logic for Applicative Common
Lisp".
ACL2 is part of the Boyer-Moore family of provers, for which its authors
have received the 2005 ACM Software System Award.
This package installs the main ACL2 executable ${pname}, as well as the
build tools cert.pl and clean.pl, renamed to ${pname}-cert and
${pname}-clean.
''
+ (
if certifyBooks then
''
The community books are also included and certified with the `make
everything` target.
''
else
''
The community books are not included in this package.
''
);
homepage = "https://www.cs.utexas.edu/users/moore/acl2/";
downloadPage = "https://github.com/acl2-devel/acl2-devel/releases";
license =
with licenses;
[
# ACL2 itself is bsd3
bsd3
]
++ optionals certifyBooks [
# The community books are mostly bsd3 or mit but with a few
# other things thrown in.
mit
gpl2
llgpl21
cc0
publicDomain
unfreeRedistributable
];
maintainers = with maintainers; [
kini
raskin
];
platforms = platforms.all;
};
}

View File

@@ -0,0 +1,46 @@
From 0f48e046f44624f4d4d8255ac5bd26397a38f16c Mon Sep 17 00:00:00 2001
From: Keshav Kini <keshav.kini@gmail.com>
Date: Sun, 23 Feb 2020 14:09:30 -0800
Subject: [PATCH] Support shared library build
Patch taken from [the ACL2 Books documentation][1].
- Add " -fPIC" to the CXXFLAGS to build position-independent code,
required for shared libraries.
- Add the line "export CXXFLAGS" below the setting of CXXFLAGS, so that
those flags apply to the recursive make of the core solver library.
- Fix a typo: replace the occurrence of "CXXLAGS" with "CXXFLAGS".
[1]: http://www.cs.utexas.edu/users/moore/acl2/v8-2/combined-manual/index.html?topic=IPASIR____BUILDING-AN-IPASIR-SOLVER-LIBRARY
---
makefile | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/makefile b/makefile
index 07121de..4e85c4b 100755
--- a/makefile
+++ b/makefile
@@ -29,7 +29,8 @@ TARGET=libipasir$(SIG).a
CXX=g++
-CXXFLAGS= -g -std=c++11 -Wall -DNDEBUG -O3
+CXXFLAGS= -g -std=c++11 -Wall -DNDEBUG -O3 -fPIC
+export CXXFLAGS
#-----------------------------------------------------------------------#
#- REQUIRED TOP RULES --------------------------------------------------#
@@ -67,7 +68,7 @@ libipasir$(SIG).a: .FORCE
#-----------------------------------------------------------------------#
ipasir$(NAME)glue.o: ipasir$(NAME)glue.cc ipasir.h makefile
- $(CXX) -g -std=c++11 $(CXXLAGS) \
+ $(CXX) -g -std=c++11 $(CXXFLAGS) \
-DVERSION=\"$(VERSION)\" \
-I$(DIR) -I$(DIR)/core -c ipasir$(NAME)glue.cc
--
2.23.1

View File

@@ -0,0 +1,47 @@
{
lib,
stdenv,
fetchurl,
zlib,
unzip,
}:
stdenv.mkDerivation rec {
pname = "libipasirglucose4";
# This library has no version number AFAICT (beyond generally being based on
# Glucose 4.x), but it was submitted to the 2017 SAT competition so let's use
# that as the version number, I guess.
version = "2017";
libname = pname + stdenv.hostPlatform.extensions.sharedLibrary;
src = fetchurl {
url = "https://baldur.iti.kit.edu/sat-competition-2017/solvers/incremental/glucose-ipasir.zip";
sha256 = "0xchgady9vwdh8frmc8swz6va53igp2wj1y9sshd0g7549n87wdj";
};
nativeBuildInputs = [ unzip ];
buildInputs = [ zlib ];
sourceRoot = "sat/glucose4";
patches = [ ./0001-Support-shared-library-build.patch ];
makeFlags = [ "CXX=${stdenv.cc.targetPrefix}c++" ];
postBuild = ''
$CXX -shared -o ${libname} \
${lib.optionalString (!stdenv.cc.isClang) "-Wl,-soname,${libname}"} \
ipasirglucoseglue.o libipasirglucose4.a
'';
installPhase = ''
install -D ${libname} $out/lib/${libname}
'';
meta = with lib; {
description = "Shared library providing IPASIR interface to the Glucose SAT solver";
license = licenses.mit;
platforms = platforms.unix;
maintainers = with maintainers; [ kini ];
};
}

View File

@@ -0,0 +1,3 @@
source 'https://rubygems.org' do
gem 'asmrepl'
end

View File

@@ -0,0 +1,18 @@
GEM
specs:
GEM
remote: https://rubygems.org/
specs:
asmrepl (1.0.3)
fisk (~> 2)
fisk (2.3.0)
PLATFORMS
ruby
DEPENDENCIES
asmrepl!
BUNDLED WITH
2.2.24

View File

@@ -0,0 +1,21 @@
{
lib,
bundlerApp,
bundlerUpdateScript,
}:
bundlerApp {
pname = "asmrepl";
gemdir = ./.;
exes = [ "asmrepl" ];
passthru.updateScript = bundlerUpdateScript "asmrepl";
meta = with lib; {
description = "REPL for x86-64 assembly language";
homepage = "https://github.com/tenderlove/asmrepl";
license = licenses.asl20;
maintainers = with maintainers; [ lom ];
platforms = platforms.x86_64;
};
}

View File

@@ -0,0 +1,23 @@
{
asmrepl = {
dependencies = [ "fisk" ];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
sha256 = "10d0zvkhk3ja48vvx28hfsqfrzfl66vdpmk3gcgb5viy174c72v6";
type = "gem";
};
version = "1.0.3";
};
fisk = {
groups = [ "default" ];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
sha256 = "1mq2a7hjs9xfg514ci0xw90c33rzq1y58ywpnmhp7w767ll6wldd";
type = "gem";
};
version = "2.3.0";
};
}

View File

@@ -0,0 +1,16 @@
# This file tracks the Clojure tools version required by babashka.
# See https://github.com/borkdude/deps.clj#deps_clj_tools_version for background.
# The `updateScript` provided in default.nix takes care of keeping it in sync, as well.
{
clojure,
fetchurl,
}:
clojure.overrideAttrs (previousAttrs: {
pname = "babashka-clojure-tools";
version = "1.12.2.1565";
src = fetchurl {
url = previousAttrs.src.url;
hash = "sha256-qj0RqgIL+pgbqdMnG+vCfHirazBVA8ro2zCKOlDzYXk=";
};
})

View File

@@ -0,0 +1,5 @@
_bb_tasks() {
COMPREPLY=( $(compgen -W "$(bb tasks |tail -n +3 |cut -f1 -d ' ')" -- ${COMP_WORDS[COMP_CWORD]}) );
}
# autocomplete filenames as well
complete -f -F _bb_tasks bb

View File

@@ -0,0 +1,9 @@
function __bb_complete_tasks
if not test "$__bb_tasks"
set -g __bb_tasks (bb tasks |tail -n +3 |cut -f1 -d ' ')
end
printf "%s\n" $__bb_tasks
end
complete -c bb -a "(__bb_complete_tasks)" -d 'tasks'

View File

@@ -0,0 +1,6 @@
_bb_tasks() {
local matches=(`bb tasks |tail -n +3 |cut -f1 -d ' '`)
compadd -a matches
_files # autocomplete filenames as well
}
compdef _bb_tasks bb

View File

@@ -0,0 +1,113 @@
{
lib,
buildGraalvmNativeImage,
fetchurl,
writeScript,
installShellFiles,
}:
buildGraalvmNativeImage (finalAttrs: {
pname = "babashka-unwrapped";
version = "1.12.208";
src = fetchurl {
url = "https://github.com/babashka/babashka/releases/download/v${finalAttrs.version}/babashka-${finalAttrs.version}-standalone.jar";
sha256 = "sha256-2tr+MM4CNYaLpVw2q5Hx4hXnUkV4fl5T3znmq8mFycU=";
};
nativeBuildInputs = [ installShellFiles ];
extraNativeImageBuildArgs = [
"-H:+ReportExceptionStackTraces"
"--no-fallback"
"--native-image-info"
"--enable-preview"
];
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
$out/bin/bb --version | fgrep '${finalAttrs.version}'
$out/bin/bb '(+ 1 2)' | fgrep '3'
$out/bin/bb '(vec (dedupe *input*))' <<< '[1 1 1 1 2]' | fgrep '[1 2]'
$out/bin/bb '(prn "bépo àê")' | fgrep 'bépo àê'
$out/bin/bb '(:out (babashka.process/sh "echo" "ä"))' | fgrep 'ä'
$out/bin/bb '(into-array [:f])'
runHook postInstallCheck
'';
postInstall = ''
installShellCompletion --cmd bb --bash ${./completions/bb.bash}
installShellCompletion --cmd bb --zsh ${./completions/bb.zsh}
installShellCompletion --cmd bb --fish ${./completions/bb.fish}
'';
passthru.updateScript = writeScript "update-babashka" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl common-updater-scripts jq libarchive
set -euo pipefail
shopt -s inherit_errexit
latest_version="$(curl \
''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
-fsL "https://api.github.com/repos/babashka/babashka/releases/latest" \
| jq -r '.tag_name')"
if [ "$(update-source-version babashka-unwrapped "''${latest_version/v/}" --print-changes)" = "[]" ]; then
# no need to update babashka.clojure-tools when babashka-unwrapped wasn't updated
exit 0
fi
clojure_tools_version=$(curl \
-fsL \
"https://github.com/babashka/babashka/releases/download/''${latest_version}/babashka-''${latest_version/v/}-standalone.jar" \
| bsdtar -qxOf - borkdude/deps.clj \
| ${lib.getExe finalAttrs.finalPackage} -I -o -e "(or (some->> *input* (filter #(= '(def version) (take 2 %))) first last last last) (throw (ex-info \"Couldn't find expected '(def version ...)' form in 'borkdude/deps.clj'.\" {})))")
update-source-version babashka.clojure-tools "$clojure_tools_version" \
--file="pkgs/development/interpreters/babashka/clojure-tools.nix"
'';
meta = {
description = "Clojure babushka for the grey areas of Bash";
longDescription = ''
The main idea behind babashka is to leverage Clojure in places where you
would be using bash otherwise.
As one user described it:
Im quite at home in Bash most of the time, but theres a substantial
grey area of things that are too complicated to be simple in bash, but
too simple to be worth writing a clj/s script for. Babashka really
seems to hit the sweet spot for those cases.
Goals:
- Low latency Clojure scripting alternative to JVM Clojure.
- Easy installation: grab the self-contained binary and run. No JVM needed.
- Familiarity and portability:
- Scripts should be compatible with JVM Clojure as much as possible
- Scripts should be platform-independent as much as possible. Babashka
offers support for linux, macOS and Windows.
- Allow interop with commonly used classes like java.io.File and System
- Multi-threading support (pmap, future, core.async)
- Batteries included (tools.cli, cheshire, ...)
- Library support via popular tools like the clojure CLI
'';
homepage = "https://github.com/babashka/babashka";
changelog = "https://github.com/babashka/babashka/blob/v${finalAttrs.version}/CHANGELOG.md";
sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
license = lib.licenses.epl10;
mainProgram = "bb";
maintainers = with lib.maintainers; [
bandresen
bhougland
DerGuteMoritz
jlesquembre
];
};
})

View File

@@ -0,0 +1,65 @@
{
stdenvNoCC,
lib,
babashka-unwrapped,
callPackage,
makeWrapper,
installShellFiles,
rlwrap,
clojureToolsBabashka ? callPackage ./clojure-tools.nix { },
jdkBabashka ? clojureToolsBabashka.jdk,
# rlwrap is a small utility to allow the editing of keyboard input, see
# https://book.babashka.org/#_repl
#
# NOTE In some cases, rlwrap prints some extra empty lines. That behavior can
# break some babashka scripts. For this reason, it is disabled by default. See:
# https://github.com/NixOS/nixpkgs/issues/246839
# https://github.com/NixOS/nixpkgs/pull/248207
withRlwrap ? false,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "babashka";
inherit (babashka-unwrapped) version meta doInstallCheck;
dontUnpack = true;
dontBuild = true;
nativeBuildInputs = [
makeWrapper
installShellFiles
];
installPhase =
let
unwrapped-bin = "${babashka-unwrapped}/bin/bb";
in
''
mkdir -p $out/clojure_tools
ln -s -t $out/clojure_tools ${clojureToolsBabashka}/*.edn
ln -s -t $out/clojure_tools ${clojureToolsBabashka}/libexec/*
makeWrapper "${babashka-unwrapped}/bin/bb" "$out/bin/bb" \
--inherit-argv0 \
--set-default DEPS_CLJ_TOOLS_DIR $out/clojure_tools \
--set-default JAVA_HOME ${jdkBabashka}
installShellCompletion --cmd bb --bash ${babashka-unwrapped}/share/bash-completion/completions/bb.bash
installShellCompletion --cmd bb --zsh ${babashka-unwrapped}/share/zsh/site-functions/_bb
installShellCompletion --cmd bb --fish ${babashka-unwrapped}/share/fish/vendor_completions.d/bb.fish
''
+ lib.optionalString withRlwrap ''
substituteInPlace $out/bin/bb \
--replace '"${unwrapped-bin}"' '"${rlwrap}/bin/rlwrap" "${unwrapped-bin}"'
'';
installCheckPhase = ''
${babashka-unwrapped.installCheckPhase}
# Needed for Darwin compat, see https://github.com/borkdude/deps.clj/issues/114
export CLJ_CONFIG="$TMP/.clojure"
$out/bin/bb clojure --version | grep -wF '${clojureToolsBabashka.version}'
'';
passthru.unwrapped = babashka-unwrapped;
passthru.clojure-tools = clojureToolsBabashka;
})

View File

@@ -0,0 +1,151 @@
{
lib,
callPackage,
fixDarwinDylibNames,
libffi,
mbqn-source,
pkg-config,
stdenv,
# Boolean flags
enableReplxx ? false,
enableLibcbqn ? ((stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin) && !enableReplxx),
generateBytecode ? false,
# "Configurable" options
bqn-interpreter,
}:
let
sources = callPackage ./sources.nix { };
in
stdenv.mkDerivation {
pname = "cbqn" + lib.optionalString (!generateBytecode) "-standalone";
inherit (sources.cbqn) version src;
nativeBuildInputs = [
pkg-config
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
fixDarwinDylibNames
];
buildInputs = [
libffi
];
makeFlags = [
"CC=${stdenv.cc.targetPrefix}cc"
];
buildFlags = [
# interpreter binary
"o3"
"notui=1" # display build progress in a plain-text format
"REPLXX=${if enableReplxx then "1" else "0"}"
]
++ lib.optionals stdenv.hostPlatform.avx2Support [
"has=avx2"
]
++ lib.optionals enableLibcbqn [
# embeddable interpreter as a shared lib
"shared-o3"
];
outputs = [
"out"
]
++ lib.optionals enableLibcbqn [
"lib"
"dev"
];
dontConfigure = true;
doInstallCheck = true;
strictDeps = true;
postPatch = ''
sed -i '/SHELL =.*/ d' makefile
patchShebangs build/build
'';
preBuild = ''
mkdir -p build/singeliLocal/
cp -r ${sources.singeli.src}/* build/singeliLocal/
''
+ (
if generateBytecode then
''
mkdir -p build/bytecodeLocal/gen
${bqn-interpreter} ./build/genRuntime ${mbqn-source} build/bytecodeLocal/
''
else
''
mkdir -p build/bytecodeLocal/gen
cp -r ${sources.cbqn-bytecode.src}/* build/bytecodeLocal/
''
)
+ lib.optionalString enableReplxx ''
mkdir -p build/replxxLocal/
cp -r ${sources.replxx.src}/* build/replxxLocal/
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin/
cp BQN -t $out/bin/
# note guard condition for case-insensitive filesystems
[ -e $out/bin/bqn ] || ln -s $out/bin/BQN $out/bin/bqn
[ -e $out/bin/cbqn ] || ln -s $out/bin/BQN $out/bin/cbqn
''
+ lib.optionalString enableLibcbqn ''
install -Dm644 include/bqnffi.h -t "$dev/include"
install -Dm755 libcbqn${stdenv.hostPlatform.extensions.sharedLibrary} -t "$lib/lib"
''
+ ''
runHook postInstall
'';
installCheckPhase = ''
runHook preInstallCheck
# main test suite from mlochbaum/BQN
$out/bin/BQN ${mbqn-source}/test/this.bqn
# CBQN tests that do not require compiling with test-only flags
$out/bin/BQN test/cmp.bqn
$out/bin/BQN test/equal.bqn
$out/bin/BQN test/copy.bqn
$out/bin/BQN test/bit.bqn
$out/bin/BQN test/hash.bqn
$out/bin/BQN test/squeezeValid.bqn
$out/bin/BQN test/squeezeExact.bqn
$out/bin/BQN test/various.bqn
$out/bin/BQN test/random.bqn
runHook postInstallCheck
'';
meta = {
homepage = "https://github.com/dzaima/CBQN/";
description = "BQN implementation in C";
license = with lib.licenses; [
# https://github.com/dzaima/CBQN?tab=readme-ov-file#licensing
asl20
boost
gpl3Only
lgpl3Only
mit
mpl20
];
mainProgram = "cbqn";
maintainers = with lib.maintainers; [
detegr
shnarazk
sternenseemann
synthetica
];
platforms = lib.platforms.all;
};
}

View File

@@ -0,0 +1,61 @@
# Sources required to build CBQN
# Update them all at the same time, or else misbuilds will happen!
# TODO: automate the update of this file
{
fetchFromGitHub,
}:
{
cbqn =
let
self = {
pname = "cbqn";
version = "0.9.0";
src = fetchFromGitHub {
owner = "dzaima";
repo = "CBQN";
rev = "v${self.version}";
hash = "sha256-WGQvnNVnNkz0PR/E5L05KvaaRZ9hgt9gNdzsR9OFYxA=";
};
};
in
self;
cbqn-bytecode = {
pname = "cbqn-bytecode";
version = "0-unstable-2025-03-16";
src = fetchFromGitHub {
owner = "dzaima";
repo = "cbqnBytecode";
rev = "0bdfb86d438a970b983afbca93011ebd92152b88";
hash = "sha256-oUM4UwLy9tusTFLlaZbbHfFqKEcqd9Mh4tTqiyvMyvo=";
};
};
replxx = {
pname = "replxx";
version = "0-unstable-2023-10-31";
src = fetchFromGitHub {
owner = "dzaima";
repo = "replxx";
rev = "13f7b60f4f79c2f14f352a76d94860bad0fc7ce9";
hash = "sha256-xPuQ5YBDSqhZCwssbaN/FcTZlc3ampYl7nfl2bbsgBA=";
};
};
singeli = {
pname = "singeli";
version = "0-unstable-2025-03-13";
src = fetchFromGitHub {
owner = "mlochbaum";
repo = "Singeli";
rev = "53f42ce4331176d281fa577408ec5a652bdd9127";
hash = "sha256-NbCNd/m0SdX2/aabeOhAzEYc5CcT/r75NR5ScuYj77c=";
};
};
}

View File

@@ -0,0 +1,155 @@
# there are the following linking sets:
# - boot (not installed): without modules, only used when building clisp
# - base (default): contains readline and i18n, regexp and syscalls modules
# by default
# - full: contains base plus modules in withModules
{
lib,
stdenv,
fetchFromGitLab,
autoconf,
automake,
bash,
libtool,
libsigsegv,
gettext,
ncurses,
pcre,
zlib,
readline,
libffi,
libffcall,
libX11,
libXau,
libXt,
libXpm,
libXext,
xorgproto,
coreutils,
# build options
threadSupport ? (stdenv.hostPlatform.isx86 && !stdenv.hostPlatform.isDarwin),
x11Support ? (stdenv.hostPlatform.isx86 && !stdenv.hostPlatform.isDarwin),
dllSupport ? true,
withModules ? [
"asdf"
"pcre"
"rawsock"
]
++ lib.optionals stdenv.hostPlatform.isLinux [
"bindings/glibc"
"zlib"
]
++ lib.optional x11Support "clx/new-clx",
}:
assert
x11Support
-> (
libX11 != null
&& libXau != null
&& libXt != null
&& libXpm != null
&& xorgproto != null
&& libXext != null
);
let
ffcallAvailable = stdenv.hostPlatform.isLinux && (libffcall != null);
in
stdenv.mkDerivation {
version = "2.49.95-unstable-2024-12-28";
pname = "clisp";
src = fetchFromGitLab {
owner = "gnu-clisp";
repo = "clisp";
rev = "c3ec11bab87cfdbeba01523ed88ac2a16b22304d";
hash = "sha256-xXGx2FlS0l9huVMHqNbcAViLjxK8szOFPT0J8MpGp9w=";
};
strictDeps = true;
nativeBuildInputs = [
autoconf
automake
libtool
];
buildInputs = [
bash
libsigsegv
]
++ lib.optional (gettext != null) gettext
++ lib.optional (ncurses != null) ncurses
++ lib.optional (pcre != null) pcre
++ lib.optional (zlib != null) zlib
++ lib.optional (readline != null) readline
++ lib.optional (ffcallAvailable && (libffi != null)) libffi
++ lib.optional ffcallAvailable libffcall
++ lib.optionals x11Support [
libX11
libXau
libXt
libXpm
xorgproto
libXext
];
# First, replace port 9090 (rather low, can be used)
# with 64237 (much higher, IANA private area, not
# anything rememberable).
postPatch = ''
sed -e 's@9090@64237@g' -i tests/socket.tst
sed -i 's@/bin/pwd@${coreutils}&@' src/clisp-link.in
sed -i 's@1\.16\.2@${automake.version}@' src/aclocal.m4
find . -type f | xargs sed -e 's/-lICE/-lXau &/' -i
'';
configureFlags = [
"builddir"
]
++ lib.optional (!dllSupport) "--without-dynamic-modules"
++ lib.optional (readline != null) "--with-readline"
# --with-dynamic-ffi can only exist with --with-ffcall - foreign.d does not compile otherwise
++ lib.optional (ffcallAvailable && (libffi != null)) "--with-dynamic-ffi"
++ lib.optional ffcallAvailable "--with-ffcall"
++ lib.optional (!ffcallAvailable) "--without-ffcall"
++ map (x: " --with-module=" + x) withModules
++ lib.optional threadSupport "--with-threads=POSIX_THREADS";
preBuild = ''
sed -e '/avcall.h/a\#include "config.h"' -i src/foreign.d
sed -i -re '/ cfree /d' -i modules/bindings/glibc/linux.lisp
cd builddir
'';
# ;; Loading file ../src/defmacro.lisp ...
# *** - handle_fault error2 ! address = 0x8 not in [0x1000000c0000,0x1000000c0000) !
# SIGSEGV cannot be cured. Fault address = 0x8.
hardeningDisable = [ "pie" ];
doCheck = true;
postInstall = lib.optionalString (withModules != [ ]) ''
bash ./clisp-link add "$out"/lib/clisp*/base "$(dirname "$out"/lib/clisp*/base)"/full \
${lib.concatMapStrings (x: " " + x) withModules}
find "$out"/lib/clisp*/full -type l -name "*.o" | while read -r symlink; do
if [[ "$(readlink "$symlink")" =~ (.*\/builddir\/)(.*) ]]; then
ln -sf "../''${BASH_REMATCH[2]}" "$symlink"
fi
done
'';
env.NIX_CFLAGS_COMPILE = "-O0 -falign-functions=${
if stdenv.hostPlatform.is64bit then "8" else "4"
}";
meta = {
description = "ANSI Common Lisp Implementation";
homepage = "http://clisp.org";
mainProgram = "clisp";
teams = [ lib.teams.lisp ];
license = lib.licenses.gpl2Plus;
platforms = with lib.platforms; linux ++ darwin;
};
}

View File

@@ -0,0 +1,37 @@
{
lib,
stdenv,
fetchurl,
jre,
makeWrapper,
}:
stdenv.mkDerivation rec {
pname = "clooj";
version = "0.4.4";
jar = fetchurl {
# mirrored as original mediafire.com source does not work without user interaction
url = "https://archive.org/download/clooj-${version}-standalone/clooj-${version}-standalone.jar";
sha256 = "0hbc29bg2a86rm3sx9kvj7h7db9j0kbnrb706wsfiyk3zi3bavnd";
};
nativeBuildInputs = [ makeWrapper ];
dontUnpack = true;
installPhase = ''
mkdir -p $out/share/java
ln -s $jar $out/share/java/clooj.jar
makeWrapper ${jre}/bin/java $out/bin/clooj --add-flags "-jar $out/share/java/clooj.jar"
'';
meta = {
description = "Lightweight IDE for Clojure";
mainProgram = "clooj";
homepage = "https://github.com/arthuredelstein/clooj";
sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
license = lib.licenses.bsd3;
platforms = lib.platforms.all;
};
}

View File

@@ -0,0 +1,122 @@
{
lib,
stdenv,
bashNonInteractive,
fetchurl,
installShellFiles,
jdk,
rlwrap,
makeWrapper,
writeScript,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "clojure";
version = "1.12.2.1565";
src = fetchurl {
# https://github.com/clojure/brew-install/releases
url = "https://github.com/clojure/brew-install/releases/download/${finalAttrs.version}/clojure-tools-${finalAttrs.version}.tar.gz";
hash = "sha256-qj0RqgIL+pgbqdMnG+vCfHirazBVA8ro2zCKOlDzYXk=";
};
nativeBuildInputs = [
installShellFiles
makeWrapper
];
buildInputs = [
bashNonInteractive
];
strictDeps = true;
# See https://github.com/clojure/brew-install/blob/1.10.3/src/main/resources/clojure/install/linux-install.sh
installPhase =
let
binPath = lib.makeBinPath [
rlwrap
jdk
];
in
''
runHook preInstall
clojure_lib_dir=$out
bin_dir=$out/bin
echo "Installing libs into $clojure_lib_dir"
install -Dm644 deps.edn "$clojure_lib_dir/deps.edn"
install -Dm644 example-deps.edn "$clojure_lib_dir/example-deps.edn"
install -Dm644 tools.edn "$clojure_lib_dir/tools.edn"
install -Dm644 exec.jar "$clojure_lib_dir/libexec/exec.jar"
install -Dm644 clojure-tools-${finalAttrs.version}.jar "$clojure_lib_dir/libexec/clojure-tools-${finalAttrs.version}.jar"
echo "Installing clojure and clj into $bin_dir"
substituteInPlace clojure --replace PREFIX $out
substituteInPlace clj --replace BINDIR $bin_dir
install -Dm755 clojure "$bin_dir/clojure"
install -Dm755 clj "$bin_dir/clj"
wrapProgram $bin_dir/clojure --prefix PATH : $out/bin:${binPath}
wrapProgram $bin_dir/clj --prefix PATH : $out/bin:${binPath}
installManPage clj.1 clojure.1
runHook postInstall
'';
doInstallCheck = true;
installCheckPhase = ''
CLJ_CONFIG=$TMPDIR CLJ_CACHE=$TMPDIR/.clj_cache $out/bin/clojure \
-Spath \
-Sverbose \
-Scp $out/libexec/clojure-tools-${finalAttrs.version}.jar
'';
passthru.updateScript = writeScript "update-clojure" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl common-updater-scripts jq
set -euo pipefail
shopt -s inherit_errexit
# `jq -r '.[0].name'` results in `v0.0`
latest_version="$(curl \
''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
-fsL "https://api.github.com/repos/clojure/brew-install/tags" \
| jq -r '.[1].name')"
update-source-version clojure "$latest_version"
'';
passthru.jdk = jdk;
meta = with lib; {
description = "Lisp dialect for the JVM";
homepage = "https://clojure.org/";
sourceProvenance = with sourceTypes; [ binaryBytecode ];
license = licenses.epl10;
longDescription = ''
Clojure is a dynamic programming language that targets the Java
Virtual Machine. It is designed to be a general-purpose language,
combining the approachability and interactive development of a
scripting language with an efficient and robust infrastructure for
multithreaded programming. Clojure is a compiled language - it
compiles directly to JVM bytecode, yet remains completely
dynamic. Every feature supported by Clojure is supported at
runtime. Clojure provides easy access to the Java frameworks, with
optional type hints and type inference, to ensure that calls to Java
can avoid reflection.
Clojure is a dialect of Lisp, and shares with Lisp the code-as-data
philosophy and a powerful macro system. Clojure is predominantly a
functional programming language, and features a rich set of immutable,
persistent data structures. When mutable state is needed, Clojure
offers a software transactional memory system and reactive Agent
system that ensure clean, correct, multithreaded designs.
'';
maintainers = with maintainers; [ jlesquembre ];
platforms = platforms.unix;
};
})

View File

@@ -0,0 +1,92 @@
{
lib,
stdenv,
babashka,
cacert,
clojure,
git,
jdk,
obb,
fetchFromGitHub,
makeWrapper,
runCommand,
}:
stdenv.mkDerivation rec {
pname = "obb";
version = "0.0.2";
src = fetchFromGitHub {
owner = "babashka";
repo = "obb";
rev = "v${version}";
sha256 = "1Gxh4IMtytQCuPS+BWOc5AgjEBxa43ebYfDsxLSPeY0=";
};
nativeBuildInputs = [ makeWrapper ];
buildInputs = [
babashka
cacert
git
jdk
];
configurePhase = ''
runHook preConfigure
mkdir -p .m2
substituteInPlace deps.edn --replace ':paths' ':mvn/local-repo "./.m2" :paths'
substituteInPlace bb.edn --replace ':paths' ':mvn/local-repo "./.m2" :paths'
echo deps.edn
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
export DEPS_CLJ_TOOLS_DIR=${clojure}
export DEPS_CLJ_TOOLS_VERSION=${clojure.version}
mkdir -p .gitlibs
mkdir -p .cpcache
export GITLIBS=.gitlibs
export CLJ_CACHE=.cpcache
bb build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
ln -s /usr/bin/osascript $out/bin/osascript
install -Dm755 "out/bin/obb" "$out/bin/obb"
wrapProgram $out/bin/obb --prefix PATH : $out/bin
runHook postInstall
'';
passthru.tests = {
simple = runCommand "obb-test" { } ''
[ $(${obb}/bin/obb -e '(+ 1 2)') = '3' ]
touch $out
'';
};
meta = with lib; {
description = "Ad-hoc ClojureScript scripting of Mac applications via Apple's Open Scripting Architecture";
homepage = "https://github.com/babashka/obb";
license = licenses.epl10;
maintainers = with maintainers; [
willcohen
];
platforms = platforms.darwin;
# https://hydra.nixos.org/job/nixpkgs/trunk/obb.aarch64-darwin/all
broken = true;
};
}

View File

@@ -0,0 +1,31 @@
{ buildDhallPackage, lib }:
# This is a minor variation on `buildDhallPackage` that splits the `code`
# argument into `src` and `file` in such a way that you can easily override
# the `file`
#
# This function is used by `dhall-to-nixpkgs` when given a directory
lib.makePackageOverridable (
{
# Arguments passed through to `buildDhallPackage`
name,
dependencies ? [ ],
source ? false,
src,
# The file to import, relative to the root directory
file ? "package.dhall",
# Set to `true` to generate documentation for the package
document ? false,
}:
buildDhallPackage (
{
inherit name dependencies source;
code = "${src}/${file}";
}
// lib.optionalAttrs document { documentationRoot = "${src}"; }
)
)

View File

@@ -0,0 +1,71 @@
{
buildDhallPackage,
fetchFromGitHub,
lib,
}:
# This function is used by `dhall-to-nixpkgs` when given a GitHub repository
lib.makePackageOverridable (
{
# Arguments passed through to `buildDhallPackage`
name,
dependencies ? [ ],
source ? false,
# The directory containing the Dhall files, if other than the root of the
# repository
directory ? "",
# The file to import, relative to the above directory
file ? "package.dhall",
# Set to `true` to generate documentation for the package
document ? false,
# Arguments passed through to `fetchFromGitHub`
owner,
repo,
rev,
# Extra arguments passed through to `fetchFromGitHub`, such as the hash
# or `fetchSubmodules`
...
}@args:
let
versionedName = "${name}-${rev}";
src = fetchFromGitHub (
{
name = "${versionedName}-source";
inherit owner repo rev;
}
// removeAttrs args [
"name"
"dependencies"
"document"
"source"
"directory"
"file"
"owner"
"repo"
"rev"
]
);
prefix = lib.optionalString (directory != "") "/${directory}";
in
buildDhallPackage (
{
inherit dependencies source;
name = versionedName;
code = "${src}${prefix}/${file}";
}
// lib.optionalAttrs document {
documentationRoot = "${src}/${prefix}";
baseImportUrl = "https://raw.githubusercontent.com/${owner}/${repo}/${rev}${prefix}";
}
)
)

View File

@@ -0,0 +1,113 @@
{
dhall,
dhall-docs,
haskell,
lib,
lndir,
runCommand,
writeText,
}:
{
name,
# Expressions to add to the cache before interpreting the code
dependencies ? [ ],
# A Dhall expression
#
# Carefully note that the following expression must be devoid of uncached HTTP
# imports. This is because the expression will be evaluated using an
# interpreter with HTTP support disabled, so all HTTP imports have to be
# protected by an integrity check that can be satisfied via cached
# dependencies.
#
# You can add a dependency to the cache using the preceding `dependencies`
# option
code,
# `buildDhallPackage` can include both a "source distribution" in
# `source.dhall` and a "binary distribution" in `binary.dhall`:
#
# * `source.dhall` is a dependency-free αβ-normalized Dhall expression
#
# * `binary.dhall` is an expression of the form: `missing sha256:${HASH}`
#
# This expression requires you to install the cache product located at
# `.cache/dhall/1220${HASH}` to successfully resolve
#
# By default, `buildDhallPackage` only includes "binary.dhall" to conserve
# space within the Nix store, but if you set the following `source` option to
# `true` then the package will also include `source.dhall`.
source ? false,
# Directory to generate documentation for (i.e. as the `--input` option to the
# `dhall-docs` command.)
#
# If `null`, then no documentation is generated.
documentationRoot ? null,
# Base URL prepended to paths copied to the clipboard
#
# This is used in conjunction with `documentationRoot`, and is unused if
# `documentationRoot` is `null`.
baseImportUrl ? null,
}:
let
# HTTP support is disabled in order to force that HTTP dependencies are built
# using Nix instead of using Dhall's support for HTTP imports.
dhallNoHTTP = haskell.lib.compose.appendConfigureFlag "-f-with-http" dhall;
file = writeText "${name}.dhall" code;
cache = ".cache";
data = ".local/share";
cacheDhall = "${cache}/dhall";
dataDhall = "${data}/dhall";
sourceFile = "source.dhall";
in
runCommand name { inherit dependencies; } ''
set -eu
mkdir -p ${cacheDhall}
for dependency in $dependencies; do
${lndir}/bin/lndir -silent $dependency/${cacheDhall} ${cacheDhall}
done
export XDG_CACHE_HOME=$PWD/${cache}
mkdir -p $out/${cacheDhall}
${dhallNoHTTP}/bin/dhall --alpha --file '${file}' > $out/${sourceFile}
SHA_HASH=$(${dhallNoHTTP}/bin/dhall hash <<< $out/${sourceFile})
HASH_FILE="''${SHA_HASH/sha256:/1220}"
${dhallNoHTTP}/bin/dhall encode --file $out/${sourceFile} > $out/${cacheDhall}/$HASH_FILE
echo "missing $SHA_HASH" > $out/binary.dhall
${lib.optionalString (!source) "rm $out/${sourceFile}"}
${lib.optionalString (documentationRoot != null) ''
mkdir -p $out/${dataDhall}
XDG_DATA_HOME=$out/${data} ${dhall-docs}/bin/dhall-docs --output-link $out/docs ${
lib.cli.toGNUCommandLineShell { } {
base-import-url = baseImportUrl;
input = documentationRoot;
package-name = name;
}
}
''}
''

View File

@@ -0,0 +1,106 @@
{
cacert,
dhall,
dhall-docs,
haskell,
lib,
runCommand,
}:
# `buildDhallUrl` is similar to `buildDhallDirectoryPackage` or
# `buildDhallGitHubPackage`, but instead builds a Nixpkgs Dhall package
# based on a hashed URL. This will generally be a URL that has an integrity
# check in a Dhall file.
#
# Similar to `buildDhallDirectoryPackage` and `buildDhallGitHubPackage`, the output
# of this function is a derivation that has a `binary.dhall` file, along with
# a `.cache/` directory with the actual contents of the Dhall file from the
# suppiled URL.
#
# This function is primarily used by `dhall-to-nixpkgs directory --fixed-output-derivations`.
{
# URL of the input Dhall file.
# example: "https://raw.githubusercontent.com/cdepillabout/example-dhall-repo/c1b0d0327146648dcf8de997b2aa32758f2ed735/example1.dhall"
url,
# Nix hash of the input Dhall file.
# example: "sha256-ZTSiQUXpPbPfPvS8OeK6dDQE6j6NbP27ho1cg9YfENI="
hash,
# Dhall hash of the input Dhall file.
# example: "sha256:6534a24145e93db3df3ef4bc39e2ba743404ea3e8d6cfdbb868d5c83d61f10d2"
dhallHash,
# Name for this derivation.
name ? (baseNameOf url + "-cache"),
# `buildDhallUrl` can include both a "source distribution" in
# `source.dhall` and a "binary distribution" in `binary.dhall`:
#
# * `source.dhall` is a dependency-free αβ-normalized Dhall expression
#
# * `binary.dhall` is an expression of the form: `missing sha256:${HASH}`
#
# This expression requires you to install the cache product located at
# `.cache/dhall/1220${HASH}` to successfully resolve
#
# By default, `buildDhallUrl` only includes "binary.dhall" to conserve
# space within the Nix store, but if you set the following `source` option to
# `true` then the package will also include `source.dhall`.
source ? false,
}:
let
# HTTP support is disabled in order to force that HTTP dependencies are built
# using Nix instead of using Dhall's support for HTTP imports.
dhallNoHTTP = haskell.lib.appendConfigureFlag dhall "-f-with-http";
# This uses Dhall's remote importing capabilities for downloading a Dhall file.
# The output Dhall file has all imports resolved, and then is
# alpha-normalized and binary-encoded.
downloadedEncodedFile =
runCommand (baseNameOf url)
{
outputHashAlgo = null;
outputHash = hash;
name = baseNameOf url;
nativeBuildInputs = [ cacert ];
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
}
''
echo "${url} ${dhallHash}" > in-dhall-file
${dhall}/bin/dhall --alpha --plain --file in-dhall-file | ${dhallNoHTTP}/bin/dhall encode > $out
'';
cache = ".cache";
data = ".local/share";
cacheDhall = "${cache}/dhall";
dataDhall = "${data}/dhall";
sourceFile = "source.dhall";
in
runCommand name { } (
''
set -eu
mkdir -p ${cacheDhall} $out/${cacheDhall}
export XDG_CACHE_HOME=$PWD/${cache}
SHA_HASH="${dhallHash}"
HASH_FILE="''${SHA_HASH/sha256:/1220}"
cp ${downloadedEncodedFile} $out/${cacheDhall}/$HASH_FILE
echo "missing $SHA_HASH" > $out/binary.dhall
''
+ lib.optionalString source ''
${dhallNoHTTP}/bin/dhall decode --file ${downloadedEncodedFile} > $out/${sourceFile}
''
)

View File

@@ -0,0 +1,32 @@
{
dhall-nixpkgs,
lib,
stdenv,
}:
# This function calls `dhall-to-nixpkgs directory --fixed-output-derivations`
# within a Nix derivation.
#
# This is possible because
# `dhall-to-nixpkgs directory --fixed-output-derivations` will turn remote
# Dhall imports protected with Dhall integrity checksinto fixed-output
# derivations (with the `buildDhallUrl` function), so no unrestricted network
# access is necessary.
lib.makePackageOverridable (
{
src,
# The file to import, relative to the root directory
file ? "package.dhall",
# Set to `true` to generate documentation for the package
document ? false,
}:
stdenv.mkDerivation {
name = "dhall-directory-package.nix";
buildCommand = ''
dhall-to-nixpkgs directory --fixed-output-derivations --file "${file}" "${src}" ${lib.optionalString document "--document"} > $out
'';
nativeBuildInputs = [ dhall-nixpkgs ];
}
)

View File

@@ -0,0 +1,82 @@
{
lib,
stdenv,
fetchFromGitHub,
jdk,
makeWrapper,
buildNativeImage ? true,
}:
stdenv.mkDerivation rec {
pname = "dapl" + lib.optionalString buildNativeImage "-native";
version = "0.2.0+date=2021-10-16";
src = fetchFromGitHub {
owner = "dzaima";
repo = "APL";
rev = "5eb0a4205e27afa6122096a25008474eec562dc0";
hash = "sha256-UdumMytqT909JRpNqzhYPuKPw644m/vRUsEbIVF2a7U=";
};
nativeBuildInputs = [
jdk
makeWrapper
];
dontConfigure = true;
postPatch = ''
patchShebangs --build ./build
'';
buildPhase = ''
runHook preBuild
./build
''
+ lib.optionalString buildNativeImage ''
native-image --report-unsupported-elements-at-runtime \
-H:CLibraryPath=${lib.getLib jdk}/lib -J-Dfile.encoding=UTF-8 \
-jar APL.jar dapl
''
+ ''
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
''
+ (
if buildNativeImage then
''
mv dapl $out/bin
''
else
''
mkdir -p $out/share/${pname}
mv APL.jar $out/share/${pname}/
makeWrapper "${lib.getBin jdk}/bin/java" "$out/bin/dapl" \
--add-flags "-jar $out/share/${pname}/APL.jar"
''
)
+ ''
ln -s $out/bin/dapl $out/bin/apl
runHook postInstall
'';
meta = with lib; {
homepage = "https://github.com/dzaima/APL";
description =
"APL implementation in Java" + lib.optionalString buildNativeImage ", compiled as a native image";
license = licenses.mit;
maintainers = [ ];
inherit (jdk.meta) platforms;
broken = stdenv.hostPlatform.isDarwin; # never built on Hydra https://hydra.nixos.org/job/nixpkgs/staging-next/dapl-native.x86_64-darwin
};
}
# TODO: Processing app
# TODO: minimalistic JDK

View File

@@ -0,0 +1,9 @@
{ mkDerivation }:
mkDerivation {
version = "1.15.7";
sha256 = "sha256-6GfZycylh+sHIuiQk/GQr1pRQRY1uBycSQdsVJ0J13k=";
# https://hexdocs.pm/elixir/1.15.0/compatibility-and-deprecations.html#compatibility-between-elixir-and-erlang-otp
minimumOTPVersion = "24";
maximumOTPVersion = "26";
escriptPath = "lib/elixir/scripts/generate_app.escript";
}

View File

@@ -0,0 +1,9 @@
{ mkDerivation }:
mkDerivation {
version = "1.16.3";
sha256 = "sha256-WUBqoz3aQvBlSG3pTxGBpWySY7I0NUcDajQBgq5xYTU=";
# https://hexdocs.pm/elixir/1.16.0/compatibility-and-deprecations.html#compatibility-between-elixir-and-erlang-otp
minimumOTPVersion = "24";
maximumOTPVersion = "26";
escriptPath = "lib/elixir/scripts/generate_app.escript";
}

View File

@@ -0,0 +1,9 @@
{ mkDerivation }:
mkDerivation {
version = "1.17.3";
sha256 = "sha256-7Qo6y0KAQ9lwD4oH+7wQ4W5i6INHIBDN9IQAAsYzNJw=";
# https://hexdocs.pm/elixir/1.17.3/compatibility-and-deprecations.html#compatibility-between-elixir-and-erlang-otp
minimumOTPVersion = "25";
maximumOTPVersion = "27";
escriptPath = "lib/elixir/scripts/generate_app.escript";
}

View File

@@ -0,0 +1,8 @@
{ mkDerivation }:
mkDerivation {
version = "1.18.4";
sha256 = "sha256-PwogI+HfRXy5M7Xn/KyDjm5vUquTBoGxliSV0A2AwSA=";
# https://hexdocs.pm/elixir/1.18.0/compatibility-and-deprecations.html#between-elixir-and-erlang-otp
minimumOTPVersion = "25";
escriptPath = "lib/elixir/scripts/generate_app.escript";
}

View File

@@ -0,0 +1,9 @@
{ mkDerivation }:
mkDerivation {
version = "1.19.0-rc.2";
sha256 = "sha256-RtJcnXjIqUw5h8Dsl8IPEaUVif4cHpUylmpmJCZ5EpM=";
# https://hexdocs.pm/elixir/1.19.0-rc.1/compatibility-and-deprecations.html#between-elixir-and-erlang-otp
minimumOTPVersion = "26";
maximumOTPVersion = "28";
escriptPath = "lib/elixir/scripts/generate_app.escript";
}

View File

@@ -0,0 +1,158 @@
{
config,
lib,
stdenv,
fetchFromGitHub,
erlang,
makeWrapper,
nix-update-script,
coreutils,
curl,
bash,
debugInfo ? false,
}@inputs:
{
baseName ? "elixir",
version,
erlang ? inputs.erlang,
minimumOTPVersion,
maximumOTPVersion ? null,
sha256 ? null,
rev ? "v${version}",
src ? fetchFromGitHub {
inherit rev sha256;
owner = "elixir-lang";
repo = "elixir";
},
escriptPath ? "lib/elixir/generate_app.escript",
}@args:
let
inherit (lib)
assertMsg
concatStringsSep
getVersion
optionals
optionalString
toInt
versions
versionAtLeast
versionOlder
;
compatibilityMsg = ''
Unsupported elixir and erlang OTP combination.
elixir ${version}
erlang OTP ${getVersion erlang} is not >= ${minimumOTPVersion} ${
optionalString (maximumOTPVersion != null) "and <= ${maximumOTPVersion}"
}
See https://hexdocs.pm/elixir/${version}/compatibility-and-deprecations.html
'';
maxShiftMajor = toString ((toInt (versions.major maximumOTPVersion)) + 1);
maxAssert =
if (maximumOTPVersion == null) then
true
else
versionOlder (versions.major (getVersion erlang)) maxShiftMajor;
minAssert = versionAtLeast (getVersion erlang) minimumOTPVersion;
bothAssert = minAssert && maxAssert;
elixirShebang =
if stdenv.hostPlatform.isDarwin then
# Darwin disallows shebang scripts from using other scripts as their
# command. Use env as an intermediary instead of calling elixir directly
# (another shebang script).
# See https://github.com/NixOS/nixpkgs/pull/9671
"${coreutils}/bin/env $out/bin/elixir"
else
"$out/bin/elixir";
erlc_opts = [ "deterministic" ] ++ optionals debugInfo [ "debug_info" ];
in
if !config.allowAliases && !bothAssert then
# Don't throw without aliases to not break CI.
null
else
assert assertMsg bothAssert compatibilityMsg;
stdenv.mkDerivation {
pname = "${baseName}";
inherit src version debugInfo;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ erlang ];
env = {
LANG = "C.UTF-8";
LC_TYPE = "C.UTF-8";
DESTDIR = placeholder "out";
PREFIX = "/";
ERL_COMPILER_OPTIONS = "[${concatStringsSep "," erlc_opts}]";
};
preBuild = ''
patchShebangs ${escriptPath} || true
'';
# copy stdlib source files for LSP access
postInstall = ''
for d in lib/*; do
cp -R "$d/lib" "$out/lib/elixir/$d"
done
'';
postFixup = ''
# Elixir binaries are shell scripts which run erl. Add some stuff
# to PATH so the scripts can run without problems.
for f in $out/bin/*; do
b=$(basename $f)
if [ "$b" = mix ]; then continue; fi
wrapProgram $f \
--prefix PATH ":" "${
lib.makeBinPath [
erlang
coreutils
curl
bash
]
}"
done
substituteInPlace $out/bin/mix \
--replace "/usr/bin/env elixir" "${elixirShebang}"
'';
passthru.updateScript = nix-update-script {
extraArgs = [
"--version-regex"
"v(${lib.versions.major version}\\.${lib.versions.minor version}\\.[0-9\\-rc.]+)"
"--override-filename"
"pkgs/development/interpreters/elixir/${lib.versions.major version}.${lib.versions.minor version}.nix"
];
};
pos = builtins.unsafeGetAttrPos "sha256" args;
meta = {
homepage = "https://elixir-lang.org/";
description = "Functional, meta-programming aware language built on top of the Erlang VM";
changelog = "https://github.com/elixir-lang/elixir/releases/tag/v${version}";
longDescription = ''
Elixir is a functional, meta-programming aware language built on
top of the Erlang VM. It is a dynamic language with flexible
syntax and macro support that leverages Erlang's abilities to
build concurrent, distributed and fault-tolerant applications
with hot code upgrades.
'';
license = lib.licenses.asl20;
platforms = lib.platforms.unix;
teams = [ lib.teams.beam ];
};
}

View File

@@ -0,0 +1,121 @@
{
lib,
stdenv,
meson,
ninja,
fetchFromGitLab,
re2c,
gperf,
gawk,
pkg-config,
boost,
fmt,
luajit_openresty,
ncurses,
serd,
sord,
libcap,
liburing,
openssl,
cereal,
cmake,
asciidoctor,
makeWrapper,
versionCheckHook,
gitUpdater,
enableIoUring ? false,
emilua, # this package
}:
stdenv.mkDerivation (finalAttrs: {
pname = "emilua";
version = "0.11.7";
src = fetchFromGitLab {
owner = "emilua";
repo = "emilua";
tag = "v${finalAttrs.version}";
hash = "sha256-c+X8HD/G75XD54Fs89DSkebLDd7h12Bk45+w7VBUXPY=";
};
propagatedBuildInputs = [
luajit_openresty
boost
fmt
ncurses
serd
sord
libcap
liburing
openssl
cereal
];
nativeBuildInputs = [
re2c
gperf
gawk
pkg-config
asciidoctor
meson
cmake
ninja
makeWrapper
];
dontUseCmakeConfigure = true;
mesonFlags = [
(lib.mesonBool "enable_io_uring" enableIoUring)
(lib.mesonBool "enable_file_io" enableIoUring)
(lib.mesonBool "enable_tests" true)
(lib.mesonBool "enable_manpages" true)
(lib.mesonOption "version_suffix" "-nixpkgs1")
];
postPatch = ''
patchShebangs src/emilua_gperf.awk --interpreter '${lib.getExe gawk} -f'
'';
# io_uring is not allowed in Nix sandbox, that breaks the tests
doCheck = !enableIoUring;
mesonCheckFlags = [
# Skipped test: libpsx
# Known issue with no-new-privs disabled in the Nix build environment.
"--no-suite"
"libpsx"
];
postInstall = ''
mkdir -p $out/nix-support
cp ${./setup-hook.sh} $out/nix-support/setup-hook
substituteInPlace $out/nix-support/setup-hook \
--replace-fail @sitePackages@ "${finalAttrs.passthru.sitePackages}"
'';
nativeInstallCheckInputs = [
versionCheckHook
];
versionCheckProgramArg = "--version";
doInstallCheck = true;
passthru = {
updateScript = gitUpdater { rev-prefix = "v"; };
inherit boost;
sitePackages = "lib/emilua-${(lib.concatStringsSep "." (lib.take 2 (lib.splitVersion finalAttrs.version)))}";
tests.with-io-uring = emilua.override { enableIoUring = true; };
};
meta = {
description = "Lua execution engine";
mainProgram = "emilua";
homepage = "https://emilua.org/";
license = lib.licenses.boost;
maintainers = with lib.maintainers; [
manipuladordedados
lucasew
];
platforms = lib.platforms.linux;
};
})

View File

@@ -0,0 +1,17 @@
addEmiluaPath() {
addToSearchPathWithCustomDelimiter : EMILUA_PATH $1/@sitePackages@
}
toEmiluaPath() {
local paths="$1"
local result=
for i in $paths; do
p="$i/@sitePackages@"
result="${result}${result:+:}$p"
done
echo $result
}
if [ -z "${dontAddEmiluaPath:-}" ]; then
addEnvHooks "$hostOffset" addEmiluaPath
fi

View File

@@ -0,0 +1,6 @@
genericBuilder:
genericBuilder {
version = "26.2.5.15";
hash = "sha256-D2JfB7D9mhbmYvJfjSMbcdNrlYNWa/BfqAeqsbjTZlE=";
}

View File

@@ -0,0 +1,6 @@
genericBuilder:
genericBuilder {
version = "27.3.4.3";
hash = "sha256-p4M1PPrbpNq6la4kgTTCOa2f5/oYxNwMaSi59mhlM4o=";
}

View File

@@ -0,0 +1,6 @@
genericBuilder:
genericBuilder {
version = "28.1";
hash = "sha256-rR31Zj7c2eNf608HhLNlrGnVQN/Nymug6EcPfeNHfqk=";
}

View File

@@ -0,0 +1,181 @@
{
# options set through beam-packages
# systemd support for epmd only
systemdSupport ? null,
wxSupport ? true,
# options set by version specific files, e.g. 28.nix
version,
hash ? null,
}:
{
# overridable options
enableDebugInfo ? false,
enableHipe ? true,
enableKernelPoll ? true,
enableSmpSupport ? true,
enableThreads ? true,
javacSupport ? false,
odbcSupport ? false,
parallelBuild ? true,
fetchFromGitHub,
gawk,
gnum4,
gnused,
lib,
libGL,
libGLU,
libxml2,
libxslt,
makeWrapper,
ncurses,
nix-update-script,
openjdk11,
openssl,
perl,
runtimeShell,
stdenv,
systemd,
unixODBC,
wrapGAppsHook3,
wxGTK32,
xorg,
zlib,
}:
let
inherit (lib)
optional
optionals
optionalString
;
wxPackages2 =
if stdenv.hostPlatform.isDarwin then
[ wxGTK32 ]
else
[
libGL
libGLU
wxGTK32
xorg.libX11
wrapGAppsHook3
];
major = builtins.head (builtins.splitVersion version);
enableSystemd =
if (systemdSupport == null) then
lib.meta.availableOn stdenv.hostPlatform systemd
else
systemdSupport;
runtimePath = lib.makeBinPath [
gawk
gnused
];
in
stdenv.mkDerivation {
pname = "erlang" + optionalString javacSupport "_javac" + optionalString odbcSupport "_odbc";
inherit version;
src = fetchFromGitHub {
owner = "erlang";
repo = "otp";
tag = "OTP-${version}";
inherit hash;
};
env = {
# only build man pages and shell/IDE docs
DOC_TARGETS = "man chunks";
LANG = "C.UTF-8";
};
nativeBuildInputs = [
makeWrapper
perl
gnum4
libxslt
libxml2
];
buildInputs = [
ncurses
openssl
zlib
]
++ optionals wxSupport wxPackages2
++ optionals odbcSupport [ unixODBC ]
++ optionals javacSupport [ openjdk11 ]
++ optionals enableSystemd [ systemd ];
# disksup requires a shell
postPatch = ''
substituteInPlace lib/os_mon/src/disksup.erl --replace-fail '"sh ' '"${runtimeShell} '
'';
debugInfo = enableDebugInfo;
# On some machines, parallel build reliably crashes on `GEN asn1ct_eval_ext.erl` step
enableParallelBuilding = parallelBuild;
configureFlags = [
"--with-ssl=${lib.getOutput "out" openssl}"
"--with-ssl-incl=${lib.getDev openssl}"
]
++ optional enableThreads "--enable-threads"
++ optional enableSmpSupport "--enable-smp-support"
++ optional enableKernelPoll "--enable-kernel-poll"
++ optional enableHipe "--enable-hipe"
++ optional javacSupport "--with-javac"
++ optional odbcSupport "--with-odbc=${unixODBC}"
++ optional wxSupport "--enable-wx"
++ optional enableSystemd "--enable-systemd"
++ optional stdenv.hostPlatform.isDarwin "--enable-darwin-64bit"
# make[3]: *** [yecc.beam] Segmentation fault: 11
++ optional (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) "--disable-jit";
installTargets = [
"install"
"install-docs"
];
postInstall = ''
ln -sv $out/lib/erlang/lib/erl_interface*/bin/erl_call $out/bin/erl_call
wrapProgram $out/lib/erlang/bin/erl --prefix PATH ":" "${runtimePath}"
wrapProgram $out/lib/erlang/bin/start_erl --prefix PATH ":" "${runtimePath}"
'';
passthru = {
updateScript = nix-update-script {
extraArgs = [
"--version-regex"
"OTP-(${major}.*)"
"--override-filename"
"pkgs/development/interpreters/erlang/${major}.nix"
];
};
};
meta = {
homepage = "https://www.erlang.org/";
downloadPage = "https://www.erlang.org/download.html";
description = "Programming language used for massively scalable soft real-time systems";
longDescription = ''
Erlang is a programming language used to build massively scalable
soft real-time systems with requirements on high availability.
Some of its uses are in telecoms, banking, e-commerce, computer
telephony and instant messaging. Erlang's runtime system has
built-in support for concurrency, distribution and fault
tolerance.
'';
platforms = lib.platforms.unix;
teams = [ lib.teams.beam ];
license = lib.licenses.asl20;
};
}

View File

@@ -0,0 +1,67 @@
{
stdenv,
lib,
fetchurl,
pkg-config,
texinfo,
libiconv,
gdbm,
openssl,
zlib,
mbedtls,
cacert,
}:
stdenv.mkDerivation rec {
pname = "gauche-bootstrap";
version = "0.9.15";
src = fetchurl {
url = "https://github.com/shirok/Gauche/releases/download/release${
lib.replaceStrings [ "." ] [ "_" ] version
}/Gauche-${version}.tgz";
hash = "sha256-NkPie8fIgiz9b7KJLbGF9ljo42STi8LM/O2yOeNa94M=";
};
nativeBuildInputs = [
pkg-config
texinfo
];
buildInputs = [
libiconv
gdbm
openssl
zlib
mbedtls
cacert
];
postPatch = ''
patchShebangs .
'';
configureFlags = [
"--with-iconv=${libiconv}"
"--with-dbm=gdbm"
"--with-zlib=${zlib}"
"--with-ca-bundle=${cacert}/etc/ssl/certs/ca-bundle.crt"
# TODO: Enable slib
# Current slib in nixpkgs is specialized to Guile
# "--with-slib=${slibGuile}/lib/slib"
];
enableParallelBuilding = true;
# TODO: Fix tests that fail in sandbox build
doCheck = false;
meta = with lib; {
description = "R7RS Scheme scripting engine (released version)";
homepage = "https://practical-scheme.net/gauche/";
mainProgram = "gosh";
maintainers = with maintainers; [ mnacamura ];
license = licenses.bsd3;
platforms = platforms.unix;
};
}

View File

@@ -0,0 +1,77 @@
{
stdenv,
lib,
fetchFromGitHub,
autoreconfHook,
gaucheBootstrap,
pkg-config,
texinfo,
libiconv,
gdbm,
openssl,
zlib,
mbedtls,
cacert,
}:
stdenv.mkDerivation rec {
pname = "gauche";
version = "0.9.15";
src = fetchFromGitHub {
owner = "shirok";
repo = "gauche";
rev = "release${lib.replaceStrings [ "." ] [ "_" ] version}";
hash = "sha256-M2vZqTMkob+WxUnCo4NDxS4pCVNleVBqkiiRp9nG/KA=";
};
nativeBuildInputs = [
gaucheBootstrap
pkg-config
texinfo
autoreconfHook
];
buildInputs = [
libiconv
gdbm
openssl
zlib
mbedtls
cacert
];
autoreconfPhase = ''
./DIST gen
'';
postPatch = ''
substituteInPlace ext/package-templates/configure \
--replace "#!/usr/bin/env gosh" "#!$out/bin/gosh"
patchShebangs .
'';
configureFlags = [
"--with-iconv=${libiconv}"
"--with-dbm=gdbm"
"--with-zlib=${zlib}"
"--with-ca-bundle=${cacert}/etc/ssl/certs/ca-bundle.crt"
# TODO: Enable slib
# Current slib in nixpkgs is specialized to Guile
# "--with-slib=${slibGuile}/lib/slib"
];
enableParallelBuilding = true;
# TODO: Fix tests that fail in sandbox build
doCheck = false;
meta = with lib; {
description = "R7RS Scheme scripting engine";
homepage = "https://practical-scheme.net/gauche/";
mainProgram = "gosh";
maintainers = with maintainers; [ mnacamura ];
license = licenses.bsd3;
platforms = platforms.unix;
};
}

View File

@@ -0,0 +1,242 @@
{
lib,
stdenv,
fetchFromGitHub,
cmake,
wrapGAppsHook3,
readline,
ncurses,
zlib,
gsl,
openmp,
graphicsmagick,
fftw,
fftwFloat,
fftwLongDouble,
proj,
shapelib,
expat,
udunits,
eigen,
pslib,
libpng,
plplot,
libtiff,
libgeotiff,
libjpeg,
qhull,
# eccodes is broken on darwin
enableGRIB ? stdenv.hostPlatform.isLinux,
eccodes,
enableGLPK ? stdenv.hostPlatform.isLinux,
glpk,
# We enable it in hdf4 and use libtirpc as a dependency here from the passthru
# of hdf4
enableLibtirpc ? stdenv.hostPlatform.isLinux,
python3,
enableMPI ? (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin),
# Choose MPICH over OpenMPI because it currently builds on AArch and Darwin
mpi,
# Unfree optional dependency for hdf4 and hdf5
enableSzip ? false,
szip,
enableHDF4 ? true,
hdf4,
hdf4-forced ? null,
enableHDF5 ? true,
# HDF5 format version (API version) 1.10 and 1.12 is not fully compatible
# Specify if the API version should default to 1.10
# netcdf currently depends on hdf5 with `usev110Api=true`
# If you wish to use HDF5 API version 1.12 (`useHdf5v110Api=false`),
# you will need to turn NetCDF off.
useHdf5v110Api ? true,
hdf5,
hdf5-forced ? null,
enableNetCDF ? true,
netcdf,
netcdf-forced ? null,
plplot-forced ? null,
# wxWidgets is preferred over X11 for this project but we only have it on Linux
# and Darwin.
enableWX ? (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin),
wxGTK32,
# X11: OFF by default for platform consistency. Use X where WX is not available
enableXWin ? (!stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isDarwin),
}:
let
hdf4-custom =
if hdf4-forced != null then
hdf4-forced
else
hdf4.override {
uselibtirpc = enableLibtirpc;
szipSupport = enableSzip;
inherit szip;
};
hdf5-custom =
if hdf5-forced != null then
hdf5-forced
else
hdf5.override (
{
usev110Api = useHdf5v110Api;
mpiSupport = enableMPI;
inherit mpi;
szipSupport = enableSzip;
inherit szip;
}
// lib.optionalAttrs enableMPI {
cppSupport = false;
}
);
netcdf-custom =
if netcdf-forced != null then
netcdf-forced
else
netcdf.override {
hdf5 = hdf5-custom;
};
enablePlplotDrivers = enableWX || enableXWin;
plplot-with-drivers =
if plplot-forced != null then
plplot-forced
else
plplot.override {
inherit
enableWX
enableXWin
;
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "gnudatalanguage";
version = "1.1.1";
src = fetchFromGitHub {
owner = "gnudatalanguage";
repo = "gdl";
tag = "v${finalAttrs.version}";
hash = "sha256-fLsa/R8+7QZcxjqJLnHZivRF6dD4a6J6KuCqYvazaCU=";
fetchSubmodules = true;
};
postPatch = ''
substituteInPlace CMakeLists.txt \
--replace-fail 'FATAL_ERROR "The src' 'WARNING "The src' \
--replace-fail "find_package(Git REQUIRED)" "" \
--replace-fail "-D GIT_EXECUTABLE=''${GIT_EXECUTABLE}" ""
echo -e 'set(VERSION "${finalAttrs.version}")\n\nconfigure_file(''${SRC} ''${DST})' > CMakeModules/GenerateVersionHeader.cmake
'';
nativeBuildInputs = [ cmake ] ++ lib.optional enableWX wrapGAppsHook3;
buildInputs = [
qhull
readline
ncurses
zlib
gsl
openmp
graphicsmagick
fftw
fftwFloat
fftwLongDouble
proj
shapelib
expat
mpi
udunits
eigen
pslib
libpng
libtiff
libgeotiff
libjpeg
hdf4-custom
hdf5-custom
netcdf-custom
plplot-with-drivers
]
++ lib.optional enableXWin plplot-with-drivers.libX11
++ lib.optional enableGRIB eccodes
++ lib.optional enableGLPK glpk
++ lib.optional enableWX wxGTK32
++ lib.optional enableMPI mpi
++ lib.optional enableLibtirpc hdf4-custom.libtirpc
++ lib.optional enableSzip szip;
propagatedBuildInputs = [
(python3.withPackages (ps: with ps; [ numpy ]))
];
cmakeFlags =
lib.optional (!enableHDF4) "-DHDF=OFF"
++ [ (if enableHDF5 then "-DHDF5DIR=${hdf5-custom}" else "-DHDF5=OFF") ]
++ lib.optional (!enableNetCDF) "-DNETCDF=OFF"
++ lib.optional (!enablePlplotDrivers) "-DINTERACTIVE_GRAPHICS=OFF"
++ lib.optional (!enableGRIB) "-DGRIB=OFF"
++ lib.optional (!enableGLPK) "-DGLPK=OFF"
++ lib.optional (!enableWX) "-DWXWIDGETS=OFF"
++ lib.optional enableSzip "-DSZIPDIR=${szip}"
++ lib.optionals enableXWin [
"-DX11=ON"
"-DX11DIR=${plplot-with-drivers.libX11}"
]
++ lib.optionals enableMPI [
"-DMPI=ON"
"-DMPIDIR=${mpi}"
];
# Tests are failing on Hydra:
# ./src/common/dpycmn.cpp(137): assert ""IsOk()"" failed in GetClientArea(): invalid wxDisplay object
doCheck = stdenv.hostPlatform.isLinux;
# Opt-out unstable tests
# https://github.com/gnudatalanguage/gdl/issues/482
# https://github.com/gnudatalanguage/gdl/issues/1079
# https://github.com/gnudatalanguage/gdl/issues/460
preCheck = ''
checkFlagsArray+=("ARGS=-E '${
lib.concatMapStringsSep "|" (test: test + ".pro") [
"test_byte_conversion"
"test_bytscl"
"test_call_external"
"test_tic_toc"
"test_timestamp"
"test_bugs_poly2d"
"test_formats"
]
}'")
'';
passthru = {
hdf4 = hdf4-custom;
hdf5 = hdf5-custom;
netcdf = netcdf-custom;
plplot = plplot-with-drivers;
python = python3;
inherit
enableMPI
mpi
useHdf5v110Api
enableSzip
enableWX
enableXWin
;
};
meta = {
description = "Free incremental compiler of IDL";
longDescription = ''
GDL (GNU Data Language) is a free/libre/open source incremental compiler
compatible with IDL (Interactive Data Language) and to some extent with PV-WAVE.
GDL is aimed as a drop-in replacement for IDL.
'';
homepage = "https://github.com/gnudatalanguage/gdl";
license = lib.licenses.gpl2Only;
maintainers = with lib.maintainers; [ ShamrockLee ];
platforms = lib.platforms.all;
mainProgram = "gdl";
};
})

View File

@@ -0,0 +1,113 @@
{
lib,
stdenv,
fetchurl,
buildPackages,
gawk,
gmp,
libtool,
makeWrapper,
pkg-config,
pkgsBuildBuild,
readline,
}:
stdenv.mkDerivation rec {
pname = "guile";
version = "1.8.8";
src = fetchurl {
url = "mirror://gnu/${pname}/${pname}-${version}.tar.gz";
sha256 = "0l200a0v7h8bh0cwz6v7hc13ds39cgqsmfrks55b1rbj5vniyiy3";
};
outputs = [
"out"
"dev"
"info"
];
setOutputFlags = false; # $dev gets into the library otherwise
# GCC 4.6 raises a number of set-but-unused warnings.
configureFlags = [
"--disable-error-on-warning"
]
# Guile needs patching to preset results for the configure tests about
# pthreads, which work only in native builds.
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "--with-threads=no";
depsBuildBuild = [
buildPackages.stdenv.cc
]
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) pkgsBuildBuild.guile_1_8;
nativeBuildInputs = [
makeWrapper
pkg-config
];
buildInputs = [
libtool
readline
];
propagatedBuildInputs = [
gmp
# XXX: These ones aren't normally needed here, but `libguile*.la' has '-l'
# flags for them without corresponding '-L' flags. Adding them here will add
# the needed `-L' flags. As for why the `.la' file lacks the `-L' flags,
# see below.
libtool
];
patches = [
# Fix doc snarfing with GCC 4.5.
./cpp-4.5.patch
# Self explanatory
./CVE-2016-8605.patch
];
preBuild = ''
sed -e '/lt_dlinit/a lt_dladdsearchdir("'$out/lib'");' -i libguile/dynl.c
'';
postInstall = ''
wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin"
''
# XXX: See http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/18903 for
# why `--with-libunistring-prefix' and similar options coming from
# `AC_LIB_LINKFLAGS_BODY' don't work on NixOS/x86_64.
+ ''
sed -i "$out/lib/pkgconfig/guile"-*.pc \
-e "s|-lltdl|-L${libtool.lib}/lib -lltdl|g"
'';
# One test fails.
# ERROR: file: "libtest-asmobs", message: "file not found"
# This is fixed here:
# <https://git.savannah.gnu.org/cgit/guile.git/commit/?h=branch_release-1-8&id=a0aa1e5b69d6ef0311aeea8e4b9a94eae18a1aaf>.
doCheck = false;
doInstallCheck = doCheck;
setupHook = ./setup-hook-1.8.sh;
passthru = {
effectiveVersion = lib.versions.majorMinor version;
siteCcacheDir = "lib/guile/site-ccache";
siteDir = "share/guile/site";
};
meta = with lib; {
homepage = "https://www.gnu.org/software/guile/";
description = "Embeddable Scheme implementation";
longDescription = ''
GNU Guile is an implementation of the Scheme programming language, with
support for many SRFIs, packaged for use in a wide variety of
environments. In addition to implementing the R5RS Scheme standard and a
large subset of R6RS, Guile includes a module system, full access to POSIX
system calls, networking support, multiple threads, dynamic linking, a
foreign function call interface, and powerful string processing.
'';
license = licenses.lgpl3Plus;
maintainers = with maintainers; [ ludo ];
platforms = platforms.all;
};
}

View File

@@ -0,0 +1,171 @@
{
lib,
stdenv,
fetchurl,
fetchpatch,
boehmgc,
buildPackages,
coverageAnalysis ? null,
gawk,
gmp,
libffi,
libtool,
libunistring,
makeWrapper,
pkg-config,
pkgsBuildBuild,
readline,
}:
let
# Do either a coverage analysis build or a standard build.
builder = if coverageAnalysis != null then coverageAnalysis else stdenv.mkDerivation;
in
builder rec {
pname = "guile";
version = "2.0.13";
src = fetchurl {
url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz";
sha256 = "12yqkr974y91ylgw6jnmci2v90i90s7h9vxa4zk0sai8vjnz4i1p";
};
outputs = [
"out"
"dev"
"info"
];
setOutputFlags = false; # $dev gets into the library otherwise
depsBuildBuild = [
buildPackages.stdenv.cc
]
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) pkgsBuildBuild.guile_2_0;
nativeBuildInputs = [
makeWrapper
pkg-config
];
buildInputs = [
readline
libtool
libunistring
libffi
];
propagatedBuildInputs = [
boehmgc
gmp
# These ones aren't normally needed here, but `libguile*.la' has '-l'
# flags for them without corresponding '-L' flags. Adding them here will
# add the needed `-L' flags. As for why the `.la' file lacks the `-L'
# flags, see below.
libtool
libunistring
];
enableParallelBuilding = true;
patches = [
# Small fixes to Clang compiler
./clang.patch
# Self-explanatory
./disable-gc-sensitive-tests.patch
# Read the header of the patch to more info
./eai_system.patch
# RISC-V endianness
./riscv.patch
# Fixes stability issues with 00-repl-server.test
(fetchpatch {
url = "https://git.savannah.gnu.org/cgit/guile.git/patch/?id=2fbde7f02adb8c6585e9baf6e293ee49cd23d4c4";
sha256 = "0p6c1lmw1iniq03z7x5m65kg3lq543kgvdb4nrxsaxjqf3zhl77v";
})
]
++ (lib.optional (coverageAnalysis != null) ./gcov-file-name.patch)
++ lib.optionals stdenv.hostPlatform.isDarwin [
./filter-mkostemp-darwin.patch
(fetchpatch {
url = "https://gitlab.gnome.org/GNOME/gtk-osx/raw/52898977f165777ad9ef169f7d4818f2d4c9b731/patches/guile-clocktime.patch";
sha256 = "12wvwdna9j8795x59ldryv9d84c1j3qdk2iskw09306idfsis207";
})
];
# Explicitly link against libgcc_s, to work around the infamous
# "libgcc_s.so.1 must be installed for pthread_cancel to work".
# don't have "libgcc_s.so.1" on darwin
LDFLAGS = lib.optionalString (
!stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isMusl
) "-lgcc_s";
configureFlags = [
"--with-libreadline-prefix"
]
++ lib.optionals stdenv.hostPlatform.isSunOS [
# Make sure the right <gmp.h> is found, and not the incompatible
# /usr/include/mp.h from OpenSolaris. See
# <https://lists.gnu.org/archive/html/hydra-users/2012-08/msg00000.html>
# for details.
"--with-libgmp-prefix=${lib.getDev gmp}"
# Same for these (?).
"--with-libreadline-prefix=${lib.getDev readline}"
"--with-libunistring-prefix=${libunistring}"
# See below.
"--without-threads"
];
postInstall = ''
wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin"
''
# XXX: See http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/18903 for
# why `--with-libunistring-prefix' and similar options coming from
# `AC_LIB_LINKFLAGS_BODY' don't work on NixOS/x86_64.
+ ''
sed -i "$out/lib/pkgconfig/guile"-*.pc \
-e "s|-lunistring|-L${libunistring}/lib -lunistring|g ;
s|^Cflags:\(.*\)$|Cflags: -I${libunistring.dev}/include \1|g ;
s|-lltdl|-L${libtool.lib}/lib -lltdl|g ;
s|includedir=$out|includedir=$dev|g
"
'';
# make check doesn't work on darwin
# On Linuxes+Hydra the tests are flaky; feel free to investigate deeper.
doCheck = false;
doInstallCheck = doCheck;
setupHook = ./setup-hook-2.0.sh;
passthru = rec {
effectiveVersion = lib.versions.majorMinor version;
siteCcacheDir = "lib/guile/${effectiveVersion}/site-ccache";
siteDir = "share/guile/site/${effectiveVersion}";
};
meta = with lib; {
homepage = "https://www.gnu.org/software/guile/";
description = "Embeddable Scheme implementation";
longDescription = ''
GNU Guile is an implementation of the Scheme programming language, with
support for many SRFIs, packaged for use in a wide variety of
environments. In addition to implementing the R5RS Scheme standard and
a large subset of R6RS, Guile includes a module system, full access to
POSIX system calls, networking support, multiple threads, dynamic
linking, a foreign function call interface, and powerful string
processing.
'';
license = licenses.lgpl3Plus;
maintainers = with maintainers; [ ludo ];
platforms = platforms.all;
};
}
//
(lib.optionalAttrs (!stdenv.hostPlatform.isLinux) {
# Work around <https://bugs.gnu.org/14201>.
SHELL = stdenv.shell;
CONFIG_SHELL = stdenv.shell;
})

View File

@@ -0,0 +1,150 @@
{
lib,
stdenv,
fetchurl,
fetchpatch,
boehmgc,
buildPackages,
coverageAnalysis ? null,
gawk,
gmp,
libffi,
libtool,
libunistring,
makeWrapper,
pkg-config,
pkgsBuildBuild,
readline,
}:
let
# Do either a coverage analysis build or a standard build.
builder = if coverageAnalysis != null then coverageAnalysis else stdenv.mkDerivation;
in
builder rec {
pname = "guile";
version = "2.2.7";
src = fetchurl {
url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz";
sha256 = "013mydzhfswqci6xmyc1ajzd59pfbdak15i0b090nhr9bzm7dxyd";
};
outputs = [
"out"
"dev"
"info"
];
setOutputFlags = false; # $dev gets into the library otherwise
depsBuildBuild = [
buildPackages.stdenv.cc
]
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) pkgsBuildBuild.guile_2_2;
nativeBuildInputs = [
makeWrapper
pkg-config
];
buildInputs = [
libffi
libtool
libunistring
readline
];
propagatedBuildInputs = [
boehmgc
gmp
# XXX: These ones aren't normally needed here, but `libguile*.la' has '-l'
# flags for them without corresponding '-L' flags. Adding them here will add
# the needed `-L' flags. As for why the `.la' file lacks the `-L' flags,
# see below.
libtool
libunistring
];
# According to Bernhard M. Wiedemann <bwiedemann suse de> on
# #reproducible-builds on irc.oftc.net, (2020-01-29): they had to
# build Guile without parallel builds to make it reproducible.
#
# re: https://issues.guix.gnu.org/issue/20272
# re: https://build.opensuse.org/request/show/732638
enableParallelBuilding = false;
patches = [
# Read the header of the patch to more info
./eai_system.patch
]
++ lib.optional (coverageAnalysis != null) ./gcov-file-name.patch
++ lib.optional stdenv.hostPlatform.isDarwin (fetchpatch {
url = "https://gitlab.gnome.org/GNOME/gtk-osx/raw/52898977f165777ad9ef169f7d4818f2d4c9b731/patches/guile-clocktime.patch";
sha256 = "12wvwdna9j8795x59ldryv9d84c1j3qdk2iskw09306idfsis207";
});
# Explicitly link against libgcc_s, to work around the infamous
# "libgcc_s.so.1 must be installed for pthread_cancel to work".
# don't have "libgcc_s.so.1" on clang
LDFLAGS = lib.optionalString (stdenv.cc.isGNU && !stdenv.hostPlatform.isStatic) "-lgcc_s";
configureFlags = [
"--with-libreadline-prefix=${lib.getDev readline}"
]
++ lib.optionals stdenv.hostPlatform.isSunOS [
# Make sure the right <gmp.h> is found, and not the incompatible
# /usr/include/mp.h from OpenSolaris. See
# <https://lists.gnu.org/archive/html/hydra-users/2012-08/msg00000.html>
# for details.
"--with-libgmp-prefix=${lib.getDev gmp}"
# Same for these (?).
"--with-libunistring-prefix=${libunistring}"
# See below.
"--without-threads"
];
postInstall = ''
wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin"
''
# XXX: See http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/18903 for
# why `--with-libunistring-prefix' and similar options coming from
# `AC_LIB_LINKFLAGS_BODY' don't work on NixOS/x86_64.
+ ''
sed -i "$out/lib/pkgconfig/guile"-*.pc \
-e "s|-lunistring|-L${libunistring}/lib -lunistring|g ;
s|^Cflags:\(.*\)$|Cflags: -I${libunistring.dev}/include \1|g ;
s|-lltdl|-L${libtool.lib}/lib -lltdl|g ;
s|includedir=$out|includedir=$dev|g
"
'';
# make check doesn't work on darwin
# On Linuxes+Hydra the tests are flaky; feel free to investigate deeper.
doCheck = false;
doInstallCheck = doCheck;
setupHook = ./setup-hook-2.2.sh;
passthru = rec {
effectiveVersion = lib.versions.majorMinor version;
siteCcacheDir = "lib/guile/${effectiveVersion}/site-ccache";
siteDir = "share/guile/site/${effectiveVersion}";
};
meta = with lib; {
homepage = "https://www.gnu.org/software/guile/";
description = "Embeddable Scheme implementation";
longDescription = ''
GNU Guile is an implementation of the Scheme programming language, with
support for many SRFIs, packaged for use in a wide variety of
environments. In addition to implementing the R5RS Scheme standard and a
large subset of R6RS, Guile includes a module system, full access to POSIX
system calls, networking support, multiple threads, dynamic linking, a
foreign function call interface, and powerful string processing.
'';
license = licenses.lgpl3Plus;
maintainers = with maintainers; [ ludo ];
platforms = platforms.all;
};
}

View File

@@ -0,0 +1,192 @@
{
lib,
stdenv,
fetchurl,
fetchpatch,
boehmgc,
buildPackages,
coverageAnalysis ? null,
gawk,
gmp,
libffi,
libtool,
libunistring,
libxcrypt,
makeWrapper,
pkg-config,
autoreconfHook,
pkgsBuildBuild,
readline,
writeScript,
}:
let
# Do either a coverage analysis build or a standard build.
builder = if coverageAnalysis != null then coverageAnalysis else stdenv.mkDerivation;
in
builder rec {
pname = "guile";
version = "3.0.10";
src = fetchurl {
url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz";
sha256 = "sha256-vXFoUX/VJjM0RtT3q4FlJ5JWNAlPvTcyLhfiuNjnY4g=";
};
outputs = [
"out"
"dev"
"info"
];
setOutputFlags = false; # $dev gets into the library otherwise
depsBuildBuild = [
buildPackages.stdenv.cc
]
++ lib.optional (
!lib.systems.equals stdenv.hostPlatform stdenv.buildPlatform
) pkgsBuildBuild.guile_3_0;
nativeBuildInputs = [
makeWrapper
pkg-config
]
++ lib.optional (!lib.systems.equals stdenv.hostPlatform stdenv.buildPlatform) autoreconfHook;
buildInputs = [
libffi
libtool
libunistring
readline
]
++ lib.optionals stdenv.hostPlatform.isLinux [
libxcrypt
];
propagatedBuildInputs = [
boehmgc
gmp
# These ones aren't normally needed here, but `libguile*.la' has '-l'
# flags for them without corresponding '-L' flags. Adding them here will
# add the needed `-L' flags. As for why the `.la' file lacks the `-L'
# flags, see below.
libtool
libunistring
]
++ lib.optionals stdenv.hostPlatform.isLinux [
libxcrypt
];
strictDeps = true;
# According to
# https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/guile.scm?h=a39207f7afd977e4e4299c6f0bb34bcb6d153818#n405
# starting with Guile 3.0.8, parallel builds can be done
# bit-reproducibly as long as we're not cross-compiling
enableParallelBuilding = lib.systems.equals stdenv.buildPlatform stdenv.hostPlatform;
patches = [
./eai_system.patch
]
# Fix cross-compilation, can be removed at next release (as well as the autoreconfHook)
# Include this only conditionally so we don't have to run the autoreconfHook for the native build.
++ lib.optional (!lib.systems.equals stdenv.hostPlatform stdenv.buildPlatform) (fetchpatch {
url = "https://cgit.git.savannah.gnu.org/cgit/guile.git/patch/?id=c117f8edc471d3362043d88959d73c6a37e7e1e9";
hash = "sha256-GFwJiwuU8lT1fNueMOcvHh8yvA4HYHcmPml2fY/HSjw=";
})
++ lib.optional (coverageAnalysis != null) ./gcov-file-name.patch
++ lib.optional stdenv.hostPlatform.isDarwin (fetchpatch {
url = "https://gitlab.gnome.org/GNOME/gtk-osx/raw/52898977f165777ad9ef169f7d4818f2d4c9b731/patches/guile-clocktime.patch";
sha256 = "12wvwdna9j8795x59ldryv9d84c1j3qdk2iskw09306idfsis207";
});
# Explicitly link against libgcc_s, to work around the infamous
# "libgcc_s.so.1 must be installed for pthread_cancel to work".
# don't have "libgcc_s.so.1" on clang
LDFLAGS = lib.optionalString (stdenv.cc.isGNU && !stdenv.hostPlatform.isStatic) "-lgcc_s";
configureFlags = [
"--with-libreadline-prefix=${lib.getDev readline}"
]
++ lib.optionals stdenv.hostPlatform.isSunOS [
# Make sure the right <gmp.h> is found, and not the incompatible
# /usr/include/mp.h from OpenSolaris. See
# <https://lists.gnu.org/archive/html/hydra-users/2012-08/msg00000.html>
# for details.
"--with-libgmp-prefix=${lib.getDev gmp}"
# Same for these (?).
"--with-libunistring-prefix=${libunistring}"
# See below.
"--without-threads"
]
# At least on x86_64-darwin '-flto' autodetection is not correct:
# https://github.com/NixOS/nixpkgs/pull/160051#issuecomment-1046193028
++ lib.optional (stdenv.hostPlatform.isDarwin) "--disable-lto";
postInstall = ''
wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin"
''
# XXX: See http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/18903 for
# why `--with-libunistring-prefix' and similar options coming from
# `AC_LIB_LINKFLAGS_BODY' don't work on NixOS/x86_64.
+ ''
sed -i "$out/lib/pkgconfig/guile"-*.pc \
-e "s|-lunistring|-L${libunistring}/lib -lunistring|g ;
s|-lltdl|-L${libtool.lib}/lib -lltdl|g ;
s|-lcrypt|-L${libxcrypt}/lib -lcrypt|g ;
s|^Cflags:\(.*\)$|Cflags: -I${libunistring.dev}/include \1|g ;
s|includedir=$out|includedir=$dev|g
"
'';
# make check doesn't work on darwin
# On Linuxes+Hydra the tests are flaky; feel free to investigate deeper.
doCheck = false;
doInstallCheck = doCheck;
# guile-3 uses ELF files to store bytecode. strip does not
# always handle them correctly and destroys the image:
# darwin: In procedure bytevector-u8-ref: Argument 2 out of range
# linux binutils-2.45: $ guile --version
# Pre-boot error; key: misc-error, args: ("load-thunk-from-memory" "missing DT_GUILE_ENTRY" () #f)Aborted
dontStrip = true;
setupHook = ./setup-hook-3.0.sh;
passthru = rec {
effectiveVersion = lib.versions.majorMinor version;
siteCcacheDir = "lib/guile/${effectiveVersion}/site-ccache";
siteDir = "share/guile/site/${effectiveVersion}";
updateScript = writeScript "update-guile-3" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl pcre common-updater-scripts
set -eu -o pipefail
# Expect the text in format of '"https://ftp.gnu.org/gnu/guile/guile-3.0.8.tar.gz"'
new_version="$(curl -s https://www.gnu.org/software/guile/download/ |
pcregrep -o1 '"https://ftp.gnu.org/gnu/guile/guile-(3[.0-9]+).tar.gz"')"
update-source-version guile_3_0 "$new_version"
'';
};
meta = with lib; {
homepage = "https://www.gnu.org/software/guile/";
description = "Embeddable Scheme implementation";
longDescription = ''
GNU Guile is an implementation of the Scheme programming language, with
support for many SRFIs, packaged for use in a wide variety of
environments. In addition to implementing the R5RS Scheme standard and a
large subset of R6RS, Guile includes a module system, full access to POSIX
system calls, networking support, multiple threads, dynamic linking, a
foreign function call interface, and powerful string processing.
'';
license = licenses.lgpl3Plus;
maintainers = [ ];
platforms = platforms.all;
};
}

View File

@@ -0,0 +1,59 @@
commit d514e3fc42eb14a1bc5846b27ef89f50ba3a5d48
Author: Ludovic Courtès <ludo@gnu.org>
Date: Tue Oct 11 10:14:26 2016 +0200
Remove 'umask' calls from 'mkdir'.
Fixes <http://bugs.gnu.org/24659>.
* libguile/filesys.c (SCM_DEFINE): Remove calls to 'umask' when MODE is
unbound; instead, use 0777 as the mode. Update docstring to clarify
this.
diff --git a/libguile/filesys.c b/libguile/filesys.c
index c8acb13ef..921f765f1 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996,1997,1998,1999,2000,2001, 2002, 2004, 2006, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006,
+ * 2009, 2010, 2011, 2012, 2013, 2014, 2016 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -791,26 +792,21 @@ SCM_DEFINE (scm_delete_file, "delete-file", 1, 0, 0,
SCM_DEFINE (scm_mkdir, "mkdir", 1, 1, 0,
(SCM path, SCM mode),
"Create a new directory named by @var{path}. If @var{mode} is omitted\n"
- "then the permissions of the directory file are set using the current\n"
- "umask. Otherwise they are set to the decimal value specified with\n"
- "@var{mode}. The return value is unspecified.")
+ "then the permissions of the directory are set to @code{#o777}\n"
+ "masked with the current umask (@pxref{Processes, @code{umask}}).\n"
+ "Otherwise they are set to the value specified with @var{mode}.\n"
+ "The return value is unspecified.")
#define FUNC_NAME s_scm_mkdir
{
int rv;
- mode_t mask;
+ mode_t c_mode;
- if (SCM_UNBNDP (mode))
- {
- mask = umask (0);
- umask (mask);
- STRING_SYSCALL (path, c_path, rv = mkdir (c_path, 0777 ^ mask));
- }
- else
- {
- STRING_SYSCALL (path, c_path, rv = mkdir (c_path, scm_to_uint (mode)));
- }
+ c_mode = SCM_UNBNDP (mode) ? 0777 : scm_to_uint (mode);
+
+ STRING_SYSCALL (path, c_path, rv = mkdir (c_path, c_mode));
if (rv != 0)
SCM_SYSERROR;
+
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME

View File

@@ -0,0 +1,14 @@
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index 889bca7..15d39b0 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -74,7 +74,8 @@
in <inttypes.h> would reinclude us, skipping our contents because
_@GUARD_PREFIX@_STDINT_H is defined.
The include_next requires a split double-inclusion guard. */
-# @INCLUDE_NEXT@ @NEXT_STDINT_H@
+# include <inttypes.h>
+// # @INCLUDE_NEXT@ @NEXT_STDINT_H@
#endif
#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H

View File

@@ -0,0 +1,24 @@
Fix doc snarfing with GCC 4.5.
From <http://git.savannah.gnu.org/cgit/guile.git/commit/?h=branch_release-1-8&id=aac41d28358cea594bb30f6e547afb82bb6004a6>.
diff --git a/scripts/snarf-check-and-output-texi b/scripts/snarf-check-and-output-texi
index ea33e17..8cd42e8 100755
--- a/scripts/snarf-check-and-output-texi
+++ b/scripts/snarf-check-and-output-texi
@@ -267,6 +267,17 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@"
(set! *file* file)
(set! *line* line))
+ ;; newer gccs like to throw around more location markers into the
+ ;; preprocessed source; these (hash . hash) bits are what they translate to
+ ;; in snarfy terms.
+ (('location ('string . file) ('int . line) ('hash . 'hash))
+ (set! *file* file)
+ (set! *line* line))
+
+ (('location ('hash . 'hash) ('string . file) ('int . line) ('hash . 'hash))
+ (set! *file* file)
+ (set! *line* line))
+
(('arglist rest ...)
(set! *args* (do-arglist rest)))

View File

@@ -0,0 +1,25 @@
This patch disable GC-sensitive tests. This is particularly useful when
compiling with `-O0' (as is done with coverage analysis) since there may
be many false references held on the stack, leading to the failure of
such tests.
--- a/test-suite/tests/gc.test
+++ b/test-suite/tests/gc.test
@@ -67,6 +67,7 @@
(with-test-prefix "gc"
(pass-if "Unused modules are removed"
+ (throw 'unresolved)
(let* ((guard (make-guardian))
(total 1000))
--- a/test-suite/tests/threads.test
+++ b/test-suite/tests/threads.test
@@ -366,6 +366,7 @@
(not (mutex-owner m))))
(pass-if "mutex with owner not retained (bug #27450)"
+ (throw 'unresolved)
(let ((g (make-guardian)))
(g (let ((m (make-mutex))) (lock-mutex m) m))

View File

@@ -0,0 +1,24 @@
Building nixpkgs in non-chroot, NSS modules may fail
and that will report EAI_SYSTEM in getaddrinfo.
https://bugzilla.novell.com/show_bug.cgi?id=794696
Index: guile-2.0.7/test-suite/tests/net-db.test
===================================================================
--- guile-2.0.7.orig/test-suite/tests/net-db.test
+++ guile-2.0.7/test-suite/tests/net-db.test
@@ -79,6 +79,7 @@
(and (defined? 'EAI_NODATA) ; GNU extension
(= errcode EAI_NODATA))
(= errcode EAI_AGAIN)
+ (= errcode EAI_SYSTEM)
(begin
(format #t "unexpected error code: ~a ~s~%"
errcode (gai-strerror errcode))
@@ -105,6 +106,7 @@
;; `EAI_NONAME'.)
(and (or (= errcode EAI_SERVICE)
(= errcode EAI_NONAME)
+ (= errcode EAI_SYSTEM)
(and (defined? 'EAI_NODATA)
(= errcode EAI_NODATA)))
(string? (gai-strerror errcode))))))))

View File

@@ -0,0 +1,28 @@
Filter incompat. mkostemp(3) flags on macOS 10.12
macOS Sierra introduces a mkostemp(3) function which is used when
present. Contrary to the GNUlib version of mkostemp(3) that was used
previously, this version fails with 'invalid argument' when flags other
than from a specified set are passed. From mktemp(3):
| The mkostemp() function is like mkstemp() but allows specifying
| additional open(2) flags (defined in <fcntl.h>). The permitted flags
| are O_APPEND, O_SHLOCK, O_EXLOCK and O_CLOEXEC.
Signed-off-by: Clemens Lang <cal@macports.org>
Upstream-Status: Submitted [https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24862#23]
--- a/libguile/filesys.c.orig 2017-01-09 00:53:27.000000000 +0100
+++ b/libguile/filesys.c 2017-01-09 00:54:48.000000000 +0100
@@ -1486,6 +1486,12 @@
mode_bits = scm_i_mode_bits (mode);
}
+#ifdef __APPLE__
+ /* macOS starting with 10.12 defines mkostemp(2) which is used if defined,
+ * but only accepts some flags according to its manpage. It fails with
+ * invalid argument when other flags are passed. */
+ open_flags &= O_APPEND | O_SHLOCK | O_EXLOCK | O_CLOEXEC;
+#endif
SCM_SYSCALL (rv = mkostemp (c_tmpl, open_flags));
if (rv == -1)
SCM_SYSERROR;

View File

@@ -0,0 +1,42 @@
This patch arranges so that we don't end up, with profiling builds, with a
file named `<stdout>.gcov' since that confuses lcov:
<stdout>:cannot open source file
geninfo: ERROR: cannot read <stdout>.gcov!
--- guile/libguile/c-tokenize.c 2009-09-13 13:05:15.000000000 +0200
+++ guile/libguile/c-tokenize.c 2009-10-28 16:24:15.000000000 +0100
@@ -1,5 +1,5 @@
-#line 3 "<stdout>"
+#line 3 "c-tokenize.c"
#define YY_INT_ALIGNED short int
@@ -616,7 +616,7 @@ int cookie_was_last = 0;
#define IS_COOKIE cookie_was_last = 1
#define IS_NOT_COOKIE cookie_was_last = 0
-#line 620 "<stdout>"
+#line 620 "c-tokenize.c"
#define INITIAL 0
@@ -799,7 +799,7 @@ YY_DECL
#line 65 "./c-tokenize.lex"
-#line 803 "<stdout>"
+#line 803 "c-tokenize.c"
if ( !(yy_init) )
{
@@ -1235,7 +1235,7 @@ YY_RULE_SETUP
#line 181 "./c-tokenize.lex"
ECHO;
YY_BREAK
-#line 1239 "<stdout>"
+#line 1239 "c-tokenize.c"
case YY_STATE_EOF(INITIAL):
yyterminate();

View File

@@ -0,0 +1,13 @@
diff --git a/module/system/base/target.scm b/module/system/base/target.scm
index 95ab8d8c9..93616f4a3 100644
--- a/module/system/base/target.scm
+++ b/module/system/base/target.scm
@@ -86,6 +86,8 @@
(endianness big))
((string=? "aarch64" cpu)
(endianness little))
+ ((string-match "riscv[1-9][0-9]*" cpu)
+ (endianness little))
(else
(error "unknown CPU endianness" cpu)))))

View File

@@ -0,0 +1,7 @@
addGuileLibPath () {
if test -d "$1/share/guile/site"; then
addToSearchPath GUILE_LOAD_PATH "$1/share/guile/site"
fi
}
addEnvHooks "$hostOffset" addGuileLibPath

View File

@@ -0,0 +1,19 @@
addGuileLibPath () {
if test -d "$1/share/guile/site/2.0"; then
addToSearchPath GUILE_LOAD_PATH "$1/share/guile/site/2.0"
addToSearchPath GUILE_LOAD_COMPILED_PATH "$1/share/guile/site/2.0"
elif test -d "$1/share/guile/site"; then
addToSearchPath GUILE_LOAD_PATH "$1/share/guile/site"
addToSearchPath GUILE_LOAD_COMPILED_PATH "$1/share/guile/site"
fi
if test -d "$1/lib/guile/2.0/ccache"; then
addToSearchPath GUILE_LOAD_COMPILED_PATH "$1/lib/guile/2.0/ccache"
fi
if test -d "$1/lib/guile/2.0/site-ccache"; then
addToSearchPath GUILE_LOAD_COMPILED_PATH "$1/lib/guile/2.0/site-ccache"
fi
}
addEnvHooks "$hostOffset" addGuileLibPath

View File

@@ -0,0 +1,19 @@
addGuileLibPath () {
if test -d "$1/share/guile/site/2.2"; then
addToSearchPath GUILE_LOAD_PATH "$1/share/guile/site/2.2"
addToSearchPath GUILE_LOAD_COMPILED_PATH "$1/share/guile/site/2.2"
elif test -d "$1/share/guile/site"; then
addToSearchPath GUILE_LOAD_PATH "$1/share/guile/site"
addToSearchPath GUILE_LOAD_COMPILED_PATH "$1/share/guile/site"
fi
if test -d "$1/lib/guile/2.2/ccache"; then
addToSearchPath GUILE_LOAD_COMPILED_PATH "$1/lib/guile/2.2/ccache"
fi
if test -d "$1/lib/guile/2.2/site-ccache"; then
addToSearchPath GUILE_LOAD_COMPILED_PATH "$1/lib/guile/2.2/site-ccache"
fi
}
addEnvHooks "$hostOffset" addGuileLibPath

View File

@@ -0,0 +1,25 @@
addGuileLibPath () {
if test -d "$1/share/guile/site/3.0"; then
addToSearchPath GUILE_LOAD_PATH "$1/share/guile/site/3.0"
addToSearchPath GUILE_LOAD_COMPILED_PATH "$1/share/guile/site/3.0"
addToSearchPath GUILE_EXTENSIONS_PATH "$1/share/guile/site/3.0"
elif test -d "$1/share/guile/site"; then
addToSearchPath GUILE_LOAD_PATH "$1/share/guile/site"
addToSearchPath GUILE_LOAD_COMPILED_PATH "$1/share/guile/site"
addToSearchPath GUILE_EXTENSIONS_PATH "$1/share/guile/site"
fi
if test -d "$1/lib/guile/3.0/ccache"; then
addToSearchPath GUILE_LOAD_COMPILED_PATH "$1/lib/guile/3.0/ccache"
fi
if test -d "$1/lib/guile/3.0/site-ccache"; then
addToSearchPath GUILE_LOAD_COMPILED_PATH "$1/lib/guile/3.0/site-ccache"
fi
if test -d "$1/lib/guile/3.0/extensions"; then
addToSearchPath GUILE_EXTENSIONS_PATH "$1/lib/guile/3.0/extensions"
fi
}
addEnvHooks "$hostOffset" addGuileLibPath

View File

@@ -0,0 +1,77 @@
{
lib,
stdenv,
fetchFromGitHub,
meson,
ninja,
nix-update-script,
runCommand,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "janet";
version = "1.39.1";
src = fetchFromGitHub {
owner = "janet-lang";
repo = "janet";
rev = "v${finalAttrs.version}";
hash = "sha256-Hd8DueT9f7vmK0QFJdRx7FgZ8BYh5prQyM++5Yb6tg4=";
};
postPatch = ''
substituteInPlace janet.1 \
--replace /usr/local/ $out/
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
# error: Socket is not connected
substituteInPlace meson.build \
--replace "'test/suite-ev.janet'," ""
'';
nativeBuildInputs = [
meson
ninja
];
mesonBuildType = "release";
mesonFlags = [ "-Dgit_hash=release" ];
doCheck = true;
doInstallCheck = true;
installCheckPhase = ''
$out/bin/janet -e '(+ 1 2 3)'
'';
passthru = {
tests.run =
runCommand "janet-test-run"
{
nativeBuildInputs = [ finalAttrs.finalPackage ];
}
''
echo "(+ 1 2 3)" | janet | tail -n 1 > arithmeticTest.txt;
diff -U3 --color=auto <(cat arithmeticTest.txt) <(echo "6");
echo "(print \"Hello, World!\")" | janet | tail -n 2 > ioTest.txt;
diff -U3 --color=auto <(cat ioTest.txt) <(echo -e "Hello, World!\nnil");
touch $out;
'';
updateScript = nix-update-script { };
};
meta = with lib; {
description = "Janet programming language";
mainProgram = "janet";
homepage = "https://janet-lang.org/";
license = licenses.mit;
maintainers = with maintainers; [
andrewchambers
peterhoeg
];
platforms = platforms.all;
};
})

View File

@@ -0,0 +1,65 @@
{
lib,
stdenv,
fetchFromGitHub,
janet,
}:
let
platformFiles = {
aarch64-darwin = "macos_config.janet";
aarch64-linux = "linux_config.janet";
x86_64-darwin = "macos_config.janet";
x86_64-linux = "linux_config.janet";
};
platformFile = platformFiles.${stdenv.hostPlatform.system};
in
stdenv.mkDerivation rec {
pname = "jpm";
version = "1.1.0";
src = fetchFromGitHub {
owner = "janet-lang";
repo = "jpm";
rev = "v${version}";
sha256 = "sha256-lPB4jew6RkJlDp8xOQ4YA9MkgLBImaBHcvv4WF/sLRc=";
};
# `auto-shebangs true` gives us a shebang line that points to janet inside the
# jpm bin folder
postPatch = ''
substituteInPlace configs/${platformFile} \
--replace 'auto-shebang true' 'auto-shebang false' \
--replace /usr/local $out
'';
dontConfigure = true;
buildInputs = [ janet ];
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/{lib/janet,share/man/man1}
janet bootstrap.janet configs/${platformFile}
runHook postInstall
'';
doInstallCheck = true;
installCheckPhase = ''
$out/bin/jpm help
'';
meta = janet.meta // {
description = "Janet Project Manager for the Janet programming language";
mainProgram = "jpm";
platforms = lib.attrNames platformFiles;
};
}

View File

@@ -0,0 +1,82 @@
{
lib,
stdenv,
callPackage,
fetchurl,
gitUpdater,
mkRubyVersion,
makeBinaryWrapper,
jre,
}:
let
# The version number here is whatever is reported by the RUBY_VERSION string
rubyVersion = mkRubyVersion "3" "1" "4" "";
in
stdenv.mkDerivation (finalAttrs: {
pname = "jruby";
version = "10.0.0.0";
src = fetchurl {
url = "https://s3.amazonaws.com/jruby.org/downloads/${finalAttrs.version}/jruby-bin-${finalAttrs.version}.tar.gz";
hash = "sha256-Qn2YJ+0j/mtNEf5hZlx13XR2ujagQ4N26zEM4qjSRzM=";
};
nativeBuildInputs = [ makeBinaryWrapper ];
installPhase = ''
mkdir -pv $out/share/jruby/docs
mv * $out
rm $out/bin/*.{bat,dll,exe,sh}
mv $out/samples $out/share/jruby/
mv $out/BSDL $out/COPYING $out/LEGAL $out/LICENSE* $out/share/jruby/docs/
for i in $out/bin/jruby; do
wrapProgram $i \
--set JAVA_HOME ${jre.home}
done
ln -s $out/bin/jruby $out/bin/ruby
# Bundler tries to create this directory
mkdir -pv $out/${finalAttrs.passthru.gemPath}
mkdir -p $out/nix-support
cat > $out/nix-support/setup-hook <<EOF
addGemPath() {
addToSearchPath GEM_PATH \$1/${finalAttrs.passthru.gemPath}
}
addEnvHooks "$hostOffset" addGemPath
EOF
'';
postFixup = ''
PATH=$out/bin:$PATH patchShebangs $out/bin
'';
passthru = rec {
rubyEngine = "jruby";
gemPath = "lib/${rubyEngine}/gems/${rubyVersion.libDir}";
libPath = "lib/${rubyEngine}/${rubyVersion.libDir}";
devEnv = callPackage ../ruby/dev.nix {
ruby = finalAttrs.finalPackage;
};
updateScript = gitUpdater {
url = "https://github.com/jruby/jruby.git";
};
};
meta = with lib; {
description = "Ruby interpreter written in Java";
homepage = "https://www.jruby.org/";
changelog = "https://github.com/jruby/jruby/releases/tag/${finalAttrs.version}";
license = with licenses; [
cpl10
gpl2
lgpl21
];
platforms = jre.meta.platforms;
maintainers = [ maintainers.fzakaria ];
sourceProvenance = with sourceTypes; [ binaryBytecode ];
};
})

View File

@@ -0,0 +1,102 @@
{
lib,
stdenv,
fetchFromGitHub,
libedit,
zlib,
ncurses,
expect,
}:
stdenv.mkDerivation rec {
pname = "kerf";
version = "unstable-2022-08-05";
src = fetchFromGitHub {
owner = "kevinlawler";
repo = "kerf1";
rev = "4ec5b592b310b96d33654d20d6a511e6fffc0f9d";
hash = "sha256-0sU2zOk5I69lQyrn1g0qsae7S/IBT6eA/911qp0GNkk=";
};
sourceRoot = "${src.name}/src";
buildInputs = [
libedit
zlib
ncurses
];
nativeCheckInputs = [ expect ];
doCheck = true;
makeFlags = [
"kerf"
"kerf_test"
];
# avoid a huge amount of warnings to make failures clearer
env.NIX_CFLAGS_COMPILE = toString (
map (x: "-Wno-${x}") [
"void-pointer-to-int-cast"
"format"
"implicit-function-declaration"
"gnu-variable-sized-type-not-at-end"
"unused-result"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [ "-fcommon" ]
);
patchPhase = ''
substituteInPlace ./Makefile \
--replace 'CPUS ?=' 'CPUS = $(NIX_BUILD_CORES) #' \
--replace 'termcap' 'ncurses'
'';
# the kerf executable uses ncurses to create a fancy terminal for input and
# reads terminal keystrokes directly, so it doesn't read from stdin as
# expected, hence why we use this fancy expect script to run the test exe and
# send 'quit' to the prompt after it finishes.
checkPhase = ''
expect <<EOD
set timeout 60
spawn ./kerf_test
expect {
"Passed" {}
"Failed" { exit 1 }
timeout { exit 1 }
}
expect {
"KeRF> " {send "quit\r"}
timeout { exit 1 }
}
expect {
"\[DEBUG\] OK: Done OK." {}
"\[DEBUG\] FAILED: Debug failure." { exit 1 }
timeout { exit 1 }
}
exit 0
EOD
'';
installPhase = "install -D kerf $out/bin/kerf";
meta = with lib; {
description = "Columnar tick database and time-series language";
mainProgram = "kerf";
longDescription = ''
Kerf is a columnar tick database and small programming
language that is a superset of JSON and SQL. It can be
used for local analytics, timeseries, logfile processing,
and more.
'';
license = with licenses; [ bsd2 ];
homepage = "https://github.com/kevinlawler/kerf1";
platforms = platforms.unix;
maintainers = with maintainers; [ thoughtpolice ];
# aarch64-linux seems hopeless, with over 2,000 warnings
# generated?
broken = (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64);
};
}

View File

@@ -0,0 +1,13 @@
diff --git a/Makefile b/Makefile
index 59f2c06..5ee8f6e 100644
--- a/Makefile
+++ b/Makefile
@@ -60,7 +60,7 @@ ESRCS = $(notdir $(wildcard $(SRCDIR)/*.erl))
XSRCS = $(notdir $(wildcard $(SRCDIR)/*.xrl))
YSRCS = $(notdir $(wildcard $(SRCDIR)/*.yrl))
LSRCS = $(notdir $(wildcard $(LSRCDIR)/*.lfe))
-EBINS = $(ESRCS:.erl=.beam) $(XSRCS:.xrl=.beam) $(YSRCS:.yrl=.beam)
+EBINS = $(sort $(ESRCS:.erl=.beam) $(XSRCS:.xrl=.beam) $(YSRCS:.yrl=.beam))
LBINS = $(LSRCS:.lfe=.beam)
CSRCS = $(notdir $(wildcard $(CSRCDIR)/*.c))

View File

@@ -0,0 +1,111 @@
{
bash,
buildHex,
buildRebar3,
config,
coreutils,
erlang,
fetchFromGitHub,
lib,
makeWrapper,
}:
let
inherit (lib)
assertMsg
makeBinPath
getVersion
versionAtLeast
versions
;
version = "2.2.0";
hash = "sha256-47lEUVU9Api1Yj1q+Ch8aIV8kaALhst1ty8RHTwMVcI=";
maximumOTPVersion = "27";
mainVersion = versions.major (getVersion erlang);
maxAssert = versionAtLeast maximumOTPVersion mainVersion;
proper = buildHex {
name = "proper";
version = "1.4.0";
sha256 = "sha256-GChYQhhb0z772pfRNKXLWgiEOE2zYRn+4OPPpIhWjLs=";
};
in
if !config.allowAliases && !maxAssert then
# Don't throw without aliases to not break CI.
null
else
assert assertMsg maxAssert ''
LFE ${version} is supported on OTP <=${maximumOTPVersion}, not ${mainVersion}.
'';
buildRebar3 {
name = "lfe";
inherit version;
src = fetchFromGitHub {
owner = "lfe";
repo = "lfe";
tag = "v${version}";
inherit hash;
};
patches = [
./fix-rebar-config.patch
./dedup-ebins.patch
];
nativeBuildInputs = [
makeWrapper
erlang
];
beamDeps = [ proper ];
makeFlags = [
"-e"
"MANDB=''"
"PREFIX=$$out"
];
# override buildRebar3's install to let the builder use make install
installPhase = "";
doCheck = true;
checkTarget = "travis";
postFixup = ''
# LFE binaries are shell scripts which run erl and lfe.
# Add some stuff to PATH so the scripts can run without problems.
for f in $out/bin/*; do
wrapProgram $f \
--prefix PATH ":" "${
makeBinPath [
erlang
coreutils
bash
]
}:$out/bin"
substituteInPlace $f --replace "/usr/bin/env" "${coreutils}/bin/env"
done
'';
meta = with lib; {
description = "Best of Erlang and of Lisp; at the same time";
longDescription = ''
LFE, Lisp Flavoured Erlang, is a lisp syntax front-end to the Erlang
compiler. Code produced with it is compatible with "normal" Erlang
code. An LFE evaluator and shell is also included.
'';
homepage = "https://lfe.io";
downloadPage = "https://github.com/lfe/lfe/releases";
changelog = "https://github.com/lfe/lfe/releases/tag/v${version}";
license = licenses.asl20;
teams = [ teams.beam ];
platforms = platforms.unix;
};
}

View File

@@ -0,0 +1,24 @@
diff --git a/rebar.config b/rebar.config
index 1204a6f..7e2c102 100644
--- a/rebar.config
+++ b/rebar.config
@@ -23,16 +23,16 @@
{pre_hooks, [{"(linux|darwin|solaris|freebsd|netbsd|openbsd)", ct,
"bin/lfescript bin/lfec"
- " -o $REBAR_DEPS_DIR/lfe/test"
+ " -o test"
" test/*_SUITE.lfe"},
{"(linux|darwin|solaris|freebsd|netbsd|openbsd)", eunit,
"bin/lfescript bin/lfec"
- " -o $REBAR_DEPS_DIR/lfe/ebin"
+ " -o ebin"
" test/clj-tests.lfe test/maps-tests.lfe"},
%% TODO: Test this on a win32 box
%% {"win32", ct,
%% "bin/lfescript bin/lfec -o $REBAR_DEPS_DIR/lfe/test test/*_SUITE.lfe"}
{"(linux|darwin|solaris|freebsd|netbsd|openbsd)", app_compile,
- "bin/lfescript bin/lfec -o $REBAR_DEPS_DIR/lfe/ebin src/*.lfe"}
+ "bin/lfescript bin/lfec -o ebin src/*.lfe"}
%% TODO: equivalent win32 hook
]}.

View File

@@ -0,0 +1,75 @@
{
lib,
stdenv,
fetchFromGitHub,
pkg-config,
SDL2,
libGLU,
libGL,
openal,
luajit,
freetype,
physfs,
libmodplug,
mpg123,
libvorbis,
libogg,
libtheora,
which,
autoconf,
automake,
libtool,
xorg,
}:
stdenv.mkDerivation rec {
pname = "love";
version = "0.10.2";
src = fetchFromGitHub {
owner = "love2d";
repo = "love";
rev = version;
sha256 = "19yfmlcx6w8yi4ndm5lni8lrsvnn77bxw5py0dc293nzzlaqa9ym";
};
nativeBuildInputs = [
pkg-config
autoconf
automake
];
buildInputs = [
SDL2
xorg.libX11 # SDl2 optional depend, for SDL_syswm.h
libGLU
libGL
openal
luajit
freetype
physfs
libmodplug
mpg123
libvorbis
libogg
libtheora
which
libtool
];
preConfigure = "$shell ./platform/unix/automagic";
configureFlags = [
"--with-lua=luajit"
];
env.NIX_CFLAGS_COMPILE = "-DluaL_reg=luaL_Reg"; # needed since luajit-2.1.0-beta3
meta = {
homepage = "https://love2d.org";
description = "Lua-based 2D game engine/scripting language";
mainProgram = "love";
license = lib.licenses.zlib;
platforms = lib.platforms.linux;
maintainers = [ lib.maintainers.raskin ];
};
}

View File

@@ -0,0 +1,94 @@
{
lib,
stdenv,
fetchFromGitHub,
pkg-config,
SDL2,
libGLU,
libGL,
openal,
luajit,
lua5_1,
freetype,
physfs,
libmodplug,
mpg123,
libvorbis,
libogg,
libtheora,
which,
autoconf,
automake,
libtool,
xorg,
}:
stdenv.mkDerivation rec {
pname = "love";
version = "11.5";
src = fetchFromGitHub {
owner = "love2d";
repo = "love";
rev = version;
sha256 = "sha256-wZktNh4UB3QH2wAIIlnYUlNoXbjEDwUmPnT4vesZNm0=";
};
nativeBuildInputs = [
pkg-config
autoconf
automake
];
buildInputs = [
SDL2
openal
(if stdenv.isDarwin then lua5_1 else luajit)
freetype
physfs
libmodplug
mpg123
libvorbis
libogg
libtheora
which
libtool
]
++ lib.optionals stdenv.isLinux [
xorg.libX11 # SDL2 optional depend, for SDL_syswm.h
libGLU
libGL
];
preConfigure = "$shell ./platform/unix/automagic";
configureFlags = [
(if stdenv.isDarwin then "--with-lua=lua" else "--with-lua=luajit")
];
env.NIX_CFLAGS_COMPILE = "-DluaL_reg=luaL_Reg"; # needed since luajit-2.1.0-beta3
# Fix Darwin bundle/dylib linking and macOS function calls
preBuild = lib.optionalString stdenv.isDarwin ''
# Fix libtool to use dynamiclib instead of bundle for Darwin
substituteInPlace libtool \
--replace "-bundle" "-dynamiclib" \
--replace "-Wl,-bundle" "-Wl,-dynamiclib"
substituteInPlace src/love.cpp \
--replace "love::macosx::checkDropEvents()" "std::string(\"\")" \
--replace "love::macosx::getLoveInResources()" "std::string(\"\")"
'';
postFixup = lib.optionalString stdenv.isDarwin ''
install_name_tool -change ".libs/liblove-11.5.so" "$out/lib/liblove-11.5.so" "$out/bin/love"
'';
meta = {
homepage = "https://love2d.org";
description = "Lua-based 2D game engine/scripting language";
mainProgram = "love";
license = lib.licenses.zlib;
platforms = lib.platforms.linux ++ lib.platforms.darwin;
maintainers = [ lib.maintainers.raskin ];
};
}

View File

@@ -0,0 +1,52 @@
diff --git a/Makefile b/Makefile
index 209a132..9387b09 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,7 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
# What to install.
TO_BIN= lua luac
TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
-TO_LIB= liblua.a
+TO_LIB= liblua.5.1.5.dylib
TO_MAN= lua.1 luac.1
# Lua version and release.
@@ -64,6 +64,8 @@ install: dummy
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
+ ln -s -f liblua.5.1.5.dylib $(INSTALL_LIB)/liblua.5.1.dylib
+ ln -s -f liblua.5.1.dylib $(INSTALL_LIB)/liblua.dylib
ranlib:
cd src && cd $(INSTALL_LIB) && $(RANLIB) $(TO_LIB)
diff --git a/src/Makefile b/src/Makefile
index e0d4c9f..4477d7b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -22,7 +22,7 @@ MYLIBS=
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
-LUA_A= liblua.a
+LUA_A= liblua.5.1.5.dylib
CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
lundump.o lvm.o lzio.o
@@ -48,11 +48,13 @@ o: $(ALL_O)
a: $(ALL_A)
$(LUA_A): $(CORE_O) $(LIB_O)
- $(AR) $@ $(CORE_O) $(LIB_O) # DLL needs all object files
- $(RANLIB) $@
+ $(CC) -dynamiclib -install_name $(out)/lib/liblua.5.1.dylib \
+ -compatibility_version 5.1 -current_version 5.1.5 \
+ -o liblua.5.1.5.dylib $^
$(LUA_T): $(LUA_O) $(LUA_A)
- $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
+ $(CC) -fno-common $(MYLDFLAGS) \
+ -o $@ $(LUA_O) $(LUA_A) -L. -llua.5.1.5 $(LIBS)
$(LUAC_T): $(LUAC_O) $(LUA_A)
$(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)

View File

@@ -0,0 +1,52 @@
diff --git a/Makefile b/Makefile
index d2c7db4..dc107b3 100644
--- a/Makefile
+++ b/Makefile
@@ -41,7 +41,7 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
# What to install.
TO_BIN= lua luac
TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
-TO_LIB= liblua.a
+TO_LIB= liblua.${pkgversion}.dylib
TO_MAN= lua.1 luac.1
# Lua version and release.
@@ -63,6 +63,8 @@ install: dummy
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
+ ln -s -f liblua.${pkgversion}.dylib $(INSTALL_LIB)/liblua.${luaversion}.dylib
+ ln -s -f liblua.${luaversion}.dylib $(INSTALL_LIB)/liblua.dylib
uninstall:
cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN)
diff --git a/src/Makefile b/src/Makefile
index 7b4b2b7..25001e5 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -28,7 +28,7 @@ MYOBJS=
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
-LUA_A= liblua.a
+LUA_A= liblua.${pkgversion}.dylib
CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
ltm.o lundump.o lvm.o lzio.o
@@ -56,11 +56,13 @@ o: $(ALL_O)
a: $(ALL_A)
$(LUA_A): $(BASE_O)
- $(AR) $@ $(BASE_O)
- $(RANLIB) $@
+ $(CC) -dynamiclib -install_name $(out)/lib/liblua.${pkgversion}.dylib \
+ -compatibility_version ${pkgversion} -current_version ${pkgversion} \
+ -o liblua.${pkgversion}.dylib $^
$(LUA_T): $(LUA_O) $(LUA_A)
- $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
+ $(CC) -fno-common $(MYLDFLAGS) \
+ -o $@ $(LUA_O) $(LUA_A) -L. -llua.${pkgversion} $(LIBS)
$(LUAC_T): $(LUAC_O) $(LUA_A)
$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)

View File

@@ -0,0 +1,48 @@
--- a/Makefile 2021-05-14 22:39:14.407200562 +0300
+++ b/Makefile 2021-05-14 22:36:23.828513407 +0300
@@ -41,7 +41,7 @@
# What to install.
TO_BIN= lua luac
TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
-TO_LIB= liblua.a
+TO_LIB= liblua.${pkgversion}.dylib
TO_MAN= lua.1 luac.1
# Lua version and release.
@@ -60,6 +60,8 @@
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
+ ln -s -f liblua.${pkgversion}.dylib $(INSTALL_LIB)/liblua.${luaversion}.dylib
+ ln -s -f liblua.${luaversion}.dylib $(INSTALL_LIB)/liblua.dylib
uninstall:
cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN)
--- a/src/Makefile 2021-05-14 22:35:38.575051882 +0300
+++ b/src/Makefile 2021-05-14 22:35:33.584631206 +0300
@@ -32,7 +32,7 @@
PLATS= guess aix bsd c89 freebsd generic linux linux-readline macosx mingw posix solaris
-LUA_A= liblua.a
+LUA_A= liblua.${pkgversion}.dylib
CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o
LIB_O= lauxlib.o lbaselib.o lcorolib.o ldblib.o liolib.o lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o linit.o
BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS)
@@ -57,11 +57,13 @@
a: $(ALL_A)
$(LUA_A): $(BASE_O)
- $(AR) $@ $(BASE_O)
- $(RANLIB) $@
+ $(CC) -dynamiclib -install_name $(out)/lib/liblua.${pkgversion}.dylib \
+ -compatibility_version ${pkgversion} -current_version ${pkgversion} \
+ -o liblua.${pkgversion}.dylib $^
$(LUA_T): $(LUA_O) $(LUA_A)
- $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
+ $(CC) -fno-common $(MYLDFLAGS) \
+ -o $@ $(LUA_O) $(LUA_A) -L. -llua.${pkgversion} $(LIBS)
$(LUAC_T): $(LUAC_O) $(LUA_A)
$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)

View File

@@ -0,0 +1,21 @@
From: Enrico Tassi <gareuselesinge@debian.org>
Date: Tue, 26 Aug 2014 16:20:55 +0200
Subject: Fix stack overflow in vararg functions
---
src/ldo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ldo.c b/src/ldo.c
index d1bf786..30333bf 100644
--- a/src/ldo.c
+++ b/src/ldo.c
@@ -274,7 +274,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
CallInfo *ci;
StkId st, base;
Proto *p = cl->p;
- luaD_checkstack(L, p->maxstacksize);
+ luaD_checkstack(L, p->maxstacksize + p->numparams);
func = restorestack(L, funcr);
if (!p->is_vararg) { /* no varargs? */
base = func + 1;

View File

@@ -0,0 +1,10 @@
--- a/src/lparser.c
+++ b/src/lparser.c
@@ -301,6 +301,7 @@
expdesc key;
singlevaraux(fs, ls->envn, var, 1); /* get environment variable */
lua_assert(var->k == VLOCAL || var->k == VUPVAL);
+ luaK_exp2anyregup(fs, var); /* but could be a constant */
codestring(ls, &key, varname); /* key is variable name */
luaK_indexed(fs, var, &key); /* env[varname] */
}

View File

@@ -0,0 +1,258 @@
# Generic builder for lua packages
{
lib,
lua,
wrapLua,
luarocks_bootstrap,
writeTextFile,
# Whether the derivation provides a lua module or not.
luarocksCheckHook,
luaLib,
}:
{
pname,
version,
# we need rockspecVersion to find the .rockspec even when version changes
rockspecVersion ? version,
# by default prefix `name` e.g. "lua5.2-${name}"
namePrefix ? "${lua.pname}${lib.versions.majorMinor lua.version}-",
# Dependencies for building the package
buildInputs ? [ ],
# Dependencies needed for running the checkPhase.
# These are added to nativeBuildInputs when doCheck = true.
nativeCheckInputs ? [ ],
# propagate build dependencies so in case we have A -> B -> C,
# C can import package A propagated by B
propagatedBuildInputs ? [ ],
# used to disable derivation, useful for specific lua versions
# TODO move from this setting meta.broken to a 'disabled' attribute on the
# package, then use that to skip/include in each lua${ver}Packages set?
disabled ? false,
# Additional arguments to pass to the makeWrapper function, which wraps
# generated binaries.
makeWrapperArgs ? [ ],
# Skip wrapping of lua programs altogether
dontWrapLuaPrograms ? false,
doCheck ? false,
# Non-Lua / system (e.g. C library) dependencies. Is a list of deps, where
# each dep is either a derivation, or an attribute set like
# { name = "rockspec external_dependencies key"; dep = derivation; }
# The latter is used to work-around luarocks having a problem with
# multiple-output derivations as external deps:
# https://github.com/luarocks/luarocks/issues/766<Paste>
externalDeps ? [ ],
# Appended to the generated luarocks config
extraConfig ? "",
# transparent mapping nix <-> lua used as LUAROCKS_CONFIG
# Refer to https://github.com/luarocks/luarocks/wiki/Config-file-format for specs
luarocksConfig ? { },
# relative to srcRoot, path to the rockspec to use when using rocks
rockspecFilename ? null,
# must be set for packages that don't have a rock
knownRockspec ? null,
...
}@attrs:
# Keep extra attributes from `attrs`, e.g., `patchPhase', etc.
let
# TODO fix warnings "Couldn't load rockspec for ..." during manifest
# construction -- from initial investigation, appears it will require
# upstream luarocks changes to fix cleanly (during manifest construction,
# luarocks only looks for rockspecs in the default/system tree instead of all
# configured trees)
luarocks_config = "luarocks-config.lua";
luarocksDrv = luaLib.toLuaModule (
lua.stdenv.mkDerivation (
self:
attrs
// {
name = namePrefix + self.pname + "-" + self.version;
inherit rockspecVersion;
__structuredAttrs = true;
env = {
LUAROCKS_CONFIG = self.configFile;
}
// attrs.env or { };
generatedRockspecFilename = "./${self.pname}-${self.rockspecVersion}.rockspec";
nativeBuildInputs = [
lua # for lua.h
wrapLua
luarocks_bootstrap
];
inherit
doCheck
extraConfig
rockspecFilename
knownRockspec
externalDeps
nativeCheckInputs
;
buildInputs =
let
# example externalDeps': [ { name = "CRYPTO"; dep = pkgs.openssl; } ]
externalDeps' = lib.filter (dep: !lib.isDerivation dep) self.externalDeps;
in
[ luarocks_bootstrap ]
++ buildInputs
++ lib.optionals self.doCheck ([ luarocksCheckHook ] ++ self.nativeCheckInputs)
++ (map (d: d.dep) externalDeps');
# propagate lua to active setup-hook in nix-shell
propagatedBuildInputs = propagatedBuildInputs ++ [ lua ];
# @-patterns do not capture formal argument default values, so we need to
# explicitly inherit this for it to be available as a shell variable in the
# builder
rocksSubdir = "${self.pname}-${self.version}-rocks";
configFile = writeTextFile {
name = self.pname + "-luarocks-config.lua";
text = self.luarocks_content;
};
luarocks_content = (lib.generators.toLua { asBindings = true; } self.luarocksConfig) + ''
${self.extraConfig}
'';
# TODO make it the default variable
luarocksConfig =
let
externalDepsGenerated = lib.filter (drv: !drv ? luaModule) (
self.nativeBuildInputs ++ self.propagatedBuildInputs ++ self.buildInputs
);
generatedConfig = luaLib.generateLuarocksConfig {
externalDeps = lib.unique (self.externalDeps ++ externalDepsGenerated);
local_cache = "";
# To prevent collisions when creating environments, we install the rock
# files into per-package subdirectories
rocks_subdir = self.rocksSubdir;
# Filter out the lua derivation itself from the Lua module dependency
# closure, as it doesn't have a rock tree :)
# luaLib.hasLuaModule
requiredLuaRocks = lib.filter luaLib.hasLuaModule (
lua.pkgs.requiredLuaModules (self.nativeBuildInputs ++ self.propagatedBuildInputs)
);
};
luarocksConfig' = lib.recursiveUpdate luarocksConfig (
lib.optionalAttrs (attrs ? extraVariables) (
lib.warn "extraVariables in buildLuarocksPackage is deprecated, use luarocksConfig instead" {
variables = attrs.extraVariables;
}
)
);
in
lib.recursiveUpdate generatedConfig luarocksConfig';
configurePhase = ''
runHook preConfigure
''
+ lib.optionalString (self.rockspecFilename == null) ''
rockspecFilename="${self.generatedRockspecFilename}"
''
+ lib.optionalString (self.knownRockspec != null) ''
# prevents the following type of error:
# Inconsistency between rockspec filename (42fm1b3d7iv6fcbhgm9674as3jh6y2sh-luv-1.22.0-1.rockspec) and its contents (luv-1.22.0-1.rockspec)
rockspecFilename="$TMP/$(stripHash ${self.knownRockspec})"
cp ${self.knownRockspec} "$rockspecFilename"
''
+ ''
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
source ${lua}/nix-support/utils.sh
nix_debug "Using LUAROCKS_CONFIG=$LUAROCKS_CONFIG"
LUAROCKS_EXTRA_ARGS=""
if (( ''${NIX_DEBUG:-0} >= 1 )); then
LUAROCKS_EXTRA_ARGS=" --verbose"
fi
runHook postBuild
'';
postFixup =
lib.optionalString (!dontWrapLuaPrograms) ''
wrapLuaPrograms
''
+ attrs.postFixup or "";
installPhase = ''
runHook preInstall
# work around failing luarocks test for Write access
mkdir -p $out
# luarocks make assumes sources are available in cwd
# After the build is complete, it also installs the rock.
# If no argument is given, it looks for a rockspec in the current directory
# but some packages have several rockspecs in their source directory so
# we force the use of the upper level since it is
# the sole rockspec in that folder
# maybe we could reestablish dependency checking via passing --rock-trees
nix_debug "ROCKSPEC $rockspecFilename"
luarocks $LUAROCKS_EXTRA_ARGS make --deps-mode=all --tree=$out ''${rockspecFilename}
runHook postInstall
'';
checkPhase = ''
runHook preCheck
luarocks test
runHook postCheck
'';
shellHook = ''
runHook preShell
export LUAROCKS_CONFIG="$PWD/${luarocks_config}";
runHook postShell
'';
passthru = {
inherit lua;
}
// attrs.passthru or { };
meta = {
platforms = lua.meta.platforms;
# add extra maintainer(s) to every package
maintainers = (attrs.meta.maintainers or [ ]) ++ [ ];
broken = disabled;
}
// attrs.meta or { };
}
)
);
in
luarocksDrv

View File

@@ -0,0 +1,189 @@
# similar to interpreters/python/default.nix
{
stdenv,
config,
lib,
callPackage,
fetchFromGitHub,
fetchurl,
makeBinaryWrapper,
}:
let
# Common passthru for all lua interpreters.
# copied from python
passthruFun =
{
executable,
luaversion,
packageOverrides,
luaOnBuildForBuild,
luaOnBuildForHost,
luaOnBuildForTarget,
luaOnHostForHost,
luaOnTargetForTarget,
luaAttr ? null,
self, # is luaOnHostForTarget
}:
let
luaPackages =
callPackage
# Function that when called
# - imports lua-packages.nix
# - adds spliced package sets to the package set
# - applies overrides from `packageOverrides`
(
{
lua,
overrides,
callPackage,
makeScopeWithSplicing',
}:
let
luaPackagesFun = callPackage ../../../top-level/lua-packages.nix {
lua = self;
};
generatedPackages =
if (builtins.pathExists ../../lua-modules/generated-packages.nix) then
(
final: prev:
callPackage ../../lua-modules/generated-packages.nix { inherit (final) callPackage; } final prev
)
else
(final: prev: { });
overriddenPackages = callPackage ../../lua-modules/overrides.nix { };
otherSplices = {
selfBuildBuild = luaOnBuildForBuild.pkgs;
selfBuildHost = luaOnBuildForHost.pkgs;
selfBuildTarget = luaOnBuildForTarget.pkgs;
selfHostHost = luaOnHostForHost.pkgs;
selfTargetTarget = luaOnTargetForTarget.pkgs or { };
};
aliases =
final: prev:
lib.optionalAttrs config.allowAliases (import ../../lua-modules/aliases.nix lib final prev);
extensions = lib.composeManyExtensions [
aliases
generatedPackages
overriddenPackages
overrides
];
in
makeScopeWithSplicing' {
inherit otherSplices;
f = lib.extends extensions luaPackagesFun;
}
)
{
overrides = packageOverrides;
lua = self;
};
in
rec {
buildEnv = callPackage ./wrapper.nix {
lua = self;
makeWrapper = makeBinaryWrapper;
inherit (luaPackages) requiredLuaModules;
};
withPackages = import ./with-packages.nix { inherit buildEnv luaPackages; };
pkgs = luaPackages;
interpreter = "${self}/bin/${executable}";
inherit executable luaversion;
luaOnBuild = luaOnBuildForHost.override {
inherit packageOverrides;
self = luaOnBuild;
};
tests = callPackage ./tests {
lua = self;
inherit (luaPackages) wrapLua;
};
inherit luaAttr;
};
in
rec {
lua5_4 = callPackage ./interpreter.nix {
self = lua5_4;
version = "5.4.7";
hash = "sha256-n79eKO+GxphY9tPTTszDLpEcGii0Eg/z6EqqcM+/HjA=";
makeWrapper = makeBinaryWrapper;
inherit passthruFun;
patches = lib.optional stdenv.hostPlatform.isDarwin ./5.4.darwin.patch;
};
lua5_4_compat = lua5_4.override {
self = lua5_4_compat;
compat = true;
};
lua5_3 = callPackage ./interpreter.nix {
self = lua5_3;
version = "5.3.6";
hash = "0q3d8qhd7p0b7a4mh9g7fxqksqfs6mr1nav74vq26qvkp2dxcpzw";
makeWrapper = makeBinaryWrapper;
inherit passthruFun;
patches = lib.optionals stdenv.hostPlatform.isDarwin [ ./5.2.darwin.patch ];
};
lua5_3_compat = lua5_3.override {
self = lua5_3_compat;
compat = true;
};
lua5_2 = callPackage ./interpreter.nix {
self = lua5_2;
version = "5.2.4";
hash = "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr";
makeWrapper = makeBinaryWrapper;
inherit passthruFun;
patches = [
./CVE-2022-28805.patch
]
++ lib.optional stdenv.hostPlatform.isDarwin ./5.2.darwin.patch;
};
lua5_2_compat = lua5_2.override {
self = lua5_2_compat;
compat = true;
};
lua5_1 = callPackage ./interpreter.nix {
self = lua5_1;
version = "5.1.5";
hash = "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333";
makeWrapper = makeBinaryWrapper;
inherit passthruFun;
patches = (lib.optional stdenv.hostPlatform.isDarwin ./5.1.darwin.patch) ++ [
./CVE-2014-5461.patch
];
};
luajit_2_0 = import ../luajit/2.0.nix {
self = luajit_2_0;
inherit
callPackage
fetchFromGitHub
lib
passthruFun
;
};
luajit_2_1 = import ../luajit/2.1.nix {
self = luajit_2_1;
inherit callPackage fetchFromGitHub passthruFun;
};
luajit_openresty = import ../luajit/openresty.nix {
self = luajit_openresty;
inherit callPackage fetchFromGitHub passthruFun;
};
}

View File

@@ -0,0 +1,26 @@
# Hooks for building lua packages.
{
lua,
makeSetupHook,
}:
let
callPackage = lua.pkgs.callPackage;
in
{
luarocksCheckHook = callPackage (
{ luarocks }:
makeSetupHook {
name = "luarocks-check-hook";
propagatedBuildInputs = [ luarocks ];
} ./luarocks-check-hook.sh
) { };
# luarocks installs data in a non-overridable location. Until a proper luarocks patch,
# we move the files around ourselves
luarocksMoveDataFolder = makeSetupHook {
name = "luarocks-move-rock";
propagatedBuildInputs = [ ];
} ./luarocks-move-data.sh;
}

View File

@@ -0,0 +1,18 @@
# Setup hook for checking whether Python imports succeed
echo "Sourcing luarocks-check-hook.sh"
luarocksCheckPhase () {
echo "Executing luarocksCheckPhase"
runHook preCheck
luarocks test
runHook postCheck
echo "Finished executing luarocksCheckPhase"
}
if [ -z "${dontLuarocksCheck-}" ] && [ -z "${checkPhase-}" ]; then
echo "Using luarocksCheckPhase"
checkPhase+=" luarocksCheckPhase"
fi

View File

@@ -0,0 +1,15 @@
# luarocks installs data in a non-overridable location. Until a proper luarocks patch,
# we move the files around ourselves
echo "Sourcing luarocks-move-data-hook.sh"
luarocksMoveDataHook () {
echo "Executing luarocksMoveDataHook"
if [ -d "$out/$rocksSubdir" ]; then
cp -rfv "$out/$rocksSubdir/$pname/$rockspecVersion/." "$out"
fi
echo "Finished executing luarocksMoveDataHook"
}
echo "Using luarocksMoveDataHook"
preFixupHooks+=(luarocksMoveDataHook)

View File

@@ -0,0 +1,236 @@
{
lib,
stdenv,
fetchurl,
readline,
compat ? false,
makeWrapper,
self,
packageOverrides ? (final: prev: { }),
replaceVars,
pkgsBuildBuild,
pkgsBuildHost,
pkgsBuildTarget,
pkgsHostHost,
pkgsTargetTarget,
version,
hash,
passthruFun,
patches ? [ ],
postConfigure ? null,
postBuild ? null,
staticOnly ? stdenv.hostPlatform.isStatic,
luaAttr ? "lua${lib.versions.major version}_${lib.versions.minor version}",
}@inputs:
stdenv.mkDerivation (
finalAttrs:
let
luaPackages = self.pkgs;
luaversion = lib.versions.majorMinor finalAttrs.version;
plat =
if (stdenv.hostPlatform.isLinux && lib.versionOlder self.luaversion "5.4") then
"linux"
else if (stdenv.hostPlatform.isLinux && lib.versionAtLeast self.luaversion "5.4") then
"linux-readline"
else if stdenv.hostPlatform.isDarwin then
"macosx"
else if stdenv.hostPlatform.isMinGW then
"mingw"
else if stdenv.hostPlatform.isFreeBSD then
"freebsd"
else if stdenv.hostPlatform.isSunOS then
"solaris"
else if stdenv.hostPlatform.isBSD then
"bsd"
else if stdenv.hostPlatform.isUnix then
"posix"
else
"generic";
compatFlags =
if (lib.versionOlder self.luaversion "5.3") then
" -DLUA_COMPAT_ALL"
else if (lib.versionOlder self.luaversion "5.4") then
" -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2"
else
" -DLUA_COMPAT_5_3";
in
{
pname = "lua";
inherit version;
outputs = [
"out"
"doc"
];
src = fetchurl {
url = "https://www.lua.org/ftp/lua-${finalAttrs.version}.tar.gz";
sha256 = hash;
};
LuaPathSearchPaths = luaPackages.luaLib.luaPathList;
LuaCPathSearchPaths = luaPackages.luaLib.luaCPathList;
setupHook = builtins.toFile "lua-setup-hook" ''
source @out@/nix-support/utils.sh
addEnvHooks "$hostOffset" luaEnvHook
'';
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ readline ];
inherit patches;
postPatch = ''
sed -i "s@#define LUA_ROOT[[:space:]]*\"/usr/local/\"@#define LUA_ROOT \"$out/\"@g" src/luaconf.h
# abort if patching didn't work
grep $out src/luaconf.h
''
+ lib.optionalString (!stdenv.hostPlatform.isDarwin && !staticOnly) ''
# Add a target for a shared library to the Makefile.
sed -e '1s/^/LUA_SO = liblua.so/' \
-e 's/ALL_T *= */&$(LUA_SO) /' \
-i src/Makefile
cat ${./lua-dso.make} >> src/Makefile
'';
env = {
inherit luaversion;
pkgversion = version;
};
# see configurePhase for additional flags (with space)
makeFlags = [
"INSTALL_TOP=${placeholder "out"}"
"INSTALL_MAN=${placeholder "out"}/share/man/man1"
"R=${version}"
"LDFLAGS=-fPIC"
"V=${luaversion}"
"PLAT=${plat}"
"CC=${stdenv.cc.targetPrefix}cc"
"RANLIB=${stdenv.cc.targetPrefix}ranlib"
# Lua links with readline which depends on ncurses. For some reason when
# building pkgsStatic.lua it fails because symbols from ncurses are not
# found. Adding ncurses here fixes the problem.
"MYLIBS=-lncurses"
];
configurePhase = ''
runHook preConfigure
makeFlagsArray+=(CFLAGS='-O2 -fPIC${lib.optionalString compat compatFlags} $(${
if lib.versionAtLeast luaversion "5.2" then "SYSCFLAGS" else "MYCFLAGS"
})' )
makeFlagsArray+=(${lib.optionalString stdenv.hostPlatform.isDarwin "CC=\"$CC\""}${
lib.optionalString (
stdenv.buildPlatform != stdenv.hostPlatform
) " 'AR=${stdenv.cc.targetPrefix}ar rcu'"
})
installFlagsArray=( TO_BIN="lua luac" INSTALL_DATA='cp -d' \
TO_LIB="${
if stdenv.hostPlatform.isDarwin then
"liblua.${finalAttrs.version}.dylib"
else
(
"liblua.a"
+ lib.optionalString (
!staticOnly
) " liblua.so liblua.so.${luaversion} liblua.so.${finalAttrs.version}"
)
}" )
runHook postConfigure
'';
inherit postConfigure;
inherit postBuild;
postInstall = ''
mkdir -p "$out/nix-support" "$out/share/doc/lua" "$out/lib/pkgconfig"
cp ${
replaceVars ./utils.sh {
luapathsearchpaths = lib.escapeShellArgs finalAttrs.LuaPathSearchPaths;
luacpathsearchpaths = lib.escapeShellArgs finalAttrs.LuaCPathSearchPaths;
}
} $out/nix-support/utils.sh
mv "doc/"*.{gif,png,css,html} "$out/share/doc/lua/"
rmdir $out/{share,lib}/lua/${luaversion} $out/{share,lib}/lua
mkdir -p "$out/lib/pkgconfig"
cat >"$out/lib/pkgconfig/lua.pc" <<EOF
prefix=$out
libdir=$out/lib
includedir=$out/include
INSTALL_BIN=$out/bin
INSTALL_INC=$out/include
INSTALL_LIB=$out/lib
INSTALL_MAN=$out/man/man1
Name: Lua
Description: An Extensible Extension Language
Version: ${finalAttrs.version}
Requires:
Libs: -L$out/lib -llua
Cflags: -I$out/include
EOF
ln -s "$out/lib/pkgconfig/lua.pc" "$out/lib/pkgconfig/lua-${luaversion}.pc"
ln -s "$out/lib/pkgconfig/lua.pc" "$out/lib/pkgconfig/lua${luaversion}.pc"
ln -s "$out/lib/pkgconfig/lua.pc" "$out/lib/pkgconfig/lua${
lib.replaceStrings [ "." ] [ "" ] luaversion
}.pc"
# Make documentation outputs of different versions co-installable.
mv $out/share/doc/lua $out/share/doc/lua-${finalAttrs.version}
'';
# copied from python
passthru =
let
# When we override the interpreter we also need to override the spliced versions of the interpreter
inputs' = lib.filterAttrs (n: v: !lib.isDerivation v && n != "passthruFun") inputs;
override =
attr:
let
lua = attr.override (inputs' // { self = lua; });
in
lua;
in
passthruFun rec {
inherit
self
luaversion
packageOverrides
luaAttr
;
executable = "lua";
luaOnBuildForBuild = override pkgsBuildBuild.${luaAttr};
luaOnBuildForHost = override pkgsBuildHost.${luaAttr};
luaOnBuildForTarget = override pkgsBuildTarget.${luaAttr};
luaOnHostForHost = override pkgsHostHost.${luaAttr};
luaOnTargetForTarget = lib.optionalAttrs (lib.hasAttr luaAttr pkgsTargetTarget) (
override pkgsTargetTarget.${luaAttr}
);
};
meta = {
homepage = "https://www.lua.org";
description = "Powerful, fast, lightweight, embeddable scripting language";
longDescription = ''
Lua combines simple procedural syntax with powerful data
description constructs based on associative arrays and extensible
semantics. Lua is dynamically typed, runs by interpreting bytecode
for a register-based virtual machine, and has automatic memory
management with incremental garbage collection, making it ideal
for configuration, scripting, and rapid prototyping.
'';
mainProgram = "lua";
license = lib.licenses.mit;
platforms = lib.platforms.unix;
};
}
)

View File

@@ -0,0 +1,4 @@
$(LUA_SO): $(CORE_O) $(LIB_O)
$(CC) -shared $(LIBS) -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $? $(MYLDFLAGS)
ln -sf $(LUA_SO).$(R) $(LUA_SO).$(V)
ln -sf $(LUA_SO).$(R) $(LUA_SO)

View File

@@ -0,0 +1,21 @@
# Always failing assertion with a message.
#
# Example:
# fail "It should have been but it wasn't to be"
function fail() {
echo -e "$1"
exit 1
}
function assertStringEqual() {
if ! diff <(echo "$1") <(echo "$2") ; then
fail "Actual value: \"$1\"\nExpected value: \"$2\""
fi
}
function assertStringContains() {
if ! echo "$1" | grep -q "$2" ; then
fail "expected \"$1\" to contain \"$2\""
fi
}

View File

@@ -0,0 +1,126 @@
{
lua,
hello,
wrapLua,
lib,
pkgs,
}:
let
runTest =
lua:
{ name, command }:
pkgs.runCommandLocal "test-${lua.name}-${name}"
{
nativeBuildInputs = [ lua ];
meta.platforms = lua.meta.platforms;
}
(
''
source ${./assert.sh}
''
+ command
+ "touch $out"
);
wrappedHello = hello.overrideAttrs (oa: {
propagatedBuildInputs = [
wrapLua
lua.pkgs.cjson
];
postFixup = ''
wrapLuaPrograms
'';
});
luaWithModule = lua.withPackages (ps: [
ps.lua-cjson
]);
golden_LUA_PATHS = {
# Looking at lua interpreter 'setpath' code
# for instance https://github.com/lua/lua/blob/69ea087dff1daba25a2000dfb8f1883c17545b7a/loadlib.c#L599
# replace ";;" by ";LUA_PATH_DEFAULT;"
"5.1" =
";./?.lua;${lua}/share/lua/5.1/?.lua;${lua}/share/lua/5.1/?/init.lua;${lua}/lib/lua/5.1/?.lua;${lua}/lib/lua/5.1/?/init.lua;";
"5.2" =
";${lua}/share/lua/5.2/?.lua;${lua}/share/lua/5.2/?/init.lua;${lua}/lib/lua/5.2/?.lua;${lua}/lib/lua/5.2/?/init.lua;./?.lua;";
"5.3" =
";${lua}/share/lua/5.3/?.lua;${lua}/share/lua/5.3/?/init.lua;${lua}/lib/lua/5.3/?.lua;${lua}/lib/lua/5.3/?/init.lua;./?.lua;./?/init.lua;";
# lua5.4 seems to be smarter about it and dont add the lua separators when nothing left or right
"5.4" =
"${lua}/share/lua/5.4/?.lua;${lua}/share/lua/5.4/?/init.lua;${lua}/lib/lua/5.4/?.lua;${lua}/lib/lua/5.4/?/init.lua;./?.lua;./?/init.lua";
# luajit versions
"2.0" =
";./?.lua;${lua}/share/luajit-2.0/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;${lua}/share/lua/5.1/?.lua;${lua}/share/lua/5.1/?/init.lua;";
"2.1" =
";./?.lua;${lua}/share/luajit-2.1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;${lua}/share/lua/5.1/?.lua;${lua}/share/lua/5.1/?/init.lua;";
};
in
pkgs.recurseIntoAttrs {
checkInterpreterPath =
let
golden_LUA_PATH = golden_LUA_PATHS.${lib.versions.majorMinor lua.version};
in
runTest lua {
name = "check-default-lua-path";
command = ''
export LUA_PATH=";;"
generated=$(lua -e 'print(package.path)')
assertStringEqual "$generated" "${golden_LUA_PATH}"
'';
};
checkWrapping = pkgs.runCommandLocal "test-${lua.name}-wrapping" { } ''
grep -- 'LUA_PATH=' ${wrappedHello}/bin/hello
touch $out
'';
# checks that lua's setup-hook adds dependencies to LUA_PATH
# Prevents the following regressions
# $ env NIX_PATH=nixpkgs=. nix-shell --pure -Q -p luajitPackages.lua luajitPackages.http
# nix-shell$ luajit
# > require('http.request')
# stdin:1: module 'http.request' not found:
checkSetupHook =
pkgs.runCommandLocal "test-${lua.name}-setup-hook"
{
nativeBuildInputs = [ lua ];
buildInputs = [ lua.pkgs.http ];
meta.platforms = lua.meta.platforms;
}
''
${lua}/bin/lua -e "require'http.request'"
touch $out
'';
checkRelativeImports = pkgs.runCommandLocal "test-${lua.name}-relative-imports" { } ''
source ${./assert.sh}
lua_vanilla_package_path="$(${lua}/bin/lua -e "print(package.path)")"
lua_with_module_package_path="$(${luaWithModule}/bin/lua -e "print(package.path)")"
assertStringContains "$lua_vanilla_package_path" "./?.lua"
assertStringContains "$lua_vanilla_package_path" "./?/init.lua"
assertStringContains "$lua_with_module_package_path" "./?.lua"
assertStringContains "$lua_with_module_package_path" "./?/init.lua"
touch $out
'';
# Check that a lua package's propagatedBuildInputs end up in LUA_PATH
checkPropagatedBuildInputs =
pkgs.runCommandLocal "test-${lua.name}-setup-hook"
{
buildInputs = [ lua.pkgs.rest-nvim ];
}
# `xml2lua` is a propagatedBuildInput of rest-nvim
''
${lua}/bin/lua -e "require'xml2lua'"
touch $out
'';
}

View File

@@ -0,0 +1,130 @@
#!/bin/bash
declare -gA luaPathsSeen=()
# shellcheck disable=SC2164,SC2041
nix_print() {
if [ ${NIX_DEBUG:-0} -ge $1 ]; then
echo "$2"
fi
}
nix_debug() {
nix_print 3 "$1"
}
addToLuaSearchPathWithCustomDelimiter() {
local varName="$1"
local absPattern="$2"
# export only if we haven't already got this dir in the search path
if [[ ${!varName-} == *"$absPattern"* ]]; then return; fi
# if the path variable has not yet been set, initialize it to ";;"
# this is a magic value that will be replaced by the default,
# allowing relative modules to be used even when there are system modules.
if [[ ! -v "${varName}" ]]; then export "${varName}=;;"; fi
# export only if the folder contains lua files
shopt -s globstar
local adjustedPattern="${absPattern/\?/\*\*\/\*}"
for _file in $adjustedPattern; do
export "${varName}=${!varName:+${!varName};}${absPattern}"
shopt -u globstar
return;
done
shopt -u globstar
}
# used in setup Hooks to load LUA_PATH and LUA_CPATH
# luaEnvHook
luaEnvHook() {
_addToLuaPath "$1"
}
addToLuaPath() {
local dir="$1"
if [ ! -d "$dir" ]; then
nix_debug "$dir not a directory abort"
return 0
fi
cd "$dir"
for pattern in @luapathsearchpaths@; do
addToLuaSearchPathWithCustomDelimiter LUA_PATH "$PWD/$pattern"
done
# LUA_CPATH
for pattern in @luacpathsearchpaths@; do
addToLuaSearchPathWithCustomDelimiter LUA_CPATH "$PWD/$pattern"
done
cd - >/dev/null
}
_addToLuaPath() {
local dir="$1"
nix_debug "_addToLuaPath called for dir $dir"
if [[ ! -d "$dir" ]]; then
nix_debug "$dir not a directory abort"
return 0
fi
# set -x
# if [ -n "${pythonPathsSeen[$dir]}" ]; then return; fi
if [[ -n "${luaPathsSeen[$dir]:-}" ]]; then
# if [ -n "${luaPathsSeen[$dir]}" ]; then
nix_debug "$dir already parsed"
return
fi
luaPathsSeen["$dir"]=true
# shellcheck disable=SC2164
cd "$dir"
for pattern in @luapathsearchpaths@; do
addToLuaSearchPathWithCustomDelimiter LUA_PATH "$PWD/$pattern"
done
# LUA_CPATH
for pattern in @luacpathsearchpaths@; do
addToLuaSearchPathWithCustomDelimiter LUA_CPATH "$PWD/$pattern"
done
cd - >/dev/null
addToSearchPath program_PATH "$dir"/bin
# Inspect the propagated inputs (if they exist) and recur on them.
local prop="$dir/nix-support/propagated-build-inputs"
if [ -e "$prop" ]; then
local new_path
for new_path in $(cat $prop); do
nix_debug "newpath: $new_path"
_addToLuaPath "$new_path"
done
fi
}
# Builds environment variables like LUA_PATH and PATH walking through closure
# of dependencies.
buildLuaPath() {
local luaPath="$1"
local path
nix_debug "BUILD_LUA_PATH"
# # Create an empty table of paths (see doc on loadFromPropagatedInputs
# # for how this is used). Build up the program_PATH variable.
# # shellcheck disable=SC2034
program_PATH=
for path in $luaPath; do
_addToLuaPath "$path"
done
}

View File

@@ -0,0 +1,8 @@
{ buildEnv, luaPackages }:
# this is a function that returns a function that returns an environment
f:
let
packages = f luaPackages;
in
buildEnv.override { extraLibs = packages; }

View File

@@ -0,0 +1,14 @@
{
lua,
makeSetupHook,
makeWrapper,
}:
# defined in trivial-builders
# imported as wrapLua in lua-packages.nix and passed to build-lua-derivation to be used as buildInput
makeSetupHook {
name = "wrap-lua-hook";
propagatedBuildInputs = [ makeWrapper ];
substitutions.executable = lua.interpreter;
substitutions.lua = lua;
} ./wrap.sh

View File

@@ -0,0 +1,56 @@
# Inspired by python/wrapper.nix
# Wrapper around wrapLuaProgramsIn, below. The $luaPath
# variable is passed in from the buildLuarocksPackage function.
set -e
source @lua@/nix-support/utils.sh
wrapLuaPrograms() {
wrapLuaProgramsIn "$out/bin" "$out $luaPath"
}
# with an executable shell script which will set some environment variables
# and then call into the original binary (which has been given a .wrapped suffix).
# luaPath is a list of directories
wrapLuaProgramsIn() {
local dir="$1"
local luaPath="$2"
local f
buildLuaPath "$luaPath"
if [ ! -d "$dir" ]; then
nix_debug "$dir not a directory"
return
fi
nix_debug "wrapping programs in [$dir]"
# Find all regular files in the output directory that are executable.
find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do
# Rewrite "#! .../env lua" to "#! /nix/store/.../lua".
# Lua to use besides one with this hook anyway.
if head -n1 "$f" | grep -q '#!.*/env.*\(lua\)'; then
sed -i "$f" -e "1 s^.*/env[ ]*\(lua\)[^ ]*^#! @executable@^"
fi
# wrapProgram creates the executable shell script described
# above. The script will set LUA_(C)PATH and PATH variables!
# (see pkgs/build-support/setup-hooks/make-wrapper.sh)
local -a wrap_args=("$f"
--prefix PATH ':' "$program_PATH"
--prefix LUA_PATH ';' "$LUA_PATH"
--prefix LUA_CPATH ';' "$LUA_CPATH"
)
# Add any additional arguments provided by makeWrapperArgs
# argument to buildLuaPackage.
# makeWrapperArgs
local -a user_args="($makeWrapperArgs)"
local -a wrapProgramArgs=("${wrap_args[@]}" "${user_args[@]}")
# see setup-hooks/make-wrapper.sh
wrapProgram "${wrapProgramArgs[@]}"
done
}

View File

@@ -0,0 +1,87 @@
{
lib,
stdenv,
lua,
buildEnv,
makeWrapper,
extraLibs ? [ ],
extraOutputsToInstall ? [ ],
postBuild ? "",
ignoreCollisions ? false,
requiredLuaModules,
makeWrapperArgs ? [ ],
}:
# Create a lua executable that knows about additional packages.
let
env =
let
paths = [ lua ] ++ requiredLuaModules extraLibs;
in
buildEnv {
name = "${lua.name}-env";
inherit paths;
inherit ignoreCollisions;
extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall;
nativeBuildInputs = [
makeWrapper
];
# we create wrapper for the binaries in the different packages
postBuild = ''
source ${lua}/nix-support/utils.sh
if [ -L "$out/bin" ]; then
unlink "$out/bin"
fi
mkdir -p "$out/bin"
buildLuaPath "$out"
# take every binary from lua packages and put them into the env
for path in ${lib.concatStringsSep " " paths}; do
nix_debug "looking for binaries in path = $path"
if [ -d "$path/bin" ]; then
cd "$path/bin"
for prg in *; do
if [ -f "$prg" ]; then
rm -f "$out/bin/$prg"
if [ -x "$prg" ]; then
nix_debug "Making wrapper $prg"
makeWrapper "$path/bin/$prg" "$out/bin/$prg" \
--set-default LUA_PATH ";;" \
--suffix LUA_PATH ';' "$LUA_PATH" \
--set-default LUA_CPATH ";;" \
--suffix LUA_CPATH ';' "$LUA_CPATH" \
${lib.concatStringsSep " " makeWrapperArgs}
fi
fi
done
fi
done
''
+ postBuild;
inherit (lua) meta;
passthru = lua.passthru // {
interpreter = "${env}/bin/lua";
inherit lua;
luaPath = lua.pkgs.luaLib.genLuaPathAbsStr env;
luaCpath = lua.pkgs.luaLib.genLuaCPathAbsStr env;
env = stdenv.mkDerivation {
name = "interactive-${lua.name}-environment";
nativeBuildInputs = [ env ];
buildCommand = ''
echo >&2 ""
echo >&2 "*** lua 'env' attributes are intended for interactive nix-shell sessions, not for building! ***"
echo >&2 ""
exit 1
'';
};
};
};
in
env

View File

@@ -0,0 +1,23 @@
--- a/Makefile 2007-10-30 01:59:10.000000000 +0300
+++ b/Makefile 2014-09-18 11:04:53.176320021 +0400
@@ -6,10 +6,6 @@
include $(CONFIG)
-ifeq "$(LUA_VERSION_NUM)" "500"
-COMPAT_O= $(COMPAT_DIR)/compat-5.1.o
-endif
-
SRCS= src/lua$T.c
OBJS= src/lua$T.o $(COMPAT_O)
@@ -19,9 +15,6 @@
src/$(LIBNAME): $(OBJS)
export MACOSX_DEPLOYMENT_TARGET="10.3"; $(CC) $(CFLAGS) $(LIB_OPTION) -o src/$(LIBNAME) $(OBJS) -lzzip
-$(COMPAT_DIR)/compat-5.1.o: $(COMPAT_DIR)/compat-5.1.c
- $(CC) -c $(CFLAGS) -o $@ $(COMPAT_DIR)/compat-5.1.c
-
install: src/$(LIBNAME)
mkdir -p $(LUA_LIBDIR)
cp src/$(LIBNAME) $(LUA_LIBDIR)

View File

@@ -0,0 +1,28 @@
{
self,
callPackage,
fetchFromGitHub,
lib,
passthruFun,
}:
callPackage ./default.nix {
# The patch version is the timestamp of the git commit,
# obtain via `cat $(nix-build -A luajit_2_0.src)/.relver`
version = "2.0.1741557863";
src = fetchFromGitHub {
owner = "LuaJIT";
repo = "LuaJIT";
rev = "85c3f2fb6f59276ebf07312859a69d6d5a897f62";
hash = "sha256-5UIZ650M/0W08iX1ajaHvDbNgjbzZJ1akVwNbiDUeyY=";
};
extraMeta = {
# this isn't precise but it at least stops the useless Hydra build
platforms = lib.filter (p: !lib.hasPrefix "aarch64-" p) (
lib.platforms.linux ++ lib.platforms.darwin
);
};
inherit self passthruFun;
}

View File

@@ -0,0 +1,21 @@
{
self,
callPackage,
fetchFromGitHub,
passthruFun,
}:
callPackage ./default.nix {
# The patch version is the timestamp of the git commit,
# obtain via `cat $(nix-build -A luajit_2_1.src)/.relver`
version = "2.1.1741730670";
src = fetchFromGitHub {
owner = "LuaJIT";
repo = "LuaJIT";
rev = "538a82133ad6fddfd0ca64de167c4aca3bc1a2da";
hash = "sha256-3DhNqVdojsWDo8mKJXIyTqFODIiKzThcAzHPdnoJaVM=";
};
inherit self passthruFun;
}

View File

@@ -0,0 +1,170 @@
{
lib,
stdenv,
buildPackages,
version,
src,
replaceVars,
extraMeta ? { },
self,
packageOverrides ? (final: prev: { }),
pkgsBuildBuild,
pkgsBuildHost,
pkgsBuildTarget,
pkgsHostHost,
pkgsTargetTarget,
passthruFun,
enableFFI ? true,
enableJIT ? true,
enableJITDebugModule ? enableJIT,
enableGC64 ? true,
enable52Compat ? false,
enableValgrindSupport ? false,
valgrind ? null,
enableGDBJITSupport ? false,
enableAPICheck ? false,
enableVMAssertions ? false,
enableRegisterAllocationRandomization ? false,
useSystemMalloc ? false,
# Upstream generates randomized string id's by default for security reasons
# https://github.com/LuaJIT/LuaJIT/issues/626. Deterministic string id's should
# never be needed for correctness (that should be fixed in the lua code),
# but may be helpful when you want to embed jit-compiled raw lua blobs in
# binaries that you want to be reproducible.
deterministicStringIds ? false,
luaAttr ? "luajit_${lib.versions.major version}_${lib.versions.minor version}",
}@inputs:
assert enableJITDebugModule -> enableJIT;
assert enableGDBJITSupport -> enableJIT;
assert enableValgrindSupport -> valgrind != null;
let
luaPackages = self.pkgs;
XCFLAGS =
lib.optional (!enableFFI) "-DLUAJIT_DISABLE_FFI"
++ lib.optional (!enableJIT) "-DLUAJIT_DISABLE_JIT"
++ lib.optional enable52Compat "-DLUAJIT_ENABLE_LUA52COMPAT"
++ lib.optional (!enableGC64) "-DLUAJIT_DISABLE_GC64"
++ lib.optional useSystemMalloc "-DLUAJIT_USE_SYSMALLOC"
++ lib.optional enableValgrindSupport "-DLUAJIT_USE_VALGRIND"
++ lib.optional enableGDBJITSupport "-DLUAJIT_USE_GDBJIT"
++ lib.optional enableAPICheck "-DLUAJIT_USE_APICHECK"
++ lib.optional enableVMAssertions "-DLUAJIT_USE_ASSERT"
++ lib.optional enableRegisterAllocationRandomization "-DLUAJIT_RANDOM_RA"
++ lib.optional deterministicStringIds "-DLUAJIT_SECURITY_STRID=0";
# LuaJIT requires build for 32bit architectures to be build on x86 not x86_64
# TODO support also other build architectures. The ideal way would be to use
# stdenv_32bit but that doesn't work due to host platform mismatch:
# https://github.com/NixOS/nixpkgs/issues/212494
buildStdenv =
if buildPackages.stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform.is32bit then
buildPackages.pkgsi686Linux.buildPackages.stdenv
else
buildPackages.stdenv;
in
stdenv.mkDerivation (finalAttrs: {
pname = "luajit";
inherit version src;
luaversion = "5.1";
postPatch = ''
substituteInPlace Makefile --replace ldconfig :
if test -n "''${dontStrip-}"; then
# CCDEBUG must be non-empty or everything will be stripped, -g being
# passed by nixpkgs CC wrapper is insufficient on its own
substituteInPlace src/Makefile --replace-fail "#CCDEBUG= -g" "CCDEBUG= -g"
fi
'';
dontConfigure = true;
buildInputs = lib.optional enableValgrindSupport valgrind;
buildFlags = [
"amalg" # Build highly optimized version
];
makeFlags = [
"PREFIX=$(out)"
"DEFAULT_CC=cc"
"CROSS=${stdenv.cc.targetPrefix}"
"HOST_CC=${buildStdenv.cc}/bin/cc"
]
++ lib.optional enableJITDebugModule "INSTALL_LJLIBD=$(INSTALL_LMOD)"
++ lib.optional stdenv.hostPlatform.isStatic "BUILDMODE=static";
enableParallelBuilding = true;
env.NIX_CFLAGS_COMPILE = toString XCFLAGS;
postInstall = ''
mkdir -p $out/nix-support
cp ${
replaceVars ../lua-5/utils.sh {
luapathsearchpaths = lib.escapeShellArgs finalAttrs.LuaPathSearchPaths;
luacpathsearchpaths = lib.escapeShellArgs finalAttrs.LuaCPathSearchPaths;
}
} $out/nix-support/utils.sh
( cd "$out/include"; ln -s luajit-*/* . )
ln -s "$out"/bin/luajit-* "$out"/bin/lua
if [[ ! -e "$out"/bin/luajit ]]; then
ln -s "$out"/bin/luajit* "$out"/bin/luajit
fi
'';
LuaPathSearchPaths = luaPackages.luaLib.luaPathList;
LuaCPathSearchPaths = luaPackages.luaLib.luaCPathList;
setupHook = builtins.toFile "lua-setup-hook" ''
source @out@/nix-support/utils.sh
addEnvHooks "$hostOffset" luaEnvHook
'';
# copied from python
passthru =
let
# When we override the interpreter we also need to override the spliced versions of the interpreter
inputs' = lib.filterAttrs (n: v: !lib.isDerivation v && n != "passthruFun") inputs;
override =
attr:
let
lua = attr.override (inputs' // { self = lua; });
in
lua;
in
passthruFun rec {
inherit self packageOverrides luaAttr;
inherit (finalAttrs) luaversion;
executable = "lua";
luaOnBuildForBuild = override pkgsBuildBuild.${luaAttr};
luaOnBuildForHost = override pkgsBuildHost.${luaAttr};
luaOnBuildForTarget = override pkgsBuildTarget.${luaAttr};
luaOnHostForHost = override pkgsHostHost.${luaAttr};
luaOnTargetForTarget = lib.optionalAttrs (lib.hasAttr luaAttr pkgsTargetTarget) (
override pkgsTargetTarget.${luaAttr}
);
};
meta =
with lib;
{
description = "High-performance JIT compiler for Lua 5.1";
homepage = "https://luajit.org/";
license = licenses.mit;
platforms = platforms.linux ++ platforms.darwin;
badPlatforms = [
"loongarch64-linux" # See https://github.com/LuaJIT/LuaJIT/issues/1278
"riscv64-linux" # See https://github.com/LuaJIT/LuaJIT/issues/628
"powerpc64le-linux" # `#error "No support for PPC64"`
];
mainProgram = "lua";
maintainers = with maintainers; [
thoughtpolice
smironov
vcunat
lblasc
];
}
// extraMeta;
})

View File

@@ -0,0 +1,19 @@
{
self,
callPackage,
fetchFromGitHub,
passthruFun,
}:
callPackage ./default.nix rec {
version = "2.1-20220915";
src = fetchFromGitHub {
owner = "openresty";
repo = "luajit2";
rev = "v${version}";
hash = "sha256-kMHE4iQtm2CujK9TVut1jNhY2QxYP514jfBsxOCyd4s=";
};
inherit self passthruFun;
}

View File

@@ -0,0 +1,111 @@
{
lib,
stdenv,
octave,
buildEnv,
makeWrapper,
locale,
texinfo,
glibcLocalesUtf8,
wrapOctave,
computeRequiredOctavePackages,
extraLibs ? [ ],
extraOutputsToInstall ? [ ],
postBuild ? "",
ignoreCollisions ? false,
}:
# Create an octave executable that knows about additional packages
let
packages = computeRequiredOctavePackages extraLibs;
# glibcLocalesUtf8 is null on darwin
localeArchiveArgs = lib.optionalString (glibcLocalesUtf8 != null) ''
--set LOCALE_ARCHIVE "${glibcLocalesUtf8}/lib/locale/locale-archive"
'';
in
buildEnv {
name = "${octave.name}-env";
paths = extraLibs ++ [ octave ];
inherit ignoreCollisions;
extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [
locale
texinfo
wrapOctave
];
# During "build" we must first unlink the /share symlink to octave's /share
# Then, we can re-symlink the all of octave/share, except for /share/octave
# in env/share/octave, re-symlink everything from octave/share/octave and then
# perform the pkg install.
postBuild = ''
if [ -L "$out/bin" ]; then
unlink $out/bin
mkdir -p "$out/bin"
cd "${octave}/bin"
for prg in *; do
if [ -x $prg ]; then
makeWrapper "${octave}/bin/$prg" "$out/bin/$prg" \
--set OCTAVE_SITE_INITFILE "$out/share/octave/site/m/startup/octaverc" \
${localeArchiveArgs}
fi
done
cd $out
fi
# Remove symlinks to the input tarballs, they aren't needed, use -f so it
# will not fail if no .tar.gz symlinks are there - for example if
# sommething which is not a tarball used as a package
rm -f $out/*.tar.gz
createOctavePackagesPath $out ${octave}
# Create the file even if the loop afterwards has no packages to run over
touch $out/.octave_packages
for path in ${lib.concatStringsSep " " packages}; do
if [ -e $path/*.tar.gz ]; then
$out/bin/octave-cli --eval "pkg local_list $out/.octave_packages; \
pkg prefix $out/${octave.octPkgsPath} $out/${octave.octPkgsPath}; \
pfx = pkg (\"prefix\"); \
pkg install -nodeps -local $path/*.tar.gz"
fi
done
# Re-write the octave-wide startup file (share/octave/site/m/startup/octaverc)
# To point to the new local_list in $out
addPkgLocalList $out ${octave}
wrapOctavePrograms "${lib.concatStringsSep " " packages}"
# We also need to modify the Exec= line of the desktop file, so it will point
# to the wrapper we generated above.
rm $out/share/applications # should be a symlink to ${octave}/share/applications
mkdir $out/share/applications
substitute \
${octave}/share/applications/org.octave.Octave.desktop \
$out/share/applications/org.octave.Octave.desktop \
--replace-fail ${octave}/bin/octave $out/bin/octave
''
+ postBuild;
inherit (octave) meta version;
passthru = (removeAttrs octave.passthru [ "tests" ]) // {
interpreter = "$out/bin/octave";
inherit octave;
env = stdenv.mkDerivation {
name = "interactive-${octave.name}-environment";
buildCommand = ''
echo >&2 ""
echo >&2 "*** octave 'env' attributes are intended for interactive nix-shell sessions, not for building! ***"
echo >&2 ""
exit 1
'';
};
};
}

View File

@@ -0,0 +1,154 @@
# Generic builder for GNU Octave libraries.
# This is a file that contains nested functions. The first, outer, function
# is the library- and package-wide details, such as the nixpkgs library, any
# additional configuration provided, and the namePrefix to use (based on the
# pname and version of Octave), the octave package, etc.
{
lib,
stdenv,
config,
octave,
callPackage,
texinfo,
computeRequiredOctavePackages,
writeRequiredOctavePackagesHook,
}:
# The inner function contains information required to build the individual
# libraries.
{
fullLibName ? "${attrs.pname}-${attrs.version}",
src,
dontPatch ? false,
patches ? [ ],
patchPhase ? "",
enableParallelBuilding ? true,
# Build-time dependencies for the package, which were compiled for the system compiling this.
nativeBuildInputs ? [ ],
# Build-time dependencies for the package, which may not have been compiled for the system compiling this.
buildInputs ? [ ],
# Propagate build dependencies so in case we have A -> B -> C,
# C can import package A propagated by B
# Run-time dependencies for the package.
propagatedBuildInputs ? [ ],
# Octave packages that are required at runtime for this one.
# These behave similarly to propagatedBuildInputs, where if
# package A is needed by B, and C needs B, then C also requires A.
# The main difference between these and propagatedBuildInputs is
# during the package's installation into octave, where all
# requiredOctavePackages are ALSO installed into octave.
requiredOctavePackages ? [ ],
preBuild ? "",
meta ? { },
passthru ? { },
...
}@attrs:
let
requiredOctavePackages' = computeRequiredOctavePackages requiredOctavePackages;
# Must use attrs.nativeBuildInputs before they are removed by the removeAttrs
# below, or everything fails.
nativeBuildInputs' = [
octave
writeRequiredOctavePackagesHook
]
++ nativeBuildInputs;
# This step is required because when
# a = { test = [ "a" "b" ]; }; b = { test = [ "c" "d" ]; };
# (a // b).test = [ "c" "d" ];
# This used to mean that if a package defined extra nativeBuildInputs, it
# would override the ones for building an Octave package (the hook and Octave
# itself, causing everything to fail.
attrs' = removeAttrs attrs [
"nativeBuildInputs"
"passthru"
];
in
stdenv.mkDerivation (
finalAttrs:
{
packageName = "${fullLibName}";
# The name of the octave package ends up being
# "octave-version-package-version"
name = "${octave.pname}-${octave.version}-${fullLibName}";
# This states that any package built with the function that this returns
# will be an octave package. This is used for ensuring other octave
# packages are installed into octave during the environment building phase.
isOctavePackage = true;
OCTAVE_HISTFILE = "/dev/null";
inherit src;
inherit dontPatch patches patchPhase;
dontConfigure = true;
enableParallelBuilding = enableParallelBuilding;
requiredOctavePackages = requiredOctavePackages';
nativeBuildInputs = nativeBuildInputs';
buildInputs = buildInputs ++ requiredOctavePackages';
propagatedBuildInputs = propagatedBuildInputs ++ [ texinfo ];
preBuild =
if preBuild == "" then
''
# This trickery is needed because Octave expects a single directory inside
# at the top-most level of the tarball.
tar --transform 's,^,${fullLibName}/,' -cz * -f ${fullLibName}.tar.gz
''
else
preBuild;
buildPhase = ''
runHook preBuild
mkdir -p $out
octave-cli --eval "pkg build $out ${fullLibName}.tar.gz"
runHook postBuild
'';
# We don't install here, because that's handled when we build the environment
# together with Octave.
dontInstall = true;
passthru = {
updateScript = [
../../../../maintainers/scripts/update-octave-packages
(builtins.unsafeGetAttrPos "pname" octave.pkgs.${attrs.pname}).file
];
}
// passthru
// {
tests = {
testOctaveBuildEnv = (octave.withPackages (os: [ finalAttrs.finalPackage ])).overrideAttrs (old: {
name = "${finalAttrs.name}-pkg-install";
});
testOctavePkgTests = callPackage ./run-pkg-test.nix { } finalAttrs.finalPackage;
}
// passthru.tests or { };
};
inherit meta;
}
// attrs'
)

View File

@@ -0,0 +1,247 @@
{
stdenv,
pkgs,
lib,
fetchurl,
gfortran,
ncurses,
perl,
flex,
testers,
texinfo,
qhull,
libsndfile,
portaudio,
libX11,
graphicsmagick,
pcre2,
pkg-config,
libGL,
libGLU,
fltk,
# Both are needed for discrete Fourier transform
fftw,
fftwSinglePrec,
zlib,
curl,
rapidjson,
blas,
lapack,
# These 3 should use the same lapack and blas as the above, see code prepending
qrupdate,
arpack,
suitesparse,
# If set to true, the above 5 deps are overridden to use the blas and lapack
# with 64 bit indexes support. If all are not compatible, the build will fail.
use64BitIdx ? false,
libwebp,
gl2ps,
ghostscript,
hdf5,
glpk,
gnuplot,
# - Include support for GNU readline:
enableReadline ? true,
readline,
# - Build Java interface:
enableJava ? true,
jdk,
python3,
sundials,
# - Packages required for building extra packages.
newScope,
callPackage,
makeSetupHook,
makeWrapper,
# - Build Octave Qt GUI:
enableQt ? false,
libsForQt5,
libiconv,
}:
let
# Not always evaluated
blas' =
if use64BitIdx then
blas.override {
isILP64 = true;
}
else
blas;
lapack' =
if use64BitIdx then
lapack.override {
isILP64 = true;
}
else
lapack;
qrupdate' = qrupdate.override {
# If use64BitIdx is false, this override doesn't evaluate to a new
# derivation, as blas and lapack are not overridden.
blas = blas';
lapack = lapack';
};
arpack' = arpack.override {
blas = blas';
lapack = lapack';
};
# We keep the option to not enable suitesparse support by putting it null
suitesparse' =
if suitesparse != null then
suitesparse.override {
blas = blas';
lapack = lapack';
}
else
null;
# To avoid confusion later in passthru
allPkgs = pkgs;
in
stdenv.mkDerivation (finalAttrs: {
version = "10.3.0";
pname = "octave";
src = fetchurl {
url = "mirror://gnu/octave/octave-${finalAttrs.version}.tar.gz";
sha256 = "sha256-L8s43AYuRA8eBsBpu8qEDtRtzI+YPkc+FVj8w4OE7ms=";
};
postPatch = ''
patchShebangs --build build-aux/*.pl
'';
buildInputs = [
readline
ncurses
flex
qhull
graphicsmagick
pcre2
fltk
zlib
curl
rapidjson
blas'
lapack'
libsndfile
fftw
fftwSinglePrec
portaudio
qrupdate'
arpack'
libwebp
gl2ps
ghostscript
hdf5
glpk
suitesparse'
sundials
gnuplot
python3
]
++ lib.optionals enableQt [
libsForQt5.qtbase
libsForQt5.qtsvg
libsForQt5.qscintilla
]
++ lib.optionals enableJava [
jdk
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
libGL
libGLU
libX11
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
libiconv
];
nativeBuildInputs = [
perl
pkg-config
gfortran
texinfo
]
++ lib.optionals enableQt [
libsForQt5.wrapQtAppsHook
libsForQt5.qtscript
libsForQt5.qttools
];
doCheck = !stdenv.hostPlatform.isDarwin;
enableParallelBuilding = true;
# Fix linker error on Darwin (see https://trac.macports.org/ticket/61865)
NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-lobjc";
# See https://savannah.gnu.org/bugs/?50339
F77_INTEGER_8_FLAG = lib.optionalString use64BitIdx "-fdefault-integer-8";
configureFlags = [
"--with-blas=blas"
"--with-lapack=lapack"
(if use64BitIdx then "--enable-64" else "--disable-64")
]
++ lib.optionals enableReadline [ "--enable-readline" ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ "--with-x=no" ]
++ lib.optionals enableQt [ "--with-qt=5" ];
# Keep a copy of the octave tests detailed results in the output
# derivation, because someone may care
postInstall = ''
cp test/fntests.log $out/share/octave/octave-${finalAttrs.version}-fntests.log || true
'';
passthru = rec {
sitePath = "share/octave/${finalAttrs.version}/site";
octPkgsPath = "share/octave/octave_packages";
blas = blas';
lapack = lapack';
qrupdate = qrupdate';
arpack = arpack';
suitesparse = suitesparse';
octavePackages = import ../../../top-level/octave-packages.nix {
pkgs = allPkgs;
inherit
lib
stdenv
fetchurl
newScope
;
octave = finalAttrs.finalPackage;
};
wrapOctave = callPackage ./wrap-octave.nix {
octave = finalAttrs.finalPackage;
inherit (allPkgs) makeSetupHook makeWrapper;
};
inherit fftw fftwSinglePrec;
inherit portaudio;
inherit jdk;
python = python3;
inherit enableQt enableReadline enableJava;
buildEnv = callPackage ./build-env.nix {
octave = finalAttrs.finalPackage;
inherit wrapOctave;
inherit (octavePackages) computeRequiredOctavePackages;
};
withPackages = import ./with-packages.nix { inherit buildEnv octavePackages; };
pkgs = octavePackages;
interpreter = "${finalAttrs.finalPackage}/bin/octave";
tests = {
wrapper = testers.testVersion {
package = finalAttrs.finalPackage.withPackages (ps: [ ps.doctest ]);
command = "octave --version";
};
};
};
meta = {
homepage = "https://www.gnu.org/software/octave/";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [
raskin
doronbehar
];
description = "Scientific Programming Language";
};
})

View File

@@ -0,0 +1,10 @@
# Hooks for building Octave packages.
{
makeSetupHook,
}:
{
writeRequiredOctavePackagesHook = makeSetupHook {
name = "write-required-octave-packages-hook";
} ./write-required-octave-packages-hook.sh;
}

View File

@@ -0,0 +1,17 @@
# Setup hook for writing octave packages that are run-time dependencies for
# another package to a nix-support file.
# `echo`s the full path name to the package derivation that is required.
echo "Sourcing write-required-octave-packages-hook.sh"
writeRequiredOctavePackagesPhase() {
echo "Executing writeRequiredOctavePackagesPhase"
mkdir -p $out/nix-support
echo ${requiredOctavePackages} > $out/nix-support/required-octave-packages
}
# Yes its a bit long...
if [ -z "${dontWriteRequiredOctavePackagesPhase-}" ]; then
echo "Using writeRequiredOctavePackagesPhase"
appendToVar preDistPhases writeRequiredOctavePackagesPhase
fi

View File

@@ -0,0 +1,25 @@
{
octave,
runCommand,
}:
package:
runCommand "${package.name}-pkg-test"
{
nativeBuildInputs = [
(octave.withPackages (os: [ package ]))
];
}
''
{ octave-cli --eval 'pkg test ${package.pname}' || touch FAILED_ERRCODE; } \
|& tee >( grep --quiet '^Failure Summary:$' && touch FAILED_OUTPUT || : ; cat >/dev/null )
if [[ -f FAILED_ERRCODE ]]; then
echo >&2 "octave-cli returned with non-zero exit code."
false
elif [[ -f FAILED_OUTPUT ]]; then
echo >&2 "Test failures detected in output."
false
else
touch $out
fi
''

View File

@@ -0,0 +1,10 @@
{ buildEnv, octavePackages }:
# Takes the buildEnv defined for Octave and the set of octavePackages, and returns
# a function, which when given a function whose return value is a list of extra
# packages to install, builds and returns that environment.
f:
let
packages = f octavePackages;
in
buildEnv.override { extraLibs = packages; }

View File

@@ -0,0 +1,16 @@
{
octave,
makeSetupHook,
makeWrapper,
}:
# Defined in trivial-builders
# Imported as wrapOctave in octave/default.nix and passed to octave's buildEnv
# as nativeBuildInput
# Each of the substitutions is available in the wrap.sh script as @thingSubstituted@
makeSetupHook {
name = "${octave.name}-pkgs-setup-hook";
propagatedBuildInputs = [ makeWrapper ];
substitutions.executable = octave.interpreter;
substitutions.octave = octave;
} ./wrap.sh

View File

@@ -0,0 +1,132 @@
# Unlinks a directory (given as the first argument), and re-creates that
# directory as an actual directory. Then descends into the directory of
# the same name in the origin (arg_2/arg_3) and symlinks the contents of
# that directory into the passed end-location.
unlinkDirReSymlinkContents() {
local dirToUnlink="$1"
local origin="$2"
local contentsLocation="$3"
unlink $dirToUnlink/$contentsLocation
mkdir -p $dirToUnlink/$contentsLocation
for f in $origin/$contentsLocation/*; do
ln -s -t "$dirToUnlink/$contentsLocation" "$f"
done
}
# Using unlinkDirReSymlinkContents, un-symlinks directories down to
# $out/share/octave, and then creates the octave_packages directory.
createOctavePackagesPath() {
local desiredOut=$1
local origin=$2
if [ -L "$out/share" ]; then
unlinkDirReSymlinkContents "$desiredOut" "$origin" "share"
fi
if [ -L "$out/share/octave" ]; then
unlinkDirReSymlinkContents "$desiredOut" "$origin" "share/octave"
fi
# Now that octave_packages has a path rather than symlinks, create the
# octave_packages directory for installed packages.
mkdir -p "$desiredOut/share/octave/octave_packages"
}
# First, descends down to $out/share/octave/site/m/startup/octaverc, and
# copies that start-up file. Once done, it performs a `chmod` to allow
# writing. Lastly, it `echo`s the location of the locally installed packages
# to the startup file, allowing octave to discover installed packages.
addPkgLocalList() {
local desiredOut=$1
local origin=$2
local octaveSite="share/octave/site"
local octaveSiteM="$octaveSite/m"
local octaveSiteStartup="$octaveSiteM/startup"
local siteOctavercStartup="$octaveSiteStartup/octaverc"
unlinkDirReSymlinkContents "$desiredOut" "$origin" "$octaveSite"
unlinkDirReSymlinkContents "$desiredOut" "$origin" "$octaveSiteM"
unlinkDirReSymlinkContents "$desiredOut" "$origin" "$octaveSiteStartup"
unlink "$out/$siteOctavercStartup"
cp "$origin/$siteOctavercStartup" "$desiredOut/$siteOctavercStartup"
chmod u+w "$desiredOut/$siteOctavercStartup"
echo "pkg local_list $out/.octave_packages" >> "$desiredOut/$siteOctavercStartup"
}
# Wrapper function for wrapOctaveProgramsIn. Takes one argument, a
# space-delimited string of packages' paths that will be installed.
wrapOctavePrograms() {
wrapOctaveProgramsIn "$out/bin" "$out" "$@"
}
# Wraps all octave programs in $out/bin with all the propagated inputs that
# a particular package requires. $1 is the directory to look for binaries in
# to wrap. $2 is the path to the octave ENVIRONMENT. $3 is the space-delimited
# string of packages.
wrapOctaveProgramsIn() {
local dir="$1"
local octavePath="$2"
local pkgs="$3"
local f
buildOctavePath "$octavePath" "$pkgs"
# Find all regular files in the output directory that are executable.
if [ -d "$dir" ]; then
find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do
echo "wrapping \`$f'..."
local -a wrap_args=("$f"
--prefix PATH ':' "$program_PATH"
)
local -a wrapProgramArgs=("${wrap_args[@]}")
wrapProgram "${wrapProgramArgs[@]}"
done
fi
}
# Build the PATH environment variable by walking through the closure of
# dependencies. Starts by constructing the `program_PATH` variable with the
# environment's path, then adding the original octave's location, and marking
# them in `octavePathsSeen`.
buildOctavePath() {
local octavePath="$1"
local packages="$2"
local pathsToSearch="$octavePath $packages"
# Create an empty table of Octave paths.
declare -A octavePathsSeen=()
program_PATH=
octavePathsSeen["$out"]=1
octavePathsSeen["@octave@"]=1
addToSearchPath program_PATH "$out/bin"
addToSearchPath program_PATH "@octave@/bin"
echo "program_PATH to change to is: $program_PATH"
for path in $pathsToSearch; do
echo "Recurse to propagated-build-input: $path"
_addToOctavePath $path
done
}
# Adds the bin directories to the program_PATH variable.
# Recurses on any paths declared in `propagated-build-inputs`, while avoiding
# duplicating paths by flagging the directires it has seen in `octavePathsSeen`.
_addToOctavePath() {
local dir="$1"
# Stop if we've already visited this path.
if [ -n "${octavePathsSeen[$dir]}" ]; then return; fi
octavePathsSeen[$dir]=1
# addToSearchPath is defined in stdenv/generic/setup.sh. It has the effect
# of calling `export X=$dir/...:$X`.
addToSearchPath program_PATH $dir/bin
# Inspect the propagated inputs (if they exist) and recur on them.
local prop="$dir/nix-support/propagated-build-inputs"
if [ -e $prop ]; then
for new_path in $(cat $prop); do
_addToOctavePath $new_path
done
fi
}

View File

@@ -0,0 +1,26 @@
commit 385e8759c3ff1e7f7f996bd4ea391074d61d48c1
Author: Karl Williamson <khw@cpan.org>
AuthorDate: 2024-12-18 18:25:29 -0700
Commit: Steve Hay <steve.m.hay@googlemail.com>
CommitDate: 2025-03-30 11:59:51 +0100
CVE-2024-56406: Heap-buffer-overflow with tr//
This was due to underallocating needed space. If the translation forces
something to become UTF-8 that is initially bytes, that UTF-8 could
now require two bytes where previously a single one would do.
(cherry picked from commit f93109c8a6950aafbd7488d98e112552033a3686)
diff --git a/op.c b/op.c
index 3fc23eca49a..aeee88e0335 100644
--- a/op.c
+++ b/op.c
@@ -6649,6 +6649,7 @@ S_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
* same time. But otherwise one crosses before the other */
if (t_cp < 256 && r_cp_end > 255 && r_cp != t_cp) {
can_force_utf8 = TRUE;
+ max_expansion = MAX(2, max_expansion);
}
}

Some files were not shown because too many files have changed in this diff Show More