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,88 @@
{
stdenv,
lib,
fetchFromGitHub,
gnat,
gprbuild,
gnatcoll-core,
component,
# component dependencies
gmp,
libiconv,
xz,
readline,
zlib,
python3,
ncurses,
}:
let
# omit python (2.7), no need to introduce a
# dependency on an EOL package for no reason
libsFor = {
iconv = [ libiconv ];
gmp = [ gmp ];
lzma = [ xz ];
readline = [ readline ];
python3 = [
python3
ncurses
];
syslog = [ ];
zlib = [ zlib ];
cpp = [ ];
};
in
stdenv.mkDerivation rec {
pname = "gnatcoll-${component}";
version = "25.0.0";
src = fetchFromGitHub {
owner = "AdaCore";
repo = "gnatcoll-bindings";
rev = "v${version}";
sha256 = "0ayc7zvv8w90v0xzhrjk2x88zrsk62xxcm27ya9crlp6affn5idk";
};
nativeBuildInputs = [
gprbuild
gnat
python3
];
# propagate since gprbuild needs to find referenced .gpr files
# and all dependency C libraries when statically linking a
# downstream executable.
propagatedBuildInputs = [
gnatcoll-core
]
++ libsFor."${component}" or [ ];
# explicit flag for GPL acceptance because upstream
# allows a gcc runtime exception for all bindings
# except for readline (since it is GPL w/o exceptions)
buildFlags = lib.optionals (component == "readline") [
"--accept-gpl"
];
buildPhase = ''
runHook preBuild
${python3.interpreter} ${component}/setup.py build --prefix $out $buildFlags
runHook postBuild
'';
installPhase = ''
runHook preInstall
${python3.interpreter} ${component}/setup.py install --prefix $out
runHook postInstall
'';
meta = with lib; {
description = "GNAT Components Collection - Bindings to C libraries";
homepage = "https://github.com/AdaCore/gnatcoll-bindings";
license = licenses.gpl3Plus;
platforms = platforms.all;
maintainers = [ maintainers.sternenseemann ];
};
}

View File

@@ -0,0 +1,88 @@
{
stdenv,
lib,
gnat,
gprbuild,
fetchFromGitHub,
fetchpatch2,
which,
python3,
rsync,
enableGnatcollCore ? true,
# TODO(@sternenseemann): figure out a way to split this up into three packages
enableGnatcollProjects ? true,
# for tests
gnatcoll-core,
}:
# gnatcoll-projects depends on gnatcoll-core
assert enableGnatcollProjects -> enableGnatcollCore;
stdenv.mkDerivation rec {
pname = "gnatcoll-core";
version = "25.0.0";
src = fetchFromGitHub {
owner = "AdaCore";
repo = "gnatcoll-core";
rev = "v${version}";
sha256 = "1srnh7vhs46c2zy4hcy4pg0a0prghfzlpv7c82k0jan384yz1g6g";
};
patches = [
# Fix compilation with GNAT 12 https://github.com/AdaCore/gnatcoll-core/issues/88
(fetchpatch2 {
name = "gnatcoll-core-gnat-12.patch";
url = "https://github.com/AdaCore/gnatcoll-core/commit/515db1c9f1eea8095f2d9ff9570159a78c981ec6.patch";
sha256 = "1ghnkhp5fncb7qcmf59kyqvy0sd0pzf1phnr2z7b4ljwlkbmcp36";
})
];
postPatch = ''
patchShebangs */*.gpr.py
'';
nativeBuildInputs = [
gprbuild
which
gnat
python3
rsync
];
# propagate since gprbuild needs to find
# referenced GPR project definitions
propagatedBuildInputs = lib.optionals enableGnatcollProjects [
gprbuild # libgpr
];
strictDeps = true;
makeFlags = [
"prefix=${placeholder "out"}"
"PROCESSORS=$(NIX_BUILD_CORES)"
# confusingly, for gprbuild --target is autoconf --host
"TARGET=${stdenv.hostPlatform.config}"
"GNATCOLL_MINIMAL_ONLY=${if !enableGnatcollCore then "yes" else "no"}"
"GNATCOLL_PROJECTS=${if enableGnatcollProjects then "yes" else "no"}"
];
passthru.tests = {
minimalOnly = gnatcoll-core.override {
enableGnatcollProjects = false;
enableGnatcollCore = false;
};
noProjects = gnatcoll-core.override {
enableGnatcollProjects = false;
enableGnatcollCore = true;
};
};
meta = with lib; {
homepage = "https://github.com/AdaCore/gnatcoll-core";
description = "GNAT Components Collection - Core packages";
license = licenses.gpl3Plus;
maintainers = [ maintainers.sternenseemann ];
platforms = platforms.all;
};
}

View File

@@ -0,0 +1,111 @@
{
stdenv,
lib,
fetchFromGitHub,
gnat,
gprbuild,
which,
gnatcoll-core,
component,
# components built by this derivation other components depend on
gnatcoll-sql,
gnatcoll-sqlite,
gnatcoll-xref,
# component specific extra dependencies
gnatcoll-iconv,
gnatcoll-readline,
sqlite,
libpq,
}:
let
libsFor = {
gnatcoll_db2ada = [
gnatcoll-sql
];
gnatinspect = [
gnatcoll-sqlite
gnatcoll-readline
gnatcoll-xref
];
postgres = [
gnatcoll-sql
libpq
];
sqlite = [
gnatcoll-sql
sqlite
];
xref = [
gnatcoll-iconv
gnatcoll-sqlite
];
};
# These components are just tools and don't install a library
onlyExecutable = builtins.elem component [
"gnatcoll_db2ada"
"gnatinspect"
];
in
stdenv.mkDerivation rec {
# executables don't adhere to the string gnatcoll-* scheme
pname =
if onlyExecutable then
builtins.replaceStrings [ "_" ] [ "-" ] component
else
"gnatcoll-${component}";
version = "25.0.0";
src = fetchFromGitHub {
owner = "AdaCore";
repo = "gnatcoll-db";
rev = "v${version}";
sha256 = "0q35ii0aa4hh59v768l5cilg1b30a4ckcvlbfy0lkcbp3rcfnbz3";
};
# Link executables dynamically unless specified by the platform,
# as we usually do in nixpkgs where possible
postPatch = lib.optionalString (!stdenv.hostPlatform.isStatic) ''
for f in gnatcoll_db2ada/Makefile gnatinspect/Makefile; do
substituteInPlace "$f" --replace "=static" "=relocatable"
done
'';
nativeBuildInputs = [
gnat
gprbuild
which
];
# Propagate since GPRbuild needs to find referenced .gpr files
# and other libraries to link against when static linking is used.
# For executables this is of course not relevant and we can reduce
# the closure size dramatically
${if onlyExecutable then "buildInputs" else "propagatedBuildInputs"} = [
gnatcoll-core
]
++ libsFor."${component}" or [ ];
makeFlags = [
"-C"
component
"PROCESSORS=$(NIX_BUILD_CORES)"
# confusingly, for gprbuild --target is autoconf --host
"TARGET=${stdenv.hostPlatform.config}"
"prefix=${placeholder "out"}"
]
++ lib.optionals (component == "sqlite") [
# link against packaged, not vendored libsqlite3
"GNATCOLL_SQLITE=external"
];
meta = with lib; {
description = "GNAT Components Collection - Database packages";
homepage = "https://github.com/AdaCore/gnatcoll-db";
license = licenses.gpl3Plus;
maintainers = [ maintainers.sternenseemann ];
platforms = platforms.all;
};
}

View File

@@ -0,0 +1,33 @@
From 7458110cc50d91cb7833b2abd232faca52865566 Mon Sep 17 00:00:00 2001
From: Thomas Heijligen <src@posteo.de>
Date: Tue, 21 May 2024 22:02:09 +0000
Subject: [PATCH] fix install
---
Makefile | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 4950b2d5cc..9d9358ad08 100644
--- a/Makefile
+++ b/Makefile
@@ -106,11 +106,11 @@ install:
$(CP) share/spark/theories/*why $(THEORIESDIR)
$(CP) share/spark/theories/*mlw $(THEORIESDIR)
$(CP) share/spark/runtimes/README $(RUNTIMESDIR)
- @echo "Generate Coq files by preprocessing context files:"
- $(MAKE) -C include generate
- $(CP) include/src/*.ad? $(INCLUDEDIR)
- $(CP) include/*.gpr $(LIBDIR)
- $(CP) include/proof $(LIBDIR)
+ #@echo "Generate Coq files by preprocessing context files:"
+ #$(MAKE) -C include generate
+ #$(CP) include/src/*.ad? $(INCLUDEDIR)
+ #$(CP) include/*.gpr $(LIBDIR)
+ #$(CP) include/proof $(LIBDIR)
doc: $(DOC)
--
2.44.0

View File

@@ -0,0 +1,22 @@
--- a/src/counterexamples/ce_parsing.adb 2025-03-14 21:48:15.657409808 +0100
+++ b/src/counterexamples/ce_parsing.adb 2025-03-14 22:04:32.114664704 +0100
@@ -975,6 +975,9 @@
elsif Is_Extended_Precision_Floating_Point_Type (Ty) then
pragma Assert (Size (Exp) = 15);
pragma Assert (Size (Significand) = 63);
+ pragma Warnings (Off, "assertion will fail at run time");
+ pragma Warnings (Off,
+ "types for unchecked conversion have different sizes");
declare
package P is new Parse_Conversion
(Interfaces.Unsigned_128, Long_Long_Float);
@@ -983,6 +986,9 @@
begin
return (Float_K, (Extended_K, F));
end;
+ pragma Warnings (On,
+ "types for unchecked conversion have different sizes");
+ pragma Warnings (On, "assertion will fail at run time");
else
raise Program_Error;
end if;

View File

@@ -0,0 +1,33 @@
From 3c06fb993ae628b5069c1f3e23f11c53815e1cbe Mon Sep 17 00:00:00 2001
From: Eric Botcazou <ebotcazou@adacore.com>
Date: Sat, 8 Mar 2025 00:09:57 +0100
Subject: [PATCH] Adjust after category change for N_Formal_Package_Declaration
Issue: eng/toolchain/gnat#1354
---
src/why/gnat2why-borrow_checker.adb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/why/gnat2why-borrow_checker.adb b/src/why/gnat2why-borrow_checker.adb
index a97f225b06..f3ab8be3e9 100644
--- a/src/why/gnat2why-borrow_checker.adb
+++ b/src/why/gnat2why-borrow_checker.adb
@@ -1693,6 +1693,7 @@ procedure Check_Declaration (Decl : Node_Id) is
-- Ignored constructs for pointer checking
when N_Formal_Object_Declaration
+ | N_Formal_Package_Declaration
| N_Formal_Type_Declaration
| N_Incomplete_Type_Declaration
| N_Private_Extension_Declaration
@@ -3326,7 +3327,6 @@ procedure Check_Node (N : Node_Id) is
| N_Empty
| N_Enumeration_Representation_Clause
| N_Exception_Renaming_Declaration
- | N_Formal_Package_Declaration
| N_Formal_Subprogram_Declaration
| N_Freeze_Entity
| N_Freeze_Generic_Entity
--
2.48.1

View File

@@ -0,0 +1,155 @@
{
stdenv,
lib,
fetchFromGitHub,
gnat,
gnatcoll-core,
gprbuild,
python3,
ocamlPackages,
makeWrapper,
gpr2,
}:
let
gnat_version = lib.versions.major gnat.version;
# gnatprove fsf-14 requires gpr2 from a special branch
gpr2_24_2_next =
(gpr2.override {
# pregenerated kb db is not included
gpr2kbdir = "${gprbuild}/share/gprconfig";
}).overrideAttrs
(old: rec {
version = "24.2.0-next";
src = fetchFromGitHub {
owner = "AdaCore";
repo = "gpr";
rev = "v${version}";
hash = "sha256-Tp+N9VLKjVWs1VRPYE0mQY3rl4E5iGb8xDoNatEYBg4=";
};
});
fetchSpark2014 =
{ rev, hash }:
fetchFromGitHub {
owner = "AdaCore";
repo = "spark2014";
fetchSubmodules = true;
inherit rev hash;
};
spark2014 = {
"12" = {
src = fetchSpark2014 {
rev = "ab34e07080a769b63beacc141707b5885c49d375"; # branch fsf-12
hash = "sha256-7pe3eWitpxmqzjW6qEIEuN0qr2IR+kJ7Ssc9pTBcCD8=";
};
commit_date = "2022-05-25";
};
"13" = {
src = fetchSpark2014 {
rev = "12db22e854defa9d1c993ef904af1e72330a68ca"; # branch fsf-13
hash = "sha256-mZWP9yF1O4knCiXx8CqolnS+93bM+hTQy40cd0HZmwI=";
};
commit_date = "2023-01-05";
patches = [
# Changes to the GNAT frontend: https://github.com/AdaCore/spark2014/issues/58
./0003-Adjust-after-category-change-for-N_Formal_Package_De.patch
];
};
"14" = {
src = fetchSpark2014 {
rev = "ce5fad038790d5dc18f9b5345dc604f1ccf45b06"; # branch fsf-14
hash = "sha256-WprJJIe/GpcdabzR2xC2dAV7kIYdNTaTpNYoR3UYTVo=";
};
patches = [
# Disable Coq related targets which are missing in the fsf-14 branch
./0001-fix-install.patch
# Suppress warnings on aarch64: https://github.com/AdaCore/spark2014/issues/54
./0002-mute-aarch64-warnings.patch
# Changes to the GNAT frontend: https://github.com/AdaCore/spark2014/issues/58
./0003-Adjust-after-category-change-for-N_Formal_Package_De.patch
];
commit_date = "2024-01-11";
};
};
thisSpark =
spark2014.${gnat_version}
or (throw "GNATprove depends on a specific GNAT version and can't be built using GNAT ${gnat_version}.");
in
stdenv.mkDerivation {
pname = "gnatprove";
version = "fsf-${gnat_version}_${thisSpark.commit_date}";
src = thisSpark.src;
patches = thisSpark.patches or [ ];
nativeBuildInputs = [
gnat
gprbuild
python3
makeWrapper
]
++ (with ocamlPackages; [
ocaml
findlib
menhir
]);
buildInputs = [
gnatcoll-core
]
++ (with ocamlPackages; [
ocamlgraph
zarith
ppx_deriving
ppx_sexp_conv
camlzip
menhirLib
num
re
sexplib
yojson
])
++ (lib.optionals (gnat_version == "14") [
gpr2_24_2_next
]);
propagatedBuildInputs = [
gprbuild
];
postPatch = ''
# gnat2why/gnat_src points to the GNAT sources
tar xf ${gnat.cc.src} --wildcards 'gcc-*/gcc/ada'
mv gcc-*/gcc/ada gnat2why/gnat_src
'';
configurePhase = ''
runHook preConfigure
make setup
runHook postConfigure
'';
installPhase = ''
runHook preInstall
make install-all
cp -a ./install/. $out
mkdir $out/share/gpr
ln -s $out/lib/gnat/* $out/share/gpr/
runHook postInstall
'';
meta = with lib; {
description = "Software development technology specifically designed for engineering high-reliability applications";
homepage = "https://github.com/AdaCore/spark2014";
maintainers = [ maintainers.jiegec ];
license = licenses.gpl3;
platforms = platforms.all;
};
}

View File

@@ -0,0 +1,72 @@
{
lib,
stdenv,
fetchurl,
gprbuild,
which,
gnat,
xmlada,
gnatcoll-core,
gnatcoll-iconv,
gnatcoll-gmp,
enableShared ? !stdenv.hostPlatform.isStatic,
# kb database source, if null assume it is pregenerated
gpr2kbdir ? null,
}:
stdenv.mkDerivation rec {
pname = "gpr2";
version = "25.0.0";
src = fetchurl {
url = "https://github.com/AdaCore/gpr/releases/download/v${version}/gpr2-with-gprconfig_kb-${lib.versions.majorMinor version}.tgz";
sha512 = "70fe0fcf541f6d3d90a34cab1638bbc0283dcd765c000406e0cfb73bae1817b30ddfe73f3672247a97c6b6bfc41900bc96a4440ca0c660f9c2f7b9d3cc8f8dcf";
};
nativeBuildInputs = [
which
gnat
gprbuild
];
makeFlags = [
"prefix=$(out)"
"PROCESSORS=$(NIX_BUILD_CORES)"
"ENABLE_SHARED=${if enableShared then "yes" else "no"}"
"GPR2_BUILD=release"
]
++ lib.optionals (gpr2kbdir != null) [
"GPR2KBDIR=${gpr2kbdir}"
];
configurePhase = ''
runHook preConfigure
make setup "''${makeFlagsArray[@]}" $makeFlags
runHook postConfigure
'';
# fool make into thinking pregenerated targets are up to date
preBuild = lib.optionalString (gpr2kbdir == null) ''
touch .build/kb/{*.adb,*.ads,collect_kb}
'';
propagatedBuildInputs = [
xmlada
gnatcoll-gmp
gnatcoll-core
gnatcoll-iconv
];
meta = with lib; {
description = "Framework for analyzing the GNAT Project (GPR) files";
homepage = "https://github.com/AdaCore/gpr";
license = with licenses; [
asl20
gpl3Only
];
maintainers = with maintainers; [ heijligen ];
platforms = platforms.all;
# TODO(@sternenseemann): investigate failure with gnat 13
broken = lib.versionOlder gnat.version "14";
};
}

View File

@@ -0,0 +1,99 @@
{
stdenv,
lib,
fetchFromGitHub,
gnat,
which,
xmlada, # for src
}:
let
version = "25.0.0";
gprConfigKbSrc = fetchFromGitHub {
name = "gprconfig-kb-${version}-src";
owner = "AdaCore";
repo = "gprconfig_kb";
rev = "v${version}";
sha256 = "09x1njq0i0z7fbwg0mg39r5ghy7369avbqvdycfj67lpmw17gb1r";
};
in
stdenv.mkDerivation {
pname = "gprbuild-boot";
inherit version;
src = fetchFromGitHub {
name = "gprbuild-${version}";
owner = "AdaCore";
repo = "gprbuild";
rev = "v${version}";
sha256 = "1mqsmc0q5bzg8223ls18kbvaz6mhzjz7ik8d3sqhhn24c0j6wjaw";
};
nativeBuildInputs = [
gnat
which
];
postPatch = ''
# The Makefile uses gprbuild to build gprbuild which
# we can't do at this point, delete it to prevent the
# default phases from failing.
rm Makefile
# make sure bootstrap script runs
patchShebangs --build bootstrap.sh
'';
# This setupHook populates GPR_PROJECT_PATH which is used by
# gprbuild to find dependencies. It works quite similar to
# the pkg-config setupHook in the sense that it also splits
# dependencies into GPR_PROJECT_PATH and GPR_PROJECT_PATH_FOR_BUILD,
# but gprbuild itself doesn't support this, so we'll need to
# introducing a wrapper for it in the future remains TODO.
# For the moment this doesn't matter since we have no situation
# were gprbuild is used to build something used at build time.
setupHooks = [
./gpr-project-path-hook.sh
]
++ lib.optionals stdenv.targetPlatform.isDarwin [
# This setupHook replaces the paths of shared libraries starting
# with @rpath with the absolute paths on Darwin, so that the
# binaries can be run without additional setup.
./gpr-project-darwin-rpath-hook.sh
];
installPhase = ''
runHook preInstall
./bootstrap.sh \
--with-xmlada=${xmlada.src} \
--with-kb=${gprConfigKbSrc} \
--prefix=$out
# Install custom compiler description which can detect nixpkgs'
# GNAT wrapper as a proper Ada compiler. The default compiler
# description expects the runtime library to be installed in
# the same prefix which isn't the case for nixpkgs. As a
# result, it would detect the unwrapped GNAT as a proper
# compiler which is unable to produce working binaries.
#
# Our compiler description is very similar to the upstream
# GNAT description except that we use a symlink in $out/nix-support
# created by the cc-wrapper to find the associated runtime
# libraries and use gnatmake instead of gnatls to find GNAT's
# bin directory.
install -m644 ${./nixpkgs-gnat.xml} $out/share/gprconfig/nixpkgs-gnat.xml
runHook postInstall
'';
meta = with lib; {
description = "Multi-language extensible build tool";
homepage = "https://github.com/AdaCore/gprbuild";
license = licenses.gpl3Plus;
maintainers = [ maintainers.sternenseemann ];
platforms = platforms.all;
};
}

View File

@@ -0,0 +1,79 @@
{
lib,
stdenv,
gprbuild-boot,
which,
gnat,
xmlada,
}:
stdenv.mkDerivation {
pname = "gprbuild";
# See ./boot.nix for an explanation of the gprbuild setupHook,
# our custom knowledge base entry and the situation wrt a
# (future) gprbuild wrapper.
inherit (gprbuild-boot)
version
src
setupHooks
meta
;
nativeBuildInputs = [
gnat
gprbuild-boot
which
];
propagatedBuildInputs = [
xmlada
];
makeFlags = [
"ENABLE_SHARED=${if stdenv.hostPlatform.isStatic then "no" else "yes"}"
"PROCESSORS=$(NIX_BUILD_CORES)"
# confusingly, for gprbuild --target is autoconf --host
"TARGET=${stdenv.hostPlatform.config}"
"prefix=${placeholder "out"}"
]
++ lib.optionals (!stdenv.hostPlatform.isStatic) [
"LIBRARY_TYPE=relocatable"
];
env = lib.optionalAttrs stdenv.hostPlatform.isDarwin {
# Ensure that there is enough space for the `fixDarwinDylibNames` hook to
# update the install names of the output dylibs.
NIX_LDFLAGS = "-headerpad_max_install_names";
};
# Fixes gprbuild being linked statically always. Based on the AUR's patch:
# https://aur.archlinux.org/cgit/aur.git/plain/0001-Makefile-build-relocatable-instead-of-static-binary.patch?h=gprbuild&id=bac524c76cd59c68fb91ef4dfcbe427357b9f850
patches = lib.optionals (!stdenv.hostPlatform.isStatic) [
./gprbuild-relocatable-build.patch
];
buildFlags = [
"all"
"libgpr.build"
];
installFlags = [
"all"
"libgpr.install"
];
# link gprconfig_kb db from gprbuild-boot into build dir,
# the install process copies its contents to $out
preInstall = ''
# Use PATH to discover spliced gprbuild-boot from buildPackages,
# since path interpolation would give us gprbuild-boot from pkgsHostTarget
gprbuild_boot="$(dirname "$(type -p gprbuild)")/.."
ln -sf "$gprbuild_boot/share/gprconfig" share/gprconfig
'';
# no need for the install script
postInstall = ''
rm $out/doinstall
'';
}

View File

@@ -0,0 +1,10 @@
fixGprProjectDarwinRpath() {
for f in $(find $out -type f -executable); do
install_name_tool -id $f $f || true
for rpath in $(otool -L $f | grep @rpath | awk '{print $1}'); do
install_name_tool -change $rpath ${!outputLib}/lib/$(basename $rpath) $f || true
done
done
}
appendToVar preFixupPhases fixGprProjectDarwinRpath

View File

@@ -0,0 +1,8 @@
addAdaObjectsPath() {
local role_post
getHostRoleEnvHook
addToSearchPath "GPR_PROJECT_PATH${role_post}" "$1/share/gpr"
}
addEnvHooks "$targetOffset" addAdaObjectsPath

View File

@@ -0,0 +1,13 @@
diff --git a/Makefile b/Makefile
index 8c542078..e91cef5e 100644
--- a/Makefile
+++ b/Makefile
@@ -82,7 +82,7 @@ LIB_INSTALLER=gprinstall -p -f --target=$(TARGET) $(RBD) "--prefix=${prefix}"
CLEANER=gprclean -q $(RBD)
GPRBUILD_BUILDER=$(BUILDER) $(GPRBUILD_GPR) \
- -XLIBRARY_TYPE=static -XXMLADA_BUILD=static
+ -XLIBRARY_TYPE=relocatable -XXMLADA_BUILD=relocatable
LIBGPR_BUILDER=$(BUILDER) $(GPR_GPR) $(LIBGPR_OS)
LIBGPR_INSTALLER=$(LIB_INSTALLER) $(GPR_GPR) $(LIBGPR_OS) -XBUILD=${BUILD} \
--install-name=gpr \

View File

@@ -0,0 +1,89 @@
<?xml version="1.0" ?>
<gprconfig>
<!-- This differs from the default GNAT compiler description
in the following ways:
* gnatmake is used over gnatls to detect the GNAT version
since the latter is not part of the wrapper.
* to find the runtime libraries, we rely on the symlink
../nix-support/gprconfig-gnat-unwrapped which is a
gprconfig-specific addition to the cc-wrapper we employ
for Ada compilers (which is only GNAT at the moment).
For documentation on this file format and its use refer to
https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/companion_tools.html#the-gprconfig-knowledge-base
-->
<compiler_description>
<!-- We would like to name this something different, so users
of gprconfig know this is something custom, nixpkgs-related,
but unfortunately the knowledge base depends on the name of
the compiler for e. g. linker settings.
-->
<name>GNAT</name>
<executable prefix="1">(.*-.*-.*)?gnatmake</executable>
<version>
<external>${PREFIX}gnatmake -v</external>
<grep regexp="^GNATMAKE.+?(\d+(\.\d+)?)" group="1"></grep>
</version>
<languages>Ada</languages>
<variable name="gcc_version">
<external>${PREFIX}gcc -v</external>
<grep regexp="^[-\w]*gcc \S+ (\S+)" group="1"></grep>
</variable>
<!-- The ada runtime libraries and objects are only part of the unwrapped
GNAT derivation. We can't symlink them into the wrapper derivation
(at least not the canonical location) since that screws with linking
against libraries distributed with gcc.
As a workaround, we create a symlink to the unwrapped GNAT's "out"
output in the cc-wrapper which we can read into a variable here and
use to find GNAT's Ada runtime.
-->
<variable name="gnat_unwrapped">
<external>readlink -n ${PATH}/../nix-support/gprconfig-gnat-unwrapped</external>
</variable>
<runtimes default="default,kernel,native">
<directory group="default" >$gnat_unwrapped/lib/gcc(-lib)?/$TARGET/$gcc_version/adalib/</directory>
<directory group="default" contents="^rts-">$gnat_unwrapped/lib/gcc(-lib)?/$TARGET/$gcc_version/ada_object_path</directory>
<directory group="2" >$gnat_unwrapped/lib/gcc(-lib)?/$TARGET/$gcc_version/rts-(.*)/adalib/</directory>
<directory group="1" >$gnat_unwrapped/$TARGET/lib/gnat/(.*)/adalib/</directory>
</runtimes>
<target>
<external>${PREFIX}gcc -dumpmachine</external>
<grep regexp="[^\r\n]+"></grep>
</target>
</compiler_description>
<configuration>
<!-- aarch64-linux - native compiler. -->
<targets>
<target name="^aarch64-unknown-linux-gnu$" />
</targets>
<hosts>
<host name="^aarch64-unknown-linux-gnu$" />
</hosts>
<config>
for Archive_Builder use ("ar", "cr");
for Archive_Builder_Append_Option use ("q");
for Archive_Indexer use ("ranlib");
for Archive_Suffix use ".a";
</config>
</configuration>
<configuration>
<!-- aarch64-linux - native compiler. -->
<targets>
<target name="^aarch64-unknown-linux-gnu$" />
</targets>
<hosts>
<host name="^aarch64-unknown-linux-gnu$" />
</hosts>
<config>
for Object_Lister use ("nm", "-g");
for Object_Lister_Matcher use " [TDRBSG] (.*)";
package Linker is
for Export_File_Format use "GNU";
for Export_File_Switch use "-Wl,--version-script=";
end Linker;
</config>
</configuration>
</gprconfig>

View File

@@ -0,0 +1,35 @@
{
stdenv,
lib,
fetchFromGitHub,
gnat,
# use gprbuild-boot since gprbuild proper depends
# on this xmlada derivation.
gprbuild-boot,
}:
stdenv.mkDerivation rec {
pname = "xmlada";
version = "25.0.0";
src = fetchFromGitHub {
name = "xmlada-${version}-src";
owner = "AdaCore";
repo = "xmlada";
rev = "v${version}";
sha256 = "sha256-UMJiXSHMS8+X5gyV1nmC29gF71BFnz7LNPQnwUMD3Yg=";
};
nativeBuildInputs = [
gnat
gprbuild-boot
];
meta = with lib; {
description = "XML/Ada: An XML parser for Ada";
homepage = "https://github.com/AdaCore/xmlada";
maintainers = [ maintainers.sternenseemann ];
license = licenses.gpl3Plus;
platforms = platforms.all;
};
}

View File

@@ -0,0 +1,201 @@
{
config,
lib,
stdenv,
makeWrapper,
runCommand,
wrapBintoolsWith,
wrapCCWith,
autoPatchelfHook,
llvmPackages,
buildAndroidndk,
androidndk,
targetAndroidndkPkgs,
}:
let
# Mapping from a platform to information needed to unpack NDK stuff for that
# platform.
#
# N.B. The Android NDK uses slightly different LLVM-style platform triples
# than we do. We don't just use theirs because ours are less ambiguous and
# some builds need that clarity.
#
ndkBuildInfoFun =
fallback:
{
x86_64-apple-darwin = {
double = "darwin-x86_64";
};
x86_64-unknown-linux-gnu = {
double = "linux-x86_64";
};
}
.${stdenv.buildPlatform.config} or fallback;
ndkTargetInfoFun =
fallback:
{
i686-unknown-linux-android = {
triple = "i686-linux-android";
arch = "x86";
};
x86_64-unknown-linux-android = {
triple = "x86_64-linux-android";
arch = "x86_64";
};
armv7a-unknown-linux-androideabi = {
arch = "arm";
triple = "arm-linux-androideabi";
};
aarch64-unknown-linux-android = {
arch = "arm64";
triple = "aarch64-linux-android";
};
}
.${stdenv.targetPlatform.config} or fallback;
buildInfo = ndkBuildInfoFun (
throw "Android NDK doesn't support building on ${stdenv.buildPlatform.config}, as far as we know"
);
targetInfo = ndkTargetInfoFun (
throw "Android NDK doesn't support targetting ${stdenv.targetPlatform.config}, as far as we know"
);
androidSdkVersion =
if
(stdenv.targetPlatform ? androidSdkVersion && stdenv.targetPlatform.androidSdkVersion != null)
then
stdenv.targetPlatform.androidSdkVersion
else
(throw "`androidSdkVersion` is not set during the importing of nixpkgs");
suffixSalt = lib.replaceStrings [ "-" "." ] [ "_" "_" ] stdenv.targetPlatform.config;
# targetInfo.triple is what Google thinks the toolchain should be, this is a little
# different from what we use. We make it four parts to conform with the existing
# standard more properly.
targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) (
stdenv.targetPlatform.config + "-"
);
in
if !config.allowAliases && (ndkBuildInfoFun null == null || ndkTargetInfoFun null == null) then
# Don't throw without aliases to not break CI.
null
else
lib.recurseIntoAttrs rec {
# Misc tools
binaries = stdenv.mkDerivation {
pname = "${targetPrefix}ndk-toolchain";
inherit (androidndk) version;
nativeBuildInputs = [
makeWrapper
autoPatchelfHook
];
propagatedBuildInputs = [ androidndk ];
passthru = {
inherit targetPrefix;
isClang = true; # clang based cc, but bintools ld
inherit (llvmPackages.clang.cc) hardeningUnsupportedFlagsByTargetPlatform;
};
dontUnpack = true;
dontBuild = true;
dontStrip = true;
dontConfigure = true;
dontPatch = true;
autoPatchelfIgnoreMissingDeps = true;
installPhase = ''
# https://developer.android.com/ndk/guides/other_build_systems
mkdir -p $out
cp -r ${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double} $out/toolchain
find $out/toolchain -type d -exec chmod 777 {} \;
if [ ! -d $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion} ]; then
echo "NDK does not contain libraries for SDK version ${androidSdkVersion}";
exit 1
fi
ln -vfs $out/toolchain/sysroot/usr/lib $out/lib
ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/*.so $out/lib/
ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/*.a $out/lib/
chmod +w $out/lib/*
ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion}/*.so $out/lib/
ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion}/*.o $out/lib/
echo "INPUT(-lc++_static)" > $out/lib/libc++.a
ln -s $out/toolchain/bin $out/bin
ln -s $out/toolchain/${targetInfo.triple}/bin/* $out/bin/
for f in $out/bin/${targetInfo.triple}-*; do
ln -s $f ''${f/${targetInfo.triple}-/${targetPrefix}}
done
for f in $(find $out/toolchain -type d -name ${targetInfo.triple}); do
ln -s $f ''${f/${targetInfo.triple}/${targetPrefix}}
done
rm -f $out/bin/${targetPrefix}ld
ln -s $out/bin/lld $out/bin/${targetPrefix}ld
(cd $out/bin;
for tool in llvm-*; do
ln -sf $tool ${targetPrefix}$(echo $tool | sed 's/llvm-//')
ln -sf $tool $(echo $tool | sed 's/llvm-//')
done)
ln -sf $out/bin/yasm $out/bin/${targetPrefix}as
ln -sf $out/bin/yasm $out/bin/as
patchShebangs $out/bin
'';
meta = {
description = "Android NDK toolchain, tuned for other platforms";
license = with lib.licenses; [ unfree ];
teams = [ lib.teams.android ];
};
};
binutils = wrapBintoolsWith {
bintools = binaries;
libc = targetAndroidndkPkgs.libraries;
};
clang = wrapCCWith {
cc = binaries // {
# for packages expecting libcompiler-rt, etc. to come from here (stdenv.cc.cc.lib)
lib = targetAndroidndkPkgs.libraries;
};
bintools = binutils;
libc = targetAndroidndkPkgs.libraries;
extraBuildCommands = ''
echo "-D__ANDROID_API__=${stdenv.targetPlatform.androidSdkVersion}" >> $out/nix-support/cc-cflags
# Android needs executables linked with -pie since version 5.0
# Use -fPIC for compilation, and link with -pie if no -shared flag used in ldflags
echo "-target ${targetInfo.triple} -fPIC" >> $out/nix-support/cc-cflags
echo "-z,noexecstack -z,relro -z,now -z,muldefs" >> $out/nix-support/cc-ldflags
echo 'expandResponseParams "$@"' >> $out/nix-support/add-flags.sh
echo 'if [[ ! (" ''${params[@]} " =~ " -shared ") && ! (" ''${params[@]} " =~ " -no-pie ") ]]; then NIX_LDFLAGS_${suffixSalt}+=" -pie"; fi' >> $out/nix-support/add-flags.sh
echo "-Xclang -mnoexecstack" >> $out/nix-support/cc-cxxflags
if [ ${targetInfo.triple} == arm-linux-androideabi ]; then
# https://android.googlesource.com/platform/external/android-cmake/+/refs/heads/cmake-master-dev/android.toolchain.cmake
echo "--fix-cortex-a8" >> $out/nix-support/cc-ldflags
fi
'';
};
# Bionic lib C and other libraries.
#
# We use androidndk from the previous stage, else we waste time or get cycles
# cross-compiling packages to wrap incorrectly wrap binaries we don't include
# anyways.
libraries = runCommand "bionic-prebuilt" { } ''
lpath=${buildAndroidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double}/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion}
if [ ! -d $lpath ]; then
echo "NDK does not contain libraries for SDK version ${androidSdkVersion} <$lpath>"
exit 1
fi
mkdir -p $out/lib
cp $lpath/*.so $lpath/*.a $out/lib
chmod +w $out/lib/*
cp $lpath/* $out/lib
'';
}

View File

@@ -0,0 +1,58 @@
{
lib,
androidenv,
buildPackages,
pkgs,
targetPackages,
config,
}:
let
makeNdkPkgs =
ndkVersion: llvmPackages:
let
buildAndroidComposition = buildPackages.buildPackages.androidenv.composeAndroidPackages {
includeNDK = true;
inherit ndkVersion;
};
androidComposition = androidenv.composeAndroidPackages {
includeNDK = true;
inherit ndkVersion;
};
majorVersion = lib.versions.major ndkVersion;
in
import ./androidndk-pkgs.nix {
inherit config lib;
inherit (buildPackages)
makeWrapper
autoPatchelfHook
;
inherit (pkgs)
stdenv
runCommand
wrapBintoolsWith
wrapCCWith
;
# For hardeningUnsupportedFlagsByTargetPlatform
inherit llvmPackages;
# buildPackages.foo rather than buildPackages.buildPackages.foo would work,
# but for splicing messing up on infinite recursion for the variants we
# *dont't* use. Using this workaround, but also making a test to ensure
# these two really are the same.
buildAndroidndk = buildAndroidComposition.ndk-bundle;
androidndk = androidComposition.ndk-bundle;
targetAndroidndkPkgs =
if targetPackages ? "androidndkPkgs_${majorVersion}" then
targetPackages."androidndkPkgs_${majorVersion}"
else
throw "androidndkPkgs_${majorVersion}: no targetPackages, use `buildPackages.androidndkPkgs_${majorVersion}";
};
in
lib.recurseIntoAttrs {
"27" = makeNdkPkgs "27.0.12077973" pkgs.llvmPackages_18;
"28" = makeNdkPkgs "28.0.13004108" pkgs.llvmPackages_19;
}

View File

@@ -0,0 +1,136 @@
{
stdenv,
writeText,
erlang,
perl,
which,
gitMinimal,
wget,
lib,
}:
{
name,
version,
src,
setupHook ? null,
buildInputs ? [ ],
beamDeps ? [ ],
postPatch ? "",
compilePorts ? false,
installPhase ? null,
buildPhase ? null,
configurePhase ? null,
meta ? { },
enableDebugInfo ? false,
buildFlags ? [ ],
...
}@attrs:
let
debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "+debug_info";
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.name}";
buildInputs = [ drv ];
};
pkg =
self:
stdenv.mkDerivation (
attrs
// {
app_name = name;
name = "${name}-${version}";
inherit version;
dontStrip = true;
inherit src;
setupHook =
if setupHook == null then
writeText "setupHook.sh" ''
addToSearchPath ERL_LIBS "$1/lib/erlang/lib"
''
else
setupHook;
buildInputs = buildInputs ++ [
erlang
perl
which
gitMinimal
wget
];
propagatedBuildInputs = beamDeps;
buildFlags = [
"SKIP_DEPS=1"
]
++ lib.optional (enableDebugInfo || erlang.debugInfo) ''ERL_OPTS="$ERL_OPTS +debug_info"''
++ buildFlags;
configurePhase =
if configurePhase == null then
''
runHook preConfigure
# We shouldnt need to do this, but it seems at times there is a *.app in
# the repo/package. This ensures we start from a clean slate
make SKIP_DEPS=1 clean
runHook postConfigure
''
else
configurePhase;
buildPhase =
if buildPhase == null then
''
runHook preBuild
make $buildFlags "''${buildFlagsArray[@]}"
runHook postBuild
''
else
buildPhase;
installPhase =
if installPhase == null then
''
runHook preInstall
mkdir -p $out/lib/erlang/lib/${name}
cp -r ebin $out/lib/erlang/lib/${name}/
cp -r src $out/lib/erlang/lib/${name}/
if [ -d include ]; then
cp -r include $out/lib/erlang/lib/${name}/
fi
if [ -d priv ]; then
cp -r priv $out/lib/erlang/lib/${name}/
fi
if [ -d doc ]; then
cp -r doc $out/lib/erlang/lib/${name}/
fi
runHook postInstall
''
else
installPhase;
passthru = {
packageName = name;
env = shell self;
inherit beamDeps;
};
}
);
in
lib.fix pkg

View File

@@ -0,0 +1,31 @@
{
lib,
buildRebar3,
fetchHex,
}:
{
name,
version,
sha256,
builder ? buildRebar3,
hexPkg ? name,
...
}@attrs:
let
pkg =
self:
builder (
attrs
// {
src = fetchHex {
pkg = hexPkg;
inherit version;
inherit sha256;
};
}
);
in
lib.fix pkg

View File

@@ -0,0 +1,157 @@
{
stdenv,
writeText,
elixir,
erlang,
hex,
lib,
}:
{
name,
version,
src,
buildInputs ? [ ],
nativeBuildInputs ? [ ],
erlangCompilerOptions ? [ ],
# Deterministic Erlang builds remove full system paths from debug information
# among other things to keep builds more reproducible. See their docs for more:
# https://www.erlang.org/doc/man/compile
erlangDeterministicBuilds ? true,
beamDeps ? [ ],
propagatedBuildInputs ? [ ],
postPatch ? "",
compilePorts ? false,
meta ? { },
enableDebugInfo ? false,
mixEnv ? "prod",
mixTarget ? "host",
removeConfig ? true,
# A config directory that is considered for all the dependencies of an app, typically in $src/config/
# This was initially added, as some of Mobilizon's dependencies need to access the config at build time.
appConfigPath ? null,
...
}@attrs:
assert appConfigPath != null -> removeConfig;
let
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.name}";
buildInputs = [ drv ];
};
pkg =
self:
stdenv.mkDerivation (
attrs
// {
name = "${name}-${version}";
inherit version src;
MIX_ENV = mixEnv;
MIX_TARGET = mixTarget;
MIX_BUILD_PREFIX = (if mixTarget == "host" then "" else "${mixTarget}_") + "${mixEnv}";
MIX_DEBUG = if enableDebugInfo then 1 else 0;
HEX_OFFLINE = 1;
ERL_COMPILER_OPTIONS =
let
options = erlangCompilerOptions ++ lib.optionals erlangDeterministicBuilds [ "deterministic" ];
in
"[${lib.concatStringsSep "," options}]";
LANG = if stdenv.hostPlatform.isLinux then "C.UTF-8" else "C";
LC_CTYPE = if stdenv.hostPlatform.isLinux then "C.UTF-8" else "UTF-8";
# add to ERL_LIBS so other modules can find at runtime.
# http://erlang.org/doc/man/code.html#code-path
# Mix also searches the code path when compiling with the --no-deps-check flag
setupHook = attrs.setupHook or writeText "setupHook.sh" ''
addToSearchPath ERL_LIBS "$1/lib/erlang/lib"
'';
buildInputs = buildInputs ++ [ ];
nativeBuildInputs = nativeBuildInputs ++ [
elixir
hex
];
propagatedBuildInputs = propagatedBuildInputs ++ beamDeps;
configurePhase =
attrs.configurePhase or ''
runHook preConfigure
${./mix-configure-hook.sh}
${lib.optionalString (removeConfig && isNull appConfigPath)
# By default, we don't want to include whatever config a dependency brings; per
# https://hexdocs.pm/elixir/main/Config.html, config is application specific.
''
rm -rf config
mkdir config
''
}
${lib.optionalString (!isNull appConfigPath)
# Some more tightly-coupled dependencies do depend on the config of the application
# they're being built for.
''
rm -rf config
cp -r ${appConfigPath} config
''
}
runHook postConfigure
'';
buildPhase =
attrs.buildPhase or ''
runHook preBuild
export HEX_HOME="$TEMPDIR/hex"
export MIX_HOME="$TEMPDIR/mix"
mix compile --no-deps-check
runHook postBuild
'';
installPhase =
attrs.installPhase or ''
runHook preInstall
# This uses the install path convention established by nixpkgs maintainers
# for all beam packages. Changing this will break compatibility with other
# builder functions like buildRebar3 and buildErlangMk.
mkdir -p "$out/lib/erlang/lib/${name}-${version}"
# Some packages like db_connection will use _build/shared instead of
# honoring the $MIX_ENV variable.
for reldir in _build/{$MIX_BUILD_PREFIX,shared}/lib/${name}/{src,ebin,priv,include} ; do
if test -d $reldir ; then
# Some builds produce symlinks (eg: phoenix priv dircetory). They must
# be followed with -H flag.
cp -Hrt "$out/lib/erlang/lib/${name}-${version}" "$reldir"
fi
done
# Copy the source so it can be used by dependent packages. For example,
# phoenix applications need the source of phoenix and phoenix_html to
# build javascript and css assets.
mkdir -p $out/src
cp -r "$src/." "$out/src"
runHook postInstall
'';
# stripping does not have any effect on beam files
# it is however needed for dependencies with NIFs like bcrypt for example
dontStrip = false;
passthru = {
packageName = name;
env = shell self;
inherit beamDeps;
};
}
);
in
lib.fix pkg

View File

@@ -0,0 +1,123 @@
{
stdenv,
writeText,
erlang,
rebar3WithPlugins,
openssl,
libyaml,
lib,
}:
{
name,
version,
src,
setupHook ? null,
buildInputs ? [ ],
beamDeps ? [ ],
buildPlugins ? [ ],
postPatch ? "",
installPhase ? null,
buildPhase ? null,
configurePhase ? null,
meta ? { },
erlangCompilerOptions ? [ ],
# Deterministic Erlang builds remove full system paths from debug information
# among other things to keep builds more reproducible. See their docs for more:
# https://www.erlang.org/doc/man/compile
erlangDeterministicBuilds ? true,
...
}@attrs:
let
rebar3 = rebar3WithPlugins {
plugins = buildPlugins;
};
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.name}";
buildInputs = [ drv ];
};
customPhases = lib.filterAttrs (_: v: v != null) {
inherit
setupHook
configurePhase
buildPhase
installPhase
;
};
pkg =
self:
stdenv.mkDerivation (
attrs
// {
name = "${name}-${version}";
inherit version;
buildInputs = buildInputs ++ [
erlang
rebar3
openssl
libyaml
];
propagatedBuildInputs = lib.unique beamDeps;
inherit src;
ERL_COMPILER_OPTIONS =
let
options = erlangCompilerOptions ++ lib.optionals erlangDeterministicBuilds [ "deterministic" ];
in
"[${lib.concatStringsSep "," options}]";
# stripping does not have any effect on beam files
# it is however needed for dependencies with NIFs
# false is the default but we keep this for readability
dontStrip = false;
setupHook = writeText "setupHook.sh" ''
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
'';
postPatch = ''
rm -f rebar rebar3
''
+ postPatch;
buildPhase = ''
runHook preBuild
HOME=. rebar3 bare compile --paths "."
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/lib/erlang/lib/${name}-${version}"
for reldir in src ebin priv include; do
[ -d "$reldir" ] || continue
# $out/lib/erlang/lib is a convention used in nixpkgs for compiled BEAM packages
cp -Hrt "$out/lib/erlang/lib/${name}-${version}" "$reldir"
done
runHook postInstall
'';
meta = {
inherit (erlang.meta) platforms;
}
// meta;
passthru = {
packageName = name;
env = shell self;
inherit beamDeps;
};
}
// customPhases
);
in
lib.fix pkg

View File

@@ -0,0 +1,98 @@
{
lib,
__splicedPackages,
erlang,
}:
let
pkgs = __splicedPackages;
inherit (lib) makeExtensible;
lib' = pkgs.callPackage ./lib.nix { };
# FIXME: add support for overrideScope
callPackageWithScope =
scope: drv: args:
lib.callPackageWith scope drv args;
mkScope = scope: pkgs // scope;
packages =
self:
let
defaultScope = mkScope self;
callPackage = drv: args: callPackageWithScope defaultScope drv args;
in
rec {
inherit callPackage erlang;
beamPackages = self;
inherit (callPackage ../tools/build-managers/rebar3 { }) rebar3 rebar3WithPlugins;
rebar = callPackage ../tools/build-managers/rebar { };
pc = callPackage ./pc { };
rebar3-proper = callPackage ./rebar3-proper { };
rebar3-nix = callPackage ./rebar3-nix { };
fetchHex = callPackage ./fetch-hex.nix { };
fetchRebar3Deps = callPackage ./fetch-rebar-deps.nix { };
rebar3Relx = callPackage ./rebar3-release.nix { };
buildRebar3 = callPackage ./build-rebar3.nix { };
buildHex = callPackage ./build-hex.nix { };
buildErlangMk = callPackage ./build-erlang-mk.nix { };
buildMix = callPackage ./build-mix.nix { };
fetchMixDeps = callPackage ./fetch-mix-deps.nix { };
mixRelease = callPackage ./mix-release.nix { };
erlfmt = callPackage ./erlfmt { };
elvis-erlang = callPackage ./elvis-erlang { };
# BEAM-based languages.
elixir = elixir_1_18;
elixir_1_19 = lib'.callElixir ../interpreters/elixir/1.19.nix {
inherit erlang;
debugInfo = true;
};
elixir_1_18 = lib'.callElixir ../interpreters/elixir/1.18.nix {
inherit erlang;
debugInfo = true;
};
elixir_1_17 = lib'.callElixir ../interpreters/elixir/1.17.nix {
inherit erlang;
debugInfo = true;
};
elixir_1_16 = lib'.callElixir ../interpreters/elixir/1.16.nix {
inherit erlang;
debugInfo = true;
};
elixir_1_15 = lib'.callElixir ../interpreters/elixir/1.15.nix {
inherit erlang;
debugInfo = true;
};
# Remove old versions of elixir, when the supports fades out:
# https://hexdocs.pm/elixir/compatibility-and-deprecations.html
ex_doc = callPackage ./ex_doc {
inherit fetchMixDeps mixRelease;
};
elixir-ls = callPackage ./elixir-ls { inherit elixir; };
lfe = callPackage ../interpreters/lfe { inherit erlang buildRebar3 buildHex; };
livebook = callPackage ./livebook { inherit beamPackages; };
# Non hex packages. Examples how to build Rebar/Mix packages with and
# without helper functions buildRebar3 and buildMix.
hex = callPackage ./hex { };
webdriver = callPackage ./webdriver { };
};
in
makeExtensible packages

View File

@@ -0,0 +1,70 @@
{
lib,
elixir,
fetchFromGitHub,
makeWrapper,
stdenv,
nix-update-script,
}:
stdenv.mkDerivation rec {
pname = "elixir-ls";
version = "0.29.3";
src = fetchFromGitHub {
owner = "elixir-lsp";
repo = "elixir-ls";
rev = "v${version}";
hash = "sha256-ikx0adlDrkUpMXPEbPtIsb2/1wcOt1jLwciVdBEKnss=";
};
patches = [
# patch wrapper script to remove elixir detection and inject necessary paths
./launch.sh.patch
];
nativeBuildInputs = [
makeWrapper
];
# for substitution
env.elixir = elixir;
dontConfigure = true;
dontBuild = true;
installPhase = ''
cp -R . $out
ln -s $out/VERSION $out/scripts/VERSION
substituteAllInPlace $out/scripts/launch.sh
mkdir -p $out/bin
makeWrapper $out/scripts/language_server.sh $out/bin/elixir-ls \
--set ELS_LOCAL "1"
makeWrapper $out/scripts/debug_adapter.sh $out/bin/elixir-debug-adapter \
--set ELS_LOCAL "1"
runHook postInstall
'';
meta = with lib; {
homepage = "https://github.com/elixir-lsp/elixir-ls";
description = ''
A frontend-independent IDE "smartness" server for Elixir.
Implements the "Language Server Protocol" standard and provides debugger support via the "Debug Adapter Protocol"
'';
longDescription = ''
The Elixir Language Server provides a server that runs in the background, providing IDEs, editors, and other tools with information about Elixir Mix projects.
It adheres to the Language Server Protocol, a standard for frontend-independent IDE support.
Debugger integration is accomplished through the similar VS Code Debug Protocol.
'';
license = licenses.asl20;
platforms = platforms.unix;
mainProgram = "elixir-ls";
teams = [ teams.beam ];
};
passthru.updateScript = nix-update-script { };
}

View File

@@ -0,0 +1,162 @@
diff --git c/scripts/launch.sh w/scripts/launch.sh
index d9c33952..8bc5c382 100755
--- c/scripts/launch.sh
+++ w/scripts/launch.sh
@@ -1,114 +1,4 @@
-#!/bin/sh
-# Actual launcher. This does the hard work of figuring out the best way
-# to launch the language server or the debug adapter.
-
-# Running this script is a one-time action per project launch, so we opt for
-# code simplicity instead of performance. Hence some potentially redundant
-# moves here.
-
-
-did_relaunch=$1
-
-# Get the user's preferred shell
-preferred_shell=$(basename "$SHELL")
-
-# Get current dirname
-dirname=$(dirname "$0")
-
-case "${did_relaunch}" in
- "")
- if [ "$preferred_shell" = "bash" ]; then
- >&2 echo "Preferred shell is bash, relaunching"
- exec "$(which bash)" "$0" relaunch
- elif [ "$preferred_shell" = "zsh" ]; then
- >&2 echo "Preferred shell is zsh, relaunching"
- exec "$(which zsh)" "$0" relaunch
- elif [ "$preferred_shell" = "fish" ]; then
- >&2 echo "Preferred shell is fish, launching launch.fish"
- exec "$(which fish)" "$dirname/launch.fish"
- else
- >&2 echo "Preferred shell $preferred_shell is not supported, continuing in POSIX shell"
- fi
- ;;
- *)
- # We have an arg2, so we got relaunched
- ;;
-esac
-
-# First order of business, see whether we can setup asdf
-echo "Looking for asdf install" >&2
-
-readlink_f () {
- cd "$(dirname "$1")" > /dev/null || exit 1
- filename="$(basename "$1")"
- if [ -h "$filename" ]; then
- readlink_f "$(readlink "$filename")"
- else
- echo "$(pwd -P)/$filename"
- fi
-}
-
-export_stdlib_path () {
- which_elixir_expr=$1
- stdlib_path=$(eval "$which_elixir_expr")
- stdlib_real_path=$(readlink_f "$stdlib_path")
- ELX_STDLIB_PATH=$(echo "$stdlib_real_path" | sed "s/\(.*\)\/bin\/elixir/\1/")
- export ELX_STDLIB_PATH
-}
-
-# Check if we have the asdf binary for version >= 0.16.0
-if command -v asdf >/dev/null 2>&1; then
- asdf_version=$(asdf --version 2>/dev/null)
- version=$(echo "$asdf_version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
- major=$(echo "$version" | cut -d. -f1)
- minor=$(echo "$version" | cut -d. -f2)
- # If the version is less than 0.16.0 (i.e. major = 0 and minor < 16), use legacy method.
- if [ "$major" -eq 0 ] && [ "$minor" -lt 16 ]; then
- ASDF_DIR=${ASDF_DIR:-"${HOME}/.asdf"}
- ASDF_SH="${ASDF_DIR}/asdf.sh"
- if test -f "$ASDF_SH"; then
- >&2 echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing"
- # Source the old asdf.sh script for versions <= 0.15.0
- . "$ASDF_SH"
- else
- >&2 echo "Legacy asdf not found at $ASDF_SH"
- fi
- else
- >&2 echo "asdf executable found at $(command -v asdf). Using ASDF_DIR=${ASDF_DIR}, ASDF_DATA_DIR=${ASDF_DATA_DIR}."
- fi
- export_stdlib_path "asdf which elixir"
-else
- # Fallback to old method for version <= 0.15.x
- ASDF_DIR=${ASDF_DIR:-"${HOME}/.asdf"}
- ASDF_SH="${ASDF_DIR}/asdf.sh"
- if test -f "$ASDF_SH"; then
- >&2 echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing"
- # Source the old asdf.sh script for versions <= 0.15.0
- . "$ASDF_SH"
- export_stdlib_path "asdf which elixir"
- else
- >&2 echo "asdf not found"
- >&2 echo "Looking for mise executable"
-
- # Look for mise executable
- if command -v mise >/dev/null 2>&1; then
- >&2 echo "mise executable found at $(command -v mise), activating"
- eval "$($(command -v mise) env -s "$preferred_shell")"
- export_stdlib_path "mise which elixir"
- else
- >&2 echo "mise not found"
- >&2 echo "Looking for vfox executable"
-
- if command -v vfox >/dev/null 2>&1; then
- >&2 echo "vfox executable found at $(command -v vfox), activating"
- eval "$( $(command -v vfox) activate "$preferred_shell" )"
- else
- >&2 echo "vfox not found"
- export_stdlib_path "which elixir"
- fi
- fi
- fi
-fi
+#!/usr/bin/env bash
# In case that people want to tweak the path, which Elixir to use, or
# whatever prior to launching the language server or the debug adapter, we
@@ -127,29 +17,22 @@ fi
# script so we can correctly configure the Erlang library path to
# include the local .ez files, and then do what we were asked to do.
-if [ -z "${ELS_INSTALL_PREFIX}" ]; then
- SCRIPT=$(readlink_f "$0")
- SCRIPTPATH=$(dirname "$SCRIPT")
-else
- SCRIPTPATH=${ELS_INSTALL_PREFIX}
-fi
+SCRIPT=$(readlink -f "$0")
+SCRIPTPATH=$(dirname "$SCRIPT")/../scripts
export MIX_ENV=prod
# Mix.install prints to stdout and reads from stdin
# we need to make sure it doesn't interfere with LSP/DAP
-echo "" | elixir "$SCRIPTPATH/quiet_install.exs" >/dev/null || exit 1
+echo "" | @elixir@/bin/elixir "$SCRIPTPATH/quiet_install.exs" >/dev/null || exit 1
default_erl_opts="-kernel standard_io_encoding latin1 +sbwt none +sbwtdcpu none +sbwtdio none"
-if [ "$preferred_shell" = "bash" ]; then
- . "$dirname/exec.bash"
-elif [ "$preferred_shell" = "zsh" ]; then
- . "$dirname/exec.zsh"
-else
- if [ -z "$ELS_ELIXIR_OPTS" ]
- then
- # in posix shell does not support arrays
- >&2 echo "ELS_ELIXIR_OPTS is not supported in current shell"
- fi
- exec elixir --erl "$default_erl_opts $ELS_ERL_OPTS" "$SCRIPTPATH/launch.exs"
-fi
+# ensure elixir stdlib can be found
+ELX_STDLIB_PATH=${ELX_STDLIB_PATH:-@elixir@/lib/elixir}
+export ELX_STDLIB_PATH
+
+# ensure our elixir is in the path
+PATH="@elixir@/bin:$PATH"
+export PATH
+
+source "$SCRIPTPATH/exec.bash"

View File

@@ -0,0 +1,58 @@
{
buildRebar3,
fetchFromGitHub,
fetchHex,
fetchgit,
lib,
rebar3Relx,
writeScript,
}:
rebar3Relx rec {
releaseType = "escript";
pname = "elvis-erlang";
version = "4.1.1";
src = fetchFromGitHub {
owner = "inaka";
repo = "elvis";
hash = "sha256-9aOJpKYb+M07bi6aEMt5Gtr/edOGm+jyA8bxiLyUd0g=";
tag = version;
};
beamDeps = builtins.attrValues (
import ./rebar-deps.nix {
inherit fetchHex fetchgit fetchFromGitHub;
builder = buildRebar3;
}
);
passthru.updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash common-updater-scripts git nix-prefetch-git gnutar gzip "rebar3WithPlugins {globalPlugins = [beamPackages.rebar3-nix];}"
set -euo pipefail
latest=$(list-git-tags | sort -V | tail -1)
if [ "$latest" != "${version}" ]; then
nixpkgs="$(git rev-parse --show-toplevel)"
nix_path="$nixpkgs/pkgs/development/beam-modules/elvis-erlang"
update-source-version elvis-erlang "$latest" --version-key=version --print-changes --file="$nix_path/default.nix"
tmpdir=$(mktemp -d)
cp -R $(nix-build $nixpkgs --no-out-link -A elvis-erlang.src)/* "$tmpdir"
(cd "$tmpdir" && HOME=. rebar3 nix lock -o "$nix_path/rebar-deps.nix")
nixfmt "$nix_path/rebar-deps.nix"
else
echo "elvis-erlang is already up-to-date"
fi
'';
meta = {
homepage = "https://github.com/inaka/elvis";
description = "Erlang Style Reviewer";
platforms = lib.platforms.unix;
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ dlesl ];
mainProgram = "elvis";
};
}

View File

@@ -0,0 +1,193 @@
# Generated by rebar3_nix
let
fetchOnly = { src, ... }: src;
in
{
builder ? fetchOnly,
fetchHex,
fetchgit,
fetchFromGitHub,
overrides ? (x: y: { }),
}:
let
self = packages // (overrides self packages);
packages = with self; {
unicode_util_compat = builder {
name = "unicode_util_compat";
version = "0.7.1";
src = fetchHex {
pkg = "unicode_util_compat";
version = "0.7.1";
sha256 = "sha256-s6kXhUzjriM2GXRK0eAQLgVnMTZ3b7L6diNPPgOyNkI=";
};
beamDeps = [ ];
};
ssl_verify_fun = builder {
name = "ssl_verify_fun";
version = "1.1.7";
src = fetchHex {
pkg = "ssl_verify_fun";
version = "1.1.7";
sha256 = "sha256-/kwZDo83QB0wFnyMQF7aGUafNFd5h8dt3mE+g4u8Z/g=";
};
beamDeps = [ ];
};
parse_trans = builder {
name = "parse_trans";
version = "3.4.2";
src = fetchHex {
pkg = "parse_trans";
version = "3.4.2";
sha256 = "sha256-TCU0feO3w1cy0y5pq0PRzu4L6uPzs63htZy9PdIk2co=";
};
beamDeps = [ ];
};
mimerl = builder {
name = "mimerl";
version = "1.4.0";
src = fetchHex {
pkg = "mimerl";
version = "1.4.0";
sha256 = "sha256-E68V+faMZYhOzKOjiR1Qp7V9ghUnkvPhnYhlCqEmsUQ=";
};
beamDeps = [ ];
};
metrics = builder {
name = "metrics";
version = "1.0.1";
src = fetchHex {
pkg = "metrics";
version = "1.0.1";
sha256 = "sha256-abCa3dxPdKQHFq5U0UD5O+sPuJeNhjbq3tDDG28JnxY=";
};
beamDeps = [ ];
};
idna = builder {
name = "idna";
version = "6.1.1";
src = fetchHex {
pkg = "idna";
version = "6.1.1";
sha256 = "sha256-kjdut4lEEu0ZrEdeSob3tBPBufu1vRbczVeTQVeUTOo=";
};
beamDeps = [ unicode_util_compat ];
};
certifi = builder {
name = "certifi";
version = "2.15.0";
src = fetchHex {
pkg = "certifi";
version = "2.15.0";
sha256 = "sha256-sUftIs5x1y6v2tlPBVFlwcGC9hov9J3yi8xx0dW5SmA=";
};
beamDeps = [ ];
};
zipper = builder {
name = "zipper";
version = "1.1.0";
src = fetchHex {
pkg = "zipper";
version = "1.1.0";
sha256 = "sha256-RkTIOug+88CYYMte1Zewx1n7vNZK1bAKYvUa5IrvdTU=";
};
beamDeps = [ ];
};
lager = builder {
name = "lager";
version = "3.9.1";
src = fetchHex {
pkg = "lager";
version = "3.9.1";
sha256 = "sha256-P1m6daBKmeXxi/kcifRtzlNvg8bLQV/ibm51pivvN9w=";
};
beamDeps = [ goldrush ];
};
katana_code = builder {
name = "katana_code";
version = "2.4.1";
src = fetchHex {
pkg = "katana_code";
version = "2.4.1";
sha256 = "sha256-WO/GO12dq8giMMq1DN5/eyWSh6aQ7Wmfeaf6gPSbCzo=";
};
beamDeps = [ ];
};
jsx = builder {
name = "jsx";
version = "2.10.0";
src = fetchHex {
pkg = "jsx";
version = "2.10.0";
sha256 = "sha256-moPjcEgHKYAWlo21Bvn60PAn3jdUbrg4s64QZMOgrWI=";
};
beamDeps = [ ];
};
hackney = builder {
name = "hackney";
version = "1.17.1";
src = fetchHex {
pkg = "hackney";
version = "1.17.1";
sha256 = "sha256-0sup48gQOtAyBiPp8cM+jTeKFeqr4u6K5EGJjz01oYw=";
};
beamDeps = [
certifi
idna
metrics
mimerl
parse_trans
ssl_verify_fun
unicode_util_compat
];
};
goldrush = builder {
name = "goldrush";
version = "0.1.9";
src = fetchHex {
pkg = "goldrush";
version = "0.1.9";
sha256 = "sha256-mctBKM/8syJ1geXU2APVQT+mQ/TrllI/d9nmk32ZTOs=";
};
beamDeps = [ ];
};
getopt = builder {
name = "getopt";
version = "1.0.3";
src = fetchHex {
pkg = "getopt";
version = "1.0.3";
sha256 = "sha256-fgHekKxUDyFJT/cnkrHjFi05mWbrv8Z0tM5Sy49JMk8=";
};
beamDeps = [ ];
};
elvis_core = builder {
name = "elvis_core";
version = "4.1.1";
src = fetchHex {
pkg = "elvis_core";
version = "4.1.1";
sha256 = "sha256-gKViV0uNl0oudUTpqUVXFtBMngldvIyJFeJGgDHdE4U=";
};
beamDeps = [
katana_code
zipper
];
};
egithub = builder {
name = "egithub";
version = "0.7.0";
src = fetchHex {
pkg = "egithub";
version = "0.7.0";
sha256 = "sha256-4AnOEe/YAI0PntWdnEiOPpq+MCoPLNbWY+TMJnVvzEw=";
};
beamDeps = [
goldrush
hackney
jsx
lager
];
};
};
in
self

View File

@@ -0,0 +1,27 @@
{
fetchFromGitHub,
lib,
rebar3Relx,
}:
rebar3Relx rec {
pname = "erlfmt";
version = "1.7.0";
releaseType = "escript";
src = fetchFromGitHub {
owner = "WhatsApp";
repo = "erlfmt";
hash = "sha256-bljqWqpzAPP7+cVA3F+vXoUzUFzD4zXpUl/4XmMypB4=";
tag = "v${version}";
};
meta = with lib; {
homepage = "https://github.com/WhatsApp/erlfmt";
description = "Automated code formatter for Erlang";
mainProgram = "erlfmt";
platforms = platforms.unix;
license = licenses.asl20;
maintainers = with lib.maintainers; [ dlesl ];
};
}

View File

@@ -0,0 +1,63 @@
{
lib,
elixir,
fetchFromGitHub,
fetchMixDeps,
mixRelease,
nix-update-script,
# for tests
beam27Packages,
beam28Packages,
}:
# Based on ../elixir-ls/default.nix
let
pname = "ex_doc";
version = "0.38.4";
src = fetchFromGitHub {
owner = "elixir-lang";
repo = "${pname}";
rev = "v${version}";
hash = "sha256-/gZczKm/IF5QQemrdcda9oKVIGDFSqdiu8YrBwT6Mtk=";
};
in
mixRelease {
inherit
pname
version
src
elixir
;
escriptBinName = "ex_doc";
stripDebug = true;
mixFodDeps = fetchMixDeps {
pname = "mix-deps-${pname}";
inherit src version elixir;
hash = "sha256-TknrENa0Nb1Eobd4oTBl6TilPVEsw9+XjPdF3Ntq+DI=";
};
passthru = {
tests = {
# ex_doc is the doc generation for OTP 27+, so let's make sure they build
erlang_27 = beam27Packages.erlang;
erlang_28 = beam28Packages.erlang;
};
updateScript = nix-update-script { };
};
meta = with lib; {
homepage = "https://github.com/elixir-lang/ex_doc";
description = ''
ExDoc produces HTML and EPUB documentation for Elixir projects
'';
license = licenses.asl20;
platforms = platforms.unix;
mainProgram = "ex_doc";
maintainers = with maintainers; [ chiroptical ];
};
}

View File

@@ -0,0 +1,50 @@
{
lib,
stdenv,
fetchurl,
}:
{
pkg,
version,
sha256,
meta ? { },
}:
stdenv.mkDerivation {
pname = pkg;
inherit version;
dontBuild = true;
dontConfigure = true;
dontFixup = true;
src = fetchurl {
url = "https://repo.hex.pm/tarballs/${pkg}-${version}.tar";
inherit sha256;
};
unpackCmd = ''
tar -xf $curSrc contents.tar.gz CHECKSUM metadata.config
mkdir contents
tar -C contents -xzf contents.tar.gz
mv metadata.config contents/hex_metadata.config
# To make the extracted hex tarballs appear legitimate to mix, we need to
# make sure they contain not just the contents of contents.tar.gz but also
# a .hex file with some lock metadata.
# We use an old version of .hex file per hex's mix_task_test.exs since it
# is just plain-text instead of an encoded format.
# See: https://github.com/hexpm/hex/blob/main/test/hex/mix_task_test.exs#L410
echo -n "${pkg},${version},$(cat CHECKSUM | tr '[:upper:]' '[:lower:]'),hexpm" > contents/.hex
'';
installPhase = ''
runHook preInstall
mkdir "$out"
cp -Hrt "$out" .
success=1
runHook postInstall
'';
inherit meta;
}

View File

@@ -0,0 +1,100 @@
{
stdenvNoCC,
lib,
elixir,
hex,
rebar,
rebar3,
cacert,
git,
}@inputs:
{
pname,
version,
hash ? "",
sha256 ? "",
src,
mixEnv ? "prod",
mixTarget ? "host",
debug ? false,
meta ? { },
patches ? [ ],
elixir ? inputs.elixir,
hex ? inputs.hex.override { inherit elixir; },
...
}@attrs:
let
hash_ =
if hash != "" then
{
outputHashAlgo = null;
outputHash = hash;
}
else if sha256 != "" then
{
outputHashAlgo = "sha256";
outputHash = sha256;
}
else
{
outputHashAlgo = "sha256";
outputHash = lib.fakeSha256;
};
in
stdenvNoCC.mkDerivation (
attrs
// {
nativeBuildInputs = [
elixir
hex
cacert
git
];
MIX_ENV = mixEnv;
MIX_TARGET = mixTarget;
MIX_DEBUG = if debug then 1 else 0;
DEBUG = if debug then 1 else 0; # for rebar3
# the api with `mix local.rebar rebar path` makes a copy of the binary
MIX_REBAR = "${rebar}/bin/rebar";
MIX_REBAR3 = "${rebar3}/bin/rebar3";
# there is a persistent download failure with absinthe 1.6.3
# those defaults reduce the failure rate
HEX_HTTP_CONCURRENCY = 1;
HEX_HTTP_TIMEOUT = 120;
configurePhase =
attrs.configurePhase or ''
runHook preConfigure
export HEX_HOME="$TEMPDIR/.hex";
export MIX_HOME="$TEMPDIR/.mix";
export MIX_DEPS_PATH="$TEMPDIR/deps";
# Rebar
export REBAR_GLOBAL_CONFIG_DIR="$TMPDIR/rebar3"
export REBAR_CACHE_DIR="$TMPDIR/rebar3.cache"
runHook postConfigure
'';
inherit patches;
dontBuild = true;
installPhase =
attrs.installPhase or ''
runHook preInstall
mix deps.get ''${MIX_ENV:+--only $MIX_ENV}
find "$TEMPDIR/deps" -path '*/.git/*' -a ! -name HEAD -exec rm -rf {} +
cp -r --no-preserve=mode,ownership,timestamps $TEMPDIR/deps $out
runHook postInstall
'';
outputHashMode = "recursive";
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
inherit meta;
}
// hash_
)

View File

@@ -0,0 +1,46 @@
{
lib,
stdenv,
rebar3,
}:
{
name,
version,
sha256,
src,
meta ? { },
}:
stdenv.mkDerivation {
pname = "rebar-deps-${name}";
inherit version;
dontUnpack = true;
dontConfigure = true;
dontFixup = true;
buildPhase = ''
cp -r ${src} src
chmod -R u+w src
cd src
HOME='.' DEBUG=1 ${rebar3}/bin/rebar3 get-deps
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/_checkouts"
for i in ./_build/default/lib/* ; do
echo "$i"
cp -R "$i" "$out/_checkouts"
done
runHook postInstall
'';
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = sha256;
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
inherit meta;
}

View File

@@ -0,0 +1,68 @@
{
lib,
stdenv,
fetchFromGitHub,
writeText,
elixir,
}:
let
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.name}";
buildInputs = [ drv ];
};
pkg =
self:
stdenv.mkDerivation rec {
pname = "hex";
version = "2.2.2";
src = fetchFromGitHub {
owner = "hexpm";
repo = "hex";
rev = "v${version}";
sha256 = "sha256-Qih10OeI7KsnAthAW0yuH+YL8uoeLy7tOVn9rdkGA4M=";
};
setupHook = writeText "setupHook.sh" ''
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
'';
dontStrip = true;
buildInputs = [ elixir ];
buildPhase = ''
runHook preBuild
export HEX_OFFLINE=1
export HEX_HOME=./
export MIX_ENV=prod
mix compile
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/lib/erlang/lib
cp -r ./_build/prod/lib/hex $out/lib/erlang/lib/
runHook postInstall
'';
meta = {
description = "Package manager for the Erlang VM https://hex.pm";
license = lib.licenses.mit;
homepage = "https://github.com/hexpm/hex";
maintainers = with lib.maintainers; [ ericbmerritt ];
};
passthru = {
env = shell self;
};
};
in
lib.fix pkg

View File

@@ -0,0 +1,85 @@
{ __splicedPackages, lib }:
let
pkgs = __splicedPackages;
in
rec {
# Similar to callPackageWith/callPackage, but without makeOverridable
callPackageWith =
autoArgs: fn: args:
let
f = if pkgs.lib.isFunction fn then fn else import fn;
auto = builtins.intersectAttrs (lib.functionArgs f) autoArgs;
in
f (auto // args);
callPackage = callPackageWith pkgs;
/*
Uses generic-builder to evaluate provided drv containing OTP-version
specific data.
drv: package containing version-specific args;
builder: generic builder for all Erlang versions;
args: arguments merged into version-specific args, used mostly to customize
dependencies;
Arguments passed to the generic-builder are overridable, used to
enable/disable high-level OTP features, like ODBC or WX support;
Please note that "mkDerivation" defined here is the one called from R16.nix
and similar files.
*/
callErlang =
drv: args:
let
genericBuilder =
versionArgs: import ../../development/interpreters/erlang/generic-builder.nix (versionArgs // args);
in
pkgs.callPackage (import drv genericBuilder) { };
/*
Uses generic-builder to evaluate provided drv containing Elixir version
specific data.
drv: file containing version-specific args;
genericBuilder: generic builder for all Erlang versions;
args: arguments merged into version-specific args, used mostly to customize
high level options;
Arguments passed to the generic-builder are overridable.
*/
callElixir =
drv: args:
let
builder = callPackage ../interpreters/elixir/generic-builder.nix args;
in
callPackage drv {
mkDerivation = pkgs.makeOverridable builder;
};
/*
Uses generic-builder to evaluate provided drv containing Elixir version
specific data.
drv: package containing version-specific args;
builder: generic builder for all Erlang versions;
args: arguments merged into version-specific args, used mostly to customize
dependencies;
Arguments passed to the generic-builder are overridable.
Please note that "mkDerivation" defined here is the one called from 1.2.nix
and similar files.
*/
callLFE =
drv: args:
let
builder = callPackage ../interpreters/lfe/generic-builder.nix args;
in
callPackage drv {
mkDerivation = pkgs.makeOverridable builder;
};
}

View File

@@ -0,0 +1,62 @@
{
lib,
beamPackages,
makeWrapper,
fetchFromGitHub,
nixosTests,
nix-update-script,
}:
beamPackages.mixRelease rec {
pname = "livebook";
version = "0.17.2";
inherit (beamPackages) elixir;
buildInputs = [ beamPackages.erlang ];
nativeBuildInputs = [ makeWrapper ];
src = fetchFromGitHub {
owner = "livebook-dev";
repo = "livebook";
tag = "v${version}";
hash = "sha256-9AlvEqyQJvcRbAuuxF5Q5S9hG96vaQYVBYwPYp4lGQM=";
};
mixFodDeps = beamPackages.fetchMixDeps {
pname = "mix-deps-${pname}";
inherit src version;
hash = "sha256-18fmaNuu2KqTGhBBd+pSBfgnrHiqzXc3CMdSpC5lFs8=";
};
postInstall = ''
wrapProgram $out/bin/livebook \
--prefix PATH : ${
lib.makeBinPath [
beamPackages.elixir
beamPackages.erlang
]
} \
--set MIX_REBAR3 ${beamPackages.rebar3}/bin/rebar3
'';
passthru = {
updateScript = nix-update-script { };
tests = {
livebook-service = nixosTests.livebook-service;
};
};
meta = {
license = lib.licenses.asl20;
homepage = "https://livebook.dev/";
description = "Automate code & data workflows with interactive Elixir notebooks";
maintainers = with lib.maintainers; [
munksgaard
scvalex
];
platforms = lib.platforms.unix;
teams = [ lib.teams.beam ];
};
}

View File

@@ -0,0 +1,18 @@
# shellcheck shell=bash
# this hook will symlink all dependencies found in ERL_LIBS
# since Elixir 1.12.2 elixir does not look into ERL_LIBS for
# elixir depencencies anymore, so those have to be symlinked to the _build directory
mkdir -p _build/"$MIX_BUILD_PREFIX"/lib
while read -r -d ':' lib; do
for dir in "$lib"/*; do
# Strip version number for directory name if it exists, so naming of
# all libs matches what mix's expectation.
dest=$(basename "$dir" | cut -d '-' -f1)
build_dir="_build/$MIX_BUILD_PREFIX/lib/$dest"
((MIX_DEBUG == 1)) && echo "Linking $dir to $build_dir"
# Symlink libs to _build so that mix can find them when compiling.
# This is what allows mix to compile the package without searching
# for dependencies over the network.
ln -s "$dir" "$build_dir"
done
done <<< "$ERL_LIBS:"

View File

@@ -0,0 +1,293 @@
{
stdenv,
lib,
elixir,
erlang,
hex,
git,
rebar,
rebar3,
fetchMixDeps,
findutils,
ripgrep,
bbe,
makeWrapper,
coreutils,
gnused,
gnugrep,
gawk,
}@inputs:
{
pname,
version,
src,
nativeBuildInputs ? [ ],
buildInputs ? [ ],
meta ? { },
enableDebugInfo ? false,
mixEnv ? "prod",
mixTarget ? "host",
compileFlags ? [ ],
# Build a particular named release.
# see https://hexdocs.pm/mix/1.12/Mix.Tasks.Release.html#content
mixReleaseName ? "",
# If set, the given escript binary will be copied to the output
# instead of the release
escriptBinName ? null,
# Options to be passed to the Erlang compiler. As documented in the reference
# manual, these must be valid Erlang terms. They will be turned into an
# erlang list and set as the ERL_COMPILER_OPTIONS environment variable.
# See https://www.erlang.org/doc/man/compile
erlangCompilerOptions ? [ ],
# Deterministic Erlang builds remove full system paths from debug information
# among other things to keep builds more reproducible. See their docs for more:
# https://www.erlang.org/doc/man/compile
erlangDeterministicBuilds ? true,
# Mix dependencies provided as a fixed output derivation
mixFodDeps ? null,
# Mix dependencies generated by mix2nix
#
# This assumes each dependency is built by buildMix or buildRebar3. Each
# dependency needs to have a setup hook to add the lib path to $ERL_LIBS.
# This is how Mix finds dependencies.
mixNixDeps ? { },
elixir ? inputs.elixir,
erlang ? inputs.erlang,
hex ? inputs.hex.override { inherit elixir; },
# Remove releases/COOKIE
#
# People have different views on the nature of cookies. Some believe that they are
# secrets, while others believe they are just ids for clustering nodes instead of
# secrets.
#
# If you think cookie is secret, you can set this attr to true, then it will be
# removed from nix store. If not, you can set it to false.
#
# For backward compatibility, it is set to true by default.
#
# You can always specify a custom cookie by using RELEASE_COOKIE environment
# variable, regardless of the value of this attr.
removeCookie ? true,
# This reduces closure size, but can lead to some hard to understand runtime
# errors, so use with caution. See e.g.
# https://github.com/whitfin/cachex/issues/205
# https://framagit.org/framasoft/mobilizon/-/issues/1169
stripDebug ? false,
...
}@attrs:
let
# Remove non standard attributes that cannot be coerced to strings
overridable = removeAttrs attrs [
"compileFlags"
"erlangCompilerOptions"
"mixNixDeps"
];
in
assert mixNixDeps != { } -> mixFodDeps == null;
assert stripDebug -> !enableDebugInfo;
assert escriptBinName != null -> mixReleaseName == "";
stdenv.mkDerivation (
overridable
// {
nativeBuildInputs =
nativeBuildInputs
++
# Erlang/Elixir deps
[
erlang
elixir
hex
git
]
++
# Mix deps
(builtins.attrValues mixNixDeps)
++
# other compile-time deps
[
findutils
ripgrep
bbe
makeWrapper
];
buildInputs = buildInputs ++ lib.optionals (escriptBinName != null) [ erlang ];
MIX_ENV = mixEnv;
MIX_TARGET = mixTarget;
MIX_BUILD_PREFIX = (if mixTarget == "host" then "" else "${mixTarget}_") + "${mixEnv}";
MIX_DEBUG = if enableDebugInfo then 1 else 0;
HEX_OFFLINE = 1;
DEBUG = if enableDebugInfo then 1 else 0; # for Rebar3 compilation
# The API with `mix local.rebar rebar path` makes a copy of the binary
# some older dependencies still use rebar.
MIX_REBAR = "${rebar}/bin/rebar";
MIX_REBAR3 = "${rebar3}/bin/rebar3";
ERL_COMPILER_OPTIONS =
let
options = erlangCompilerOptions ++ lib.optionals erlangDeterministicBuilds [ "deterministic" ];
in
"[${lib.concatStringsSep "," options}]";
LANG = if stdenv.hostPlatform.isLinux then "C.UTF-8" else "C";
LC_CTYPE = if stdenv.hostPlatform.isLinux then "C.UTF-8" else "UTF-8";
postUnpack = ''
# Mix and Hex
export MIX_HOME="$TEMPDIR/mix"
export HEX_HOME="$TEMPDIR/hex"
# Rebar
export REBAR_GLOBAL_CONFIG_DIR="$TEMPDIR/rebar3"
export REBAR_CACHE_DIR="$TEMPDIR/rebar3.cache"
${lib.optionalString (mixFodDeps != null) ''
# Compilation of the dependencies will require that the dependency path is
# writable, thus a copy to the $TEMPDIR is inevitable here.
export MIX_DEPS_PATH="$TEMPDIR/deps"
cp --no-preserve=mode -R "${mixFodDeps}" "$MIX_DEPS_PATH"
''}
''
+ (attrs.postUnpack or "");
configurePhase =
attrs.configurePhase or ''
runHook preConfigure
${./mix-configure-hook.sh}
# This is needed for projects that have a specific compile step
# the dependency needs to be compiled in order for the task
# to be available.
#
# Phoenix projects for example will need compile.phoenix.
mix deps.compile --no-deps-check --skip-umbrella-children
# Symlink dependency sources. This is needed for projects that require
# access to the source of their dependencies. For example, Phoenix
# projects need javascript assets to build asset bundles.
${lib.optionalString (mixNixDeps != { }) ''
mkdir -p deps
${lib.concatMapStringsSep "\n" (dep: ''
dep_name=$(basename ${dep} | cut -d '-' -f2)
dep_path="deps/$dep_name"
if [ -d "${dep}/src" ]; then
ln -s ${dep}/src $dep_path
fi
'') (builtins.attrValues mixNixDeps)}
''}
# Symlink deps to build root. Similar to above, but allows for mixFodDeps
# Phoenix projects to find javascript assets.
${lib.optionalString (mixFodDeps != null) ''
ln -s "$MIX_DEPS_PATH" ./deps
''}
runHook postConfigure
'';
buildPhase =
attrs.buildPhase or ''
runHook preBuild
mix compile --no-deps-check ${lib.concatStringsSep " " compileFlags}
${lib.optionalString (escriptBinName != null) ''
mix escript.build --no-deps-check
''}
runHook postBuild
'';
installPhase =
attrs.installPhase or ''
runHook preInstall
${
if (escriptBinName != null) then
''
mkdir -p $out/bin
cp ${escriptBinName} $out/bin
''
else
''
mix release ${mixReleaseName} --no-deps-check --path "$out"
''
}
runHook postInstall
'';
postFixup = ''
echo "removing files for Microsoft Windows"
rm -f "$out"/bin/*.bat
echo "wrapping programs in $out/bin with their runtime deps"
for f in $(find $out/bin/ -type f -executable); do
wrapProgram "$f" \
--prefix PATH : ${
lib.makeBinPath [
coreutils
gnused
gnugrep
gawk
]
}
done
''
+ lib.optionalString removeCookie ''
if [ -e $out/releases/COOKIE ]; then
echo "removing $out/releases/COOKIE"
rm $out/releases/COOKIE
fi
''
+ ''
if [ -e $out/erts-* ]; then
# ERTS is included in the release, then erlang is not required as a runtime dependency.
# But, erlang is still referenced in some places. To removed references to erlang,
# following steps are required.
# 1. remove references to erlang from plain text files
for file in $(rg "${erlang}/lib/erlang" "$out" --files-with-matches); do
echo "removing references to erlang in $file"
substituteInPlace "$file" --replace "${erlang}/lib/erlang" "$out"
done
# 2. remove references to erlang from .beam files
#
# No need to do anything, because it has been handled by "deterministic" option specified
# by ERL_COMPILER_OPTIONS.
# 3. remove references to erlang from normal binary files
for file in $(rg "${erlang}/lib/erlang" "$out" --files-with-matches --binary --iglob '!*.beam'); do
echo "removing references to erlang in $file"
# use bbe to substitute strings in binary files, because using substituteInPlace
# on binaries will raise errors
bbe -e "s|${erlang}/lib/erlang|$out|" -o "$file".tmp "$file"
rm -f "$file"
mv "$file".tmp "$file"
done
# References to erlang should be removed from output after above processing.
fi
''
+ lib.optionalString stripDebug ''
# Strip debug symbols to avoid hardreferences to "foreign" closures actually
# not needed at runtime, while at the same time reduce size of BEAM files.
erl -noinput -eval 'lists:foreach(fun(F) -> io:format("Stripping ~p.~n", [F]), beam_lib:strip(F) end, filelib:wildcard("'"$out"'/**/*.beam"))' -s init stop
'';
}
)

View File

@@ -0,0 +1,13 @@
{ lib, buildHex }:
buildHex {
name = "pc";
version = "1.15.0";
sha256 = "sha256-TA+tT2Q3yuNT1RfaIY/ng0e4/6RLmBeIdJTKquVFlbM=";
meta = {
description = "Rebar3 port compiler for native code";
license = lib.licenses.mit;
homepage = "https://github.com/blt/port_compiler";
};
}

View File

@@ -0,0 +1,44 @@
{
lib,
stdenv,
fetchFromGitHub,
buildRebar3,
}:
let
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.name}";
buildInputs = [ drv ];
};
pkg =
self:
buildRebar3 {
name = "pgsql";
version = "25+beta.2";
src = fetchFromGitHub {
owner = "semiocast";
repo = "pgsql";
rev = "14f632bc89e464d82ce3ef12a67ed8c2adb5b60c";
sha256 = "17dcahiwlw61zhy8aq9rn46lwb35fb9q3372s4wmz01czm8c348w";
};
dontStrip = true;
meta = {
description = "Erlang PostgreSQL Driver";
license = lib.licenses.mit;
homepage = "https://github.com/semiocast/pgsql";
maintainers = with lib.maintainers; [ ericbmerritt ];
};
passthru = {
env = shell self;
};
};
in
lib.fix pkg

View File

@@ -0,0 +1,25 @@
{
lib,
buildRebar3,
fetchFromGitHub,
}:
buildRebar3 rec {
name = "rebar3_nix";
version = "0.1.1";
src = fetchFromGitHub {
owner = "erlang-nix";
repo = name;
rev = "v${version}";
sha256 = "10ijc06qvv5hqv0qy3w7mbv9pshdb8bvy0f3phr1vd5hksbk731y";
};
meta = {
description = "nix integration for rebar3";
license = lib.licenses.bsd3;
homepage = "https://github.com/erlang-nix/rebar3_nix";
maintainers = with lib.maintainers; [
dlesl
gleber
];
};
}

View File

@@ -0,0 +1,13 @@
{ lib, buildHex }:
buildHex {
name = "rebar3_proper";
version = "0.12.1";
sha256 = "1f174fb6h2071wr7qbw9aqqvnglzsjlylmyi8215fhrmi38w94b6";
meta = {
description = "rebar3 proper plugin";
license = lib.licenses.bsd3;
homepage = "https://github.com/ferd/rebar3_proper";
};
}

View File

@@ -0,0 +1,128 @@
{
stdenv,
erlang,
rebar3WithPlugins,
openssl,
lib,
}:
{
pname,
version,
src,
beamDeps ? [ ],
buildPlugins ? [ ],
checkouts ? null,
releaseType,
buildInputs ? [ ],
setupHook ? null,
profile ? "default",
installPhase ? null,
buildPhase ? null,
configurePhase ? null,
meta ? { },
...
}@attrs:
let
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.pname}";
buildInputs = [ drv ];
};
customPhases = lib.filterAttrs (_: v: v != null) {
inherit
setupHook
configurePhase
buildPhase
installPhase
;
};
# When using the `beamDeps` argument, it is important that we use
# `rebar3WithPlugins` here even when there are no plugins. The vanilla
# `rebar3` package is an escript archive with bundled dependencies which can
# interfere with those in the app we are trying to build. `rebar3WithPlugins`
# doesn't have this issue since it puts its own deps last on the code path.
rebar3 = rebar3WithPlugins {
plugins = buildPlugins;
};
pkg =
assert beamDeps != [ ] -> checkouts == null;
self:
stdenv.mkDerivation (
attrs
// {
name = "${pname}-${version}";
inherit version pname;
buildInputs =
buildInputs
++ [
erlang
rebar3
openssl
]
++ beamDeps;
# ensure we strip any native binaries (eg. NIFs, ports)
stripDebugList = lib.optional (releaseType == "release") "rel";
inherit src;
REBAR_IGNORE_DEPS = beamDeps != [ ];
configurePhase = ''
runHook preConfigure
${lib.optionalString (checkouts != null) "cp --no-preserve=all -R ${checkouts}/_checkouts ."}
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
HOME=. DEBUG=1 rebar3 as ${profile} ${if releaseType == "escript" then "escriptize" else "release"}
runHook postBuild
'';
installPhase = ''
runHook preInstall
dir=${if releaseType == "escript" then "bin" else "rel"}
mkdir -p "$out/$dir" "$out/bin"
cp -R --preserve=mode "_build/${profile}/$dir" "$out"
${lib.optionalString (
releaseType == "release"
) "find $out/rel/*/bin -type f -executable -exec ln -s -t $out/bin {} \\;"}
runHook postInstall
'';
# Release will generate a binary which will cause a read null byte failure, see #261354
postInstall = lib.optionalString (releaseType == "escript") ''
for dir in $out/rel/*/erts-*; do
echo "ERTS found in $dir - removing references to erlang to reduce closure size"
for f in $dir/bin/{erl,start}; do
substituteInPlace "$f" --replace "${erlang}/lib/erlang" "''${dir/\/erts-*/}"
done
done
'';
meta = {
inherit (erlang.meta) platforms;
}
// meta;
passthru = (
{
packageName = pname;
env = shell self;
}
// (if attrs ? passthru then attrs.passthru else { })
);
}
// customPhases
);
in
lib.fix pkg

View File

@@ -0,0 +1,51 @@
{
lib,
stdenv,
fetchFromGitHub,
writeText,
erlang,
}:
let
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.name}";
buildInputs = [ drv ];
};
pkg =
self:
stdenv.mkDerivation {
pname = "webdriver";
version = "0.pre+unstable=2015-02-08";
src = fetchFromGitHub {
owner = "Quviq";
repo = "webdrv";
rev = "7ceaf1f67d834e841ca0133b4bf899a9fa2db6bb";
sha256 = "1pq6pmlr6xb4hv2fvmlrvzd8c70kdcidlgjv4p8n9pwvkif0cb87";
};
setupHook = writeText "setupHook.sh" ''
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
'';
buildInputs = [ erlang ];
installFlags = [ "PREFIX=$(out)/lib/erlang/lib" ];
meta = {
description = "WebDriver implementation in Erlang";
license = lib.licenses.mit;
homepage = "https://github.com/Quviq/webdrv";
maintainers = with lib.maintainers; [ ericbmerritt ];
};
passthru = {
env = shell self;
};
};
in
lib.fix pkg

View File

@@ -0,0 +1,74 @@
{
lib,
stdenv,
writeShellScriptBin,
fetchurl,
ant,
openjdk17,
makeWrapper,
stripJavaArchivesHook,
}:
let
# https://armedbear.common-lisp.dev/ lists OpenJDK 17 as the highest
# supported JDK.
jdk = openjdk17;
fakeHostname = writeShellScriptBin "hostname" ''
echo nix-builder.localdomain
'';
in
stdenv.mkDerivation (finalAttrs: {
pname = "abcl";
version = "1.9.3";
src = fetchurl {
url = "https://common-lisp.net/project/armedbear/releases/${finalAttrs.version}/abcl-src-${finalAttrs.version}.tar.gz";
hash = "sha256-uwShIj06mGCS4BD/2tE69QQp1VwagYdL8wIvlDa/sv8=";
};
# note for the future:
# if you use makeBinaryWrapper, you will trade bash for glibc, the closure will be slightly larger
nativeBuildInputs = [
ant
jdk
fakeHostname
makeWrapper
stripJavaArchivesHook
];
buildPhase = ''
runHook preBuild
ant \
-Dabcl.runtime.jar.path="$out/lib/abcl/abcl.jar" \
-Dadditional.jars="$out/lib/abcl/abcl-contrib.jar"
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p "$out"/{share/doc/abcl,lib/abcl}
cp -r README COPYING CHANGES examples/ "$out/share/doc/abcl/"
cp -r dist/*.jar contrib/ "$out/lib/abcl/"
install -Dm555 abcl -t $out/bin
runHook postInstall
'';
passthru.updateScript = ./update.sh;
meta = {
description = "JVM-based Common Lisp implementation";
homepage = "https://common-lisp.net/project/armedbear/";
license = with lib.licenses; [
gpl2
classpathException20
];
mainProgram = "abcl";
teams = [ lib.teams.lisp ];
platforms = lib.platforms.darwin ++ lib.platforms.linux;
};
})

View File

@@ -0,0 +1,5 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix-update subversion
new_version=$(svn ls https://abcl.org/svn/tags | tail -1 | tr -d /)
nix-update abcl --version "$new_version"

View File

@@ -0,0 +1,44 @@
{
lib,
fetchFromGitHub,
callPackage,
zig_0_14,
}:
let
versions = [
{
zig = zig_0_14;
version = "0-unstable-2025-03-05";
src = fetchFromGitHub {
owner = "Vexu";
repo = "arocc";
rev = "8c6bab43ba351fc045a1d262d8a8da4a11215e37";
hash = "sha256-J5Cj9UMwAMwH2JGby13FIKl5Qbj4N4XpSSY7zL21aoY=";
};
}
];
mkPackage =
{
zig,
version,
src,
}:
callPackage ./package.nix { inherit zig version src; };
pkgsList = lib.map mkPackage versions;
pkgsAttrsUnwrapped = lib.listToAttrs (
lib.map (pkg: lib.nameValuePair "${pkg.version}-unwrapped" pkg) pkgsList
);
pkgsAttrsWrapped = lib.listToAttrs (
lib.map (pkg: lib.nameValuePair pkg.version pkg.wrapped) pkgsList
);
pkgsAttrs = pkgsAttrsWrapped // pkgsAttrsUnwrapped;
in
{
latest-unwrapped = lib.last pkgsList;
latest = (lib.last pkgsList).wrapped;
}
// pkgsAttrs

View File

@@ -0,0 +1,33 @@
{
lib,
stdenv,
wrapCCWith,
overrideCC,
zig,
version,
src,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "arocc";
inherit version src;
nativeBuildInputs = [ zig.hook ];
passthru = {
inherit zig;
isArocc = true;
wrapped = wrapCCWith { cc = finalAttrs.finalPackage; };
stdenv = overrideCC stdenv finalAttrs.passthru.wrapped;
};
meta = {
description = "C compiler written in Zig";
homepage = "http://aro.vexu.eu/";
license = with lib.licenses; [
mit
unicode-30
];
maintainers = with lib.maintainers; [ RossComputerGuy ];
mainProgram = "arocc";
};
})

View File

@@ -0,0 +1,94 @@
{
lib,
stdenv,
cmake,
python3,
fetchFromGitHub,
emscripten,
gtest,
lit,
nodejs,
filecheck,
}:
let
testsuite = fetchFromGitHub {
owner = "WebAssembly";
repo = "testsuite";
rev = "e05365077e13a1d86ffe77acfb1a835b7aa78422";
hash = "sha256-yvZ5AZTPUA6nsD3xpFC0VLthiu2CxVto66RTXBXXeJM=";
};
in
stdenv.mkDerivation rec {
pname = "binaryen";
version = "124";
src = fetchFromGitHub {
owner = "WebAssembly";
repo = "binaryen";
rev = "version_${version}";
hash = "sha256-tkvO0gNESliRV6FOpXDQd7ZKujGe6q1mGX5V+twcE1o=";
};
nativeBuildInputs = [
cmake
python3
];
strictDeps = true;
preConfigure = ''
if [ $doCheck -eq 1 ]; then
sed -i '/gtest/d' third_party/CMakeLists.txt
rmdir test/spec/testsuite
ln -s ${testsuite} test/spec/testsuite
else
cmakeFlagsArray=($cmakeFlagsArray -DBUILD_TESTS=0)
fi
'';
nativeCheckInputs = [
lit
nodejs
filecheck
];
checkInputs = [ gtest ];
checkPhase = ''
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib python3 ../check.py $tests
'';
tests = [
"version"
"wasm-opt"
"wasm-dis"
"crash"
"dylink"
"ctor-eval"
"wasm-metadce"
"wasm-reduce"
"spec"
"lld"
"wasm2js"
# "unit" # fails on test.unit.test_cluster_fuzz.ClusterFuzz
# "binaryenjs" "binaryenjs_wasm" # not building this
# "lit" # fails on d8/fuzz_shell*
"gtest"
]
++ lib.optionals stdenv.hostPlatform.isLinux [
"example"
"validator"
];
doCheck = (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin);
meta = with lib; {
homepage = "https://github.com/WebAssembly/binaryen";
description = "Compiler infrastructure and toolchain library for WebAssembly, in C++";
platforms = platforms.all;
maintainers = with maintainers; [
asppsa
willcohen
];
license = licenses.asl20;
};
passthru.tests = { inherit emscripten; };
}

View File

@@ -0,0 +1,88 @@
{
lib,
stdenv,
fetchFromBitbucket,
mlton,
pkg-config,
getopt,
boehmgc,
darwin,
libbacktrace,
libpng,
ncurses,
readline,
unstableGitUpdater,
}:
stdenv.mkDerivation rec {
pname = "c0";
version = "0-unstable-2023-09-05";
src = fetchFromBitbucket {
owner = "c0-lang";
repo = "c0";
rev = "608f97eef5d81bb85963d66f955730dd93996f67";
hash = "sha256-lRIEtclx+NKxAO72nsvnxVeEGCEe6glC6w8MXh1HEwY=";
};
patches = [
./use-system-libraries.patch
];
postPatch = ''
substituteInPlace cc0/Makefile \
--replace '$(shell ./get_version.sh)' '${version}'
substituteInPlace cc0/compiler/bin/buildid \
--replace '`../get_version.sh`' '${version}' \
--replace '`date`' '1970-01-01T00:00:00Z' \
--replace '`hostname`' 'nixpkgs'
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
for f in cc0/compiler/bin/coin-o0-support cc0/compiler/bin/cc0-o0-support; do
substituteInPlace $f --replace '$(brew --prefix gnu-getopt)' '${getopt}'
done
'';
preConfigure = ''
cd cc0/
'';
nativeBuildInputs = [
getopt
mlton
pkg-config
]
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.sigtool ];
buildInputs = [
boehmgc
libbacktrace
libpng
ncurses
readline
];
strictDeps = true;
installFlags = [ "PREFIX=$(out)" ];
postInstall = ''
mkdir -p $out/share/emacs/site-lisp
mv $out/c0-mode/ $out/share/emacs/site-lisp/
'';
passthru.updateScript = unstableGitUpdater {
url = "https://bitbucket.org/c0-lang/c0.git";
};
meta = with lib; {
description = "Small safe subset of the C programming language, augmented with contracts";
homepage = "https://c0.cs.cmu.edu/";
license = licenses.mit;
maintainers = [ ];
platforms = platforms.unix;
# line 1: ../../bin/wrappergen: cannot execute: required file not found
# make[2]: *** [../../lib.mk:83:
broken = stdenv.hostPlatform.isLinux;
};
}

View File

@@ -0,0 +1,53 @@
Use system libraries
--- a/cc0/Makefile
+++ b/cc0/Makefile
@@ -22,12 +22,12 @@ MLTON_BASIC = mlton $(MLTON_FLAGS) -verbose $(MLTON_VERB) -output
MLTON_NATIVE := mlton -default-ann "redundantMatch error" -default-ann "sequenceNonUnit error"
MLTON_NATIVE += -link-opt "-lpthread -ldl -rdynamic" -cc-opt "-Iinclude" -default-ann "allowFFI true"
MLTON_NATIVE += -cc-opt "-I../externals/"
-MLTON_NATIVE += -link-opt "../externals/readline/libreadline.a ../externals/readline/libhistory.a"
+MLTON_NATIVE += -link-opt "$(shell pkg-config readline --libs)"
MLTON_NATIVE += -link-opt "$(shell pkg-config libpng --libs)"
# libreadline dependencies
ifeq ($(PLATFORM),osx)
-MLTON_NATIVE += -link-opt "-ltermcap"
+MLTON_NATIVE += -link-opt "-lncurses"
else
# (Assuming Linux)
MLTON_NATIVE += -link-opt "-ltinfo"
@@ -122,9 +122,9 @@ endef
$(foreach rt,$(RUNTIMES),$(eval $(call runtime_template,$(rt))))
-c0rt/$(call dllname,c0rt): gc libbacktrace
+c0rt/$(call dllname,c0rt):
-unsafe/$(call dllname,unsafe): gc
+unsafe/$(call dllname,unsafe):
### cc0 - the C0 compiler
@@ -222,7 +222,6 @@ NATIVE_COIN = $(NATIVE_CYMBOL) $(NATIVE_CALLING)
NATIVE_COIN += coin/c0readline.c
COIN_DEPS = $(CC0_DEPS) $(NATIVE_COIN) cymbol/cymbol*.cm cymbol/*.sml cymbol/*.mlb coin/coin*.cm coin/*.sml coin/*.sml
-COIN_DEPS += readline
.PHONY: coin
coin: bin/coin
--- a/cc0/lib.mk
+++ b/cc0/lib.mk
@@ -15,9 +15,9 @@ TARGET = $(call dllname,$(LIBNAME))
endif
# These libs are handled specially by this file
-NATIVELIBS = gc ncurses backtrace
+NATIVELIBS =
C0LIBS = $(filter-out $(NATIVELIBS),$(REQUIRES))
-LIBS = -L$(abspath $(DEPTH)/lib) $(patsubst %,$(DEPTH)/lib/$(call dllname,%),$(C0LIBS))
+LIBS = -L$(abspath $(DEPTH)/lib)
LDFLAGS =
# -fPIC is not supported on Windows and is not necessary there because we link statically

View File

@@ -0,0 +1,121 @@
{
lib,
stdenv,
fetchurl,
bootstrap_cmds,
coreutils,
glibc,
m4,
runtimeShell,
}:
let
options = rec {
# TODO: there are also FreeBSD and Windows versions
x86_64-linux = {
arch = "linuxx86";
sha256 = "0mhmm8zbk42p2b9amy702365m687k5p0xnz010yqrki6mwyxlkx9";
runtime = "lx86cl64";
kernel = "linuxx8664";
};
i686-linux = {
arch = "linuxx86";
sha256 = x86_64-linux.sha256;
runtime = "lx86cl";
kernel = "linuxx8632";
};
armv7l-linux = {
arch = "linuxarm";
sha256 = "1a4y07cmmn1r88b4hl4msb0bvr2fxd2vw9lf7h4j9f7a5rpq7124";
runtime = "armcl";
kernel = "linuxarm";
};
x86_64-darwin = {
arch = "darwinx86";
sha256 = "1xclnik6pqhkmr15cbqa2n1ddzdf0rs452lyiln3c42nmkf9jjb6";
runtime = "dx86cl64";
kernel = "darwinx8664";
};
armv6l-linux = armv7l-linux;
};
cfg =
options.${stdenv.hostPlatform.system}
or (throw "missing source url for platform ${stdenv.hostPlatform.system}");
in
stdenv.mkDerivation rec {
pname = "ccl";
version = "1.12.2";
src = fetchurl {
url = "https://github.com/Clozure/ccl/releases/download/v${version}/ccl-${version}-${cfg.arch}.tar.gz";
sha256 = cfg.sha256;
};
buildInputs =
if stdenv.hostPlatform.isDarwin then
[
bootstrap_cmds
m4
]
else
[
glibc
m4
];
CCL_RUNTIME = cfg.runtime;
CCL_KERNEL = cfg.kernel;
postPatch =
if stdenv.hostPlatform.isDarwin then
''
substituteInPlace lisp-kernel/${CCL_KERNEL}/Makefile \
--replace "M4 = gm4" "M4 = m4" \
--replace "dtrace" "/usr/sbin/dtrace" \
--replace "/bin/rm" "${coreutils}/bin/rm" \
--replace "/bin/echo" "${coreutils}/bin/echo"
substituteInPlace lisp-kernel/m4macros.m4 \
--replace "/bin/pwd" "${coreutils}/bin/pwd"
''
else
''
substituteInPlace lisp-kernel/${CCL_KERNEL}/Makefile \
--replace "/bin/rm" "${coreutils}/bin/rm" \
--replace "/bin/echo" "${coreutils}/bin/echo"
substituteInPlace lisp-kernel/m4macros.m4 \
--replace "/bin/pwd" "${coreutils}/bin/pwd"
'';
buildPhase = ''
make -C lisp-kernel/${CCL_KERNEL} clean
make -C lisp-kernel/${CCL_KERNEL} all
./${CCL_RUNTIME} -n -b -e '(ccl:rebuild-ccl :full t)' -e '(ccl:quit)'
'';
installPhase = ''
mkdir -p "$out/share"
cp -r . "$out/share/ccl-installation"
mkdir -p "$out/bin"
echo -e '#!${runtimeShell}\n'"$out/share/ccl-installation/${CCL_RUNTIME}"' "$@"\n' > "$out"/bin/"${CCL_RUNTIME}"
chmod a+x "$out"/bin/"${CCL_RUNTIME}"
ln -s "$out"/bin/"${CCL_RUNTIME}" "$out"/bin/ccl
'';
hardeningDisable = [ "format" ];
meta = with lib; {
# assembler failures during build, x86_64-darwin broken since 2020-10-14
broken = (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64);
description = "Clozure Common Lisp";
homepage = "https://ccl.clozure.com/";
license = licenses.asl20;
mainProgram = "ccl";
teams = [ lib.teams.lisp ];
platforms = attrNames options;
};
}

View File

@@ -0,0 +1,157 @@
From 2877f33747e3871c3a682b3a0c812b8ba2e4da5a Mon Sep 17 00:00:00 2001
From: Caolan McMahon <caolan@caolanmcmahon.com>
Date: Sat, 25 Jun 2016 11:52:28 +0100
Subject: [PATCH] Introduce CHICKEN_REPOSITORY_EXTRA
This environment variable works like CHICKEN_REPOSITORY but supports
multiple paths separated by `:'. Those paths are searched after
CHICKEN_REPOSITORY when loading extensions via `require-library' and
friends. It can be accessed and changed at runtime via the new procedure
`repository-extra-paths' which is analog to `repository-path'.
Original patch by Moritz Heidkamp.
Updated by Caolan McMahon for CHICKEN 4.11.0
---
chicken-install.scm | 29 ++++++++++++++++++++++++-----
chicken.import.scm | 1 +
eval.scm | 37 +++++++++++++++++++++++++++++++------
3 files changed, 56 insertions(+), 11 deletions(-)
diff --git a/chicken-install.scm b/chicken-install.scm
index 7bc6041..f557793 100644
--- a/chicken-install.scm
+++ b/chicken-install.scm
@@ -120,6 +120,19 @@
(sprintf "lib/chicken/~a" (##sys#fudge 42)))
(repository-path)))))
+ (define (repo-paths)
+ (if *deploy*
+ *prefix*
+ (if (and *cross-chicken* (not *host-extension*))
+ (list (make-pathname C_TARGET_LIB_HOME (sprintf "chicken/~a" C_BINARY_VERSION)))
+ (cons
+ (if *prefix*
+ (make-pathname
+ *prefix*
+ (sprintf "lib/chicken/~a" (##sys#fudge 42)))
+ (repository-path))
+ (repository-extra-paths)))))
+
(define (get-prefix #!optional runtime)
(cond ((and *cross-chicken*
(not *host-extension*))
@@ -226,10 +239,13 @@
(chicken-version) )
;; Duplication of (extension-information) to get custom
;; prefix. This should be fixed.
- ((let* ((ep (##sys#canonicalize-extension-path x 'ext-version))
- (sf (make-pathname (repo-path) ep "setup-info")))
- (and (file-exists? sf)
- (with-input-from-file sf read))) =>
+ ((let ((ep (##sys#canonicalize-extension-path x 'ext-version)))
+ (let loop ((paths (repo-paths)))
+ (cond ((null? paths) #f)
+ ((let ((sf (make-pathname (car paths) ep "setup-info")))
+ (and (file-exists? sf)
+ (with-input-from-file sf read))))
+ (else (loop (cdr paths)))))) =>
(lambda (info)
(let ((a (assq 'version info)))
(if a
@@ -776,7 +792,10 @@
"installed extension has no information about which egg it belongs to"
(pathname-file sf))
#f))))
- (glob (make-pathname (repo-path) "*" "setup-info")))
+ (append-map
+ (lambda (path)
+ (glob (make-pathname path "*" "setup-info")))
+ (repo-paths)))
equal?))
(define (list-available-extensions trans locn)
diff --git a/chicken.import.scm b/chicken.import.scm
index f6e3a19..be1637c 100644
--- a/chicken.import.scm
+++ b/chicken.import.scm
@@ -200,6 +200,7 @@
repl
repl-prompt
repository-path
+ repository-extra-paths
require
reset
reset-handler
diff --git a/eval.scm b/eval.scm
index 6242f62..f7d76d4 100644
--- a/eval.scm
+++ b/eval.scm
@@ -81,6 +81,7 @@
(define-constant source-file-extension ".scm")
(define-constant setup-file-extension "setup-info")
(define-constant repository-environment-variable "CHICKEN_REPOSITORY")
+(define-constant repository-extra-environment-variable "CHICKEN_REPOSITORY_EXTRA")
(define-constant prefix-environment-variable "CHICKEN_PREFIX")
; these are actually in unit extras, but that is used by default
@@ -1176,6 +1177,25 @@
(define ##sys#repository-path repository-path)
+(define ##sys#repository-extra-paths
+ (let* ((repaths (get-environment-variable repository-extra-environment-variable))
+ (repaths (if repaths
+ (let ((len (string-length repaths)))
+ (let loop ((i 0) (offset 0) (res '()))
+ (cond ((> i len)
+ (reverse res))
+ ((or (= i len) (eq? #\: (string-ref repaths i)))
+ (loop (+ i 1) (+ i 1) (cons (substring repaths offset i) res)))
+ (else
+ (loop (+ i 1) offset res)))))
+ '())))
+ (lambda (#!optional val)
+ (if val
+ (set! repaths val)
+ repaths))))
+
+(define repository-extra-paths ##sys#repository-extra-paths)
+
(define ##sys#setup-mode #f)
(define ##sys#find-extension
@@ -1193,6 +1213,7 @@
(let loop ((paths (##sys#append
(if ##sys#setup-mode '(".") '())
(if rp (list rp) '())
+ (##sys#repository-extra-paths)
(if inc? ##sys#include-pathnames '())
(if ##sys#setup-mode '() '("."))) ))
(and (pair? paths)
@@ -1252,12 +1273,16 @@
[string-append string-append]
[read read] )
(lambda (id loc)
- (and-let* ((rp (##sys#repository-path)))
- (let* ((p (##sys#canonicalize-extension-path id loc))
- (rpath (string-append rp "/" p ".")) )
- (cond ((file-exists? (string-append rpath setup-file-extension))
- => (cut with-input-from-file <> read) )
- (else #f) ) ) ) ) ))
+ (let loop ((rpaths (cons (##sys#repository-path) (##sys#repository-extra-paths))))
+ (and (pair? rpaths)
+ (let ((rp (car rpaths)))
+ (if (not rp)
+ (loop (cdr rpaths))
+ (let* ((p (##sys#canonicalize-extension-path id loc))
+ (rpath (string-append rp "/" p ".")) )
+ (cond ((file-exists? (string-append rpath setup-file-extension))
+ => (cut with-input-from-file <> read) )
+ (else (loop (cdr rpaths))) ) )) ))) ) ))
(define (extension-information ext)
(##sys#extension-information ext 'extension-information) )
--
2.1.4

View File

@@ -0,0 +1,112 @@
{
lib,
stdenv,
fetchurl,
makeWrapper,
darwin,
bootstrap-chicken ? null,
}:
let
version = "4.13.0";
platform =
with stdenv;
if isDarwin then
"macosx"
else if isCygwin then
"cygwin"
else if (isFreeBSD || isOpenBSD) then
"bsd"
else if isSunOS then
"solaris"
else
"linux"; # Should be a sane default
in
stdenv.mkDerivation {
pname = "chicken";
inherit version;
binaryVersion = 8;
src = fetchurl {
url = "https://code.call-cc.org/releases/${version}/chicken-${version}.tar.gz";
sha256 = "0hvckhi5gfny3mlva6d7y9pmx7cbwvq0r7mk11k3sdiik9hlkmdd";
};
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
# There is not enough space in the load command to accomodate a full path to the store,
# so use `@executable_path` to specify a relative path to chickens lib folder.
sed -e '/POSTINSTALL_PROGRAM_FLAGS = /{s|$(LIBDIR)|@executable_path/../lib|}' \
-i Makefile.macosx
'';
setupHook = lib.optional (bootstrap-chicken != null) ./setup-hook.sh;
# -fno-strict-overflow is not a supported argument in clang on darwin
hardeningDisable = lib.optionals stdenv.hostPlatform.isDarwin [ "strictoverflow" ];
makeFlags = [
"PLATFORM=${platform}"
"PREFIX=$(out)"
"VARDIR=$(out)/var/lib"
]
++ (lib.optionals stdenv.hostPlatform.isDarwin [
"XCODE_TOOL_PATH=${darwin.binutils.bintools}/bin"
"C_COMPILER=$(CC)"
"POSTINSTALL_PROGRAM=${stdenv.cc.targetPrefix}install_name_tool"
]);
# We need a bootstrap-chicken to regenerate the c-files after
# applying a patch to add support for CHICKEN_REPOSITORY_EXTRA
patches = lib.optionals (bootstrap-chicken != null) [
./0001-Introduce-CHICKEN_REPOSITORY_EXTRA.patch
];
nativeBuildInputs = [
makeWrapper
]
++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
darwin.autoSignDarwinBinariesHook
];
buildInputs = lib.optionals (bootstrap-chicken != null) [
bootstrap-chicken
];
preBuild = lib.optionalString (bootstrap-chicken != null) ''
# Backup the build* files - those are generated from hostname,
# git-tag, etc. and we don't need/want that
mkdir -p build-backup
mv buildid buildbranch buildtag.h build-backup
# Regenerate eval.c after the patch
make spotless $makeFlags
mv build-backup/* .
'';
postInstall = ''
for f in $out/bin/*
do
wrapProgram $f \
--prefix PATH : ${stdenv.cc}/bin
done
'';
# TODO: Assert csi -R files -p '(pathname-file (repository-path))' == binaryVersion
meta = {
homepage = "http://www.call-cc.org/";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ corngood ];
platforms = lib.platforms.linux ++ lib.platforms.darwin; # Maybe other Unix
description = "Portable compiler for the Scheme programming language";
longDescription = ''
CHICKEN is a compiler for the Scheme programming language.
CHICKEN produces portable and efficient C, supports almost all
of the R5RS Scheme language standard, and includes many
enhancements and extensions. CHICKEN runs on Linux, macOS,
Windows, and many Unix flavours.
'';
};
}

View File

@@ -0,0 +1,24 @@
{ lib, newScope }:
let
callPackage = newScope self;
self = {
pkgs = self // {
recurseForDerivations = false;
};
fetchegg = callPackage ./fetchegg { };
eggDerivation = callPackage ./eggDerivation.nix { };
chicken = callPackage ./chicken.nix {
bootstrap-chicken = self.chicken.override { bootstrap-chicken = null; };
};
chickenEggs = lib.recurseIntoAttrs (callPackage ./eggs.nix { });
egg2nix = callPackage ./egg2nix.nix { };
};
in
self

View File

@@ -0,0 +1,35 @@
{
lib,
eggDerivation,
fetchFromGitHub,
chickenEggs,
}:
# Note: This mostly reimplements the default.nix already contained in
# the tarball. Is there a nicer way than duplicating code?
eggDerivation rec {
name = "egg2nix-${version}";
version = "0.5";
src = fetchFromGitHub {
owner = "the-kenny";
repo = "egg2nix";
rev = version;
sha256 = "sha256-5ov2SWVyTUQ6NHnZNPRywd9e7oIxHlVWv4uWbsNaj/s=";
};
buildInputs = with chickenEggs; [
matchable
http-client
];
meta = {
description = "Generate nix-expression from CHICKEN scheme eggs";
mainProgram = "egg2nix";
homepage = "https://github.com/the-kenny/egg2nix";
license = lib.licenses.bsd3;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ corngood ];
};
}

View File

@@ -0,0 +1,62 @@
{
lib,
stdenv,
chicken,
makeWrapper,
}:
{
name,
src,
buildInputs ? [ ],
chickenInstallFlags ? [ ],
cscOptions ? [ ],
...
}@args:
let
libPath = "${chicken}/var/lib/chicken/${toString chicken.binaryVersion}/";
overrides = import ./overrides.nix;
baseName = lib.getName name;
override = if builtins.hasAttr baseName overrides then builtins.getAttr baseName overrides else { };
in
stdenv.mkDerivation (
{
name = "chicken-${name}";
propagatedBuildInputs = buildInputs;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ chicken ];
CSC_OPTIONS = lib.concatStringsSep " " cscOptions;
CHICKEN_REPOSITORY = libPath;
CHICKEN_INSTALL_PREFIX = "$out";
installPhase = ''
runHook preInstall
chicken-install -p $out ${lib.concatStringsSep " " chickenInstallFlags}
for f in $out/bin/*
do
wrapProgram $f \
--set CHICKEN_REPOSITORY $CHICKEN_REPOSITORY \
--prefix CHICKEN_REPOSITORY_EXTRA : "$out/lib/chicken/${toString chicken.binaryVersion}/:$CHICKEN_REPOSITORY_EXTRA" \
--prefix CHICKEN_INCLUDE_PATH \; "$CHICKEN_INCLUDE_PATH;$out/share/" \
--prefix PATH : "$out/bin:${chicken}/bin:$CHICKEN_REPOSITORY_EXTRA:$CHICKEN_REPOSITORY"
done
runHook postInstall
'';
meta = {
inherit (chicken.meta) platforms;
}
// args.meta or { };
}
// (removeAttrs args [
"name"
"buildInputs"
"meta"
])
// override
)

View File

@@ -0,0 +1,137 @@
{ pkgs }:
rec {
inherit (pkgs) eggDerivation fetchegg;
base64 = eggDerivation {
name = "base64-3.3.1";
src = fetchegg {
name = "base64";
version = "3.3.1";
sha256 = "0wmldiwwg1jpcn07wb906nc53si5j7sa83wgyq643xzqcx4v4x1d";
};
buildInputs = [
];
};
defstruct = eggDerivation {
name = "defstruct-1.6";
src = fetchegg {
name = "defstruct";
version = "1.6";
sha256 = "0lsgl32nmb5hxqiii4r3292cx5vqh50kp6v062nfiyid9lhrj0li";
};
buildInputs = [
];
};
http-client = eggDerivation {
name = "http-client-0.18";
src = fetchegg {
name = "http-client";
version = "0.18";
sha256 = "1b9x66kfcglld4xhm06vba00gw37vr07c859kj7lmwnk9nwhcplg";
};
buildInputs = [
intarweb
uri-common
simple-md5
sendfile
];
};
intarweb = eggDerivation {
name = "intarweb-1.7";
src = fetchegg {
name = "intarweb";
version = "1.7";
sha256 = "1arjgn5g4jfdzj3nlrhxk235qwf6k6jxr14yhnncnfbgdb820xp8";
};
buildInputs = [
defstruct
uri-common
base64
];
};
matchable = eggDerivation {
name = "matchable-3.7";
src = fetchegg {
name = "matchable";
version = "3.7";
sha256 = "1vc9rpb44fhn0n91hzglin986dw9zj87fikvfrd7j308z22a41yh";
};
buildInputs = [
];
};
sendfile = eggDerivation {
name = "sendfile-1.8.3";
src = fetchegg {
name = "sendfile";
version = "1.8.3";
sha256 = "036x4xdndx7qly94afnag5b9idd1yymdm8d832w2cy054y7lxqsi";
};
buildInputs = [
];
};
simple-md5 = eggDerivation {
name = "simple-md5-0.0.1";
src = fetchegg {
name = "simple-md5";
version = "0.0.1";
sha256 = "1h0b51p9wl1dl3pzs39hdq3hk2qnjgn8n750bgmh0651g4lzmq3i";
};
buildInputs = [
];
};
uri-common = eggDerivation {
name = "uri-common-1.4";
src = fetchegg {
name = "uri-common";
version = "1.4";
sha256 = "01ds1gixcn4rz657x3hr4rhw2496hsjff42ninw0k39l8i1cbh7c";
};
buildInputs = [
uri-generic
defstruct
matchable
];
};
uri-generic = eggDerivation {
name = "uri-generic-2.46";
src = fetchegg {
name = "uri-generic";
version = "2.46";
sha256 = "10ivf4xlmr6jcm00l2phq1y73hjv6g3qgr38ycc8rw56wv6sbm4g";
};
buildInputs = [
matchable
];
};
}

View File

@@ -0,0 +1,5 @@
;; Eggs used by egg2nix
http-client
intarweb
matchable
uri-common

View File

@@ -0,0 +1,5 @@
echo "exporting egg ${eggName} (version $version) into $out"
mkdir -p $out
chicken-install -r "${eggName}:${version}"
cp -r ${eggName}/* $out/

View File

@@ -0,0 +1,33 @@
# Fetches a chicken egg from henrietta using `chicken-install -r'
# See: http://wiki.call-cc.org/chicken-projects/egg-index-4.html
{
lib,
stdenvNoCC,
chicken,
}:
{
name,
version,
md5 ? "",
sha256 ? "",
}:
if md5 != "" then
throw "fetchegg does not support md5 anymore, please use sha256"
else
stdenvNoCC.mkDerivation {
name = "chicken-${name}-export-${version}";
builder = ./builder.sh;
nativeBuildInputs = [ chicken ];
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = sha256;
inherit version;
eggName = name;
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
}

View File

@@ -0,0 +1,10 @@
{
setup-helper = {
preBuild = ''
substituteInPlace setup-helper.setup \
--replace "(chicken-home)" \"$out/share/\"
cat setup-helper.setup
'';
};
}

View File

@@ -0,0 +1,6 @@
addChickenRepositoryPath() {
addToSearchPathWithCustomDelimiter : CHICKEN_REPOSITORY_EXTRA "$1/lib/chicken/8/"
export CHICKEN_INCLUDE_PATH="$1/share${CHICKEN_INCLUDE_PATH:+;$CHICKEN_INCLUDE_PATH}"
}
addEnvHooks "$targetOffset" addChickenRepositoryPath

View File

@@ -0,0 +1,101 @@
{
lib,
stdenv,
fetchurl,
makeWrapper,
darwin,
bootstrap-chicken ? null,
testers,
}:
let
platform =
with stdenv;
if isDarwin then
"macosx"
else if isCygwin then
"cygwin"
else if (isFreeBSD || isOpenBSD) then
"bsd"
else if isSunOS then
"solaris"
else
"linux"; # Should be a sane default
in
stdenv.mkDerivation (finalAttrs: {
pname = "chicken";
version = "5.4.0";
binaryVersion = 11;
src = fetchurl {
url = "https://code.call-cc.org/releases/${finalAttrs.version}/chicken-${finalAttrs.version}.tar.gz";
sha256 = "sha256-PF1KphwRZ79tm/nq+JHadjC6n188Fb8JUVpwOb/N7F8=";
};
# Disable two broken tests: "static link" and "linking tests"
postPatch = ''
sed -i tests/runtests.sh -e "/static link/,+4 { s/^/# / }"
sed -i tests/runtests.sh -e "/linking tests/,+11 { s/^/# / }"
'';
setupHook = lib.optional (bootstrap-chicken != null) ./setup-hook.sh;
makeFlags = [
"PLATFORM=${platform}"
"PREFIX=$(out)"
"C_COMPILER=$(CC)"
"CXX_COMPILER=$(CXX)"
]
++ (lib.optionals stdenv.hostPlatform.isDarwin [
"XCODE_TOOL_PATH=${darwin.binutils.bintools}/bin"
"LINKER_OPTIONS=-headerpad_max_install_names"
"POSTINSTALL_PROGRAM=install_name_tool"
])
++ (lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"HOSTSYSTEM=${stdenv.hostPlatform.config}"
"TARGET_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
"TARGET_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"
]);
nativeBuildInputs = [
makeWrapper
]
++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
darwin.autoSignDarwinBinariesHook
];
buildInputs = lib.optionals (bootstrap-chicken != null) [
bootstrap-chicken
];
doCheck = !stdenv.hostPlatform.isDarwin;
postCheck = ''
./csi -R chicken.pathname -R chicken.platform \
-p "(assert (equal? \"${toString finalAttrs.binaryVersion}\" (pathname-file (car (repository-path)))))"
'';
passthru.tests.version = testers.testVersion {
package = finalAttrs.finalPackage;
command = "csi -version";
};
meta = {
homepage = "https://call-cc.org/";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [
corngood
nagy
konst-aa
];
platforms = lib.platforms.unix;
description = "Portable compiler for the Scheme programming language";
longDescription = ''
CHICKEN is a compiler for the Scheme programming language.
CHICKEN produces portable and efficient C, supports almost all
of the R5RS Scheme language standard, and includes many
enhancements and extensions. CHICKEN runs on Linux, macOS,
Windows, and many Unix flavours.
'';
};
})

View File

@@ -0,0 +1,90 @@
{
lib,
newScope,
fetchurl,
}:
let
# Some eggs mistakenly declare dependencies on modules which are part of chicken itself and thus
# need not (and cannot) be installed as eggs. Instead of marking such eggs as broken, we remove
# these invalid dependencies.
invalidDependencies = [
"srfi-4"
];
in
lib.makeScope newScope (self: {
fetchegg =
{
pname,
version,
sha256,
...
}:
fetchurl {
inherit sha256;
url = "https://code.call-cc.org/egg-tarballs/5/${pname}/${pname}-${version}.tar.gz";
};
eggDerivation = self.callPackage ./eggDerivation.nix { };
chicken = self.callPackage ./chicken.nix {
bootstrap-chicken = self.chicken.override { bootstrap-chicken = null; };
};
chickenEggs = lib.recurseIntoAttrs (
lib.makeScope self.newScope (
eggself:
(lib.mapAttrs (
pname:
eggData@{
version,
synopsis,
dependencies,
license,
...
}:
self.eggDerivation {
inherit pname version;
src = self.fetchegg (eggData // { inherit pname; });
buildInputs = map (x: eggself.${x}) (lib.subtractLists invalidDependencies dependencies);
meta.homepage = "https://wiki.call-cc.org/eggref/5/${pname}";
meta.description = synopsis;
meta.license =
(
lib.licenses
// {
"agpl" = lib.licenses.agpl3Only;
"artistic" = lib.licenses.artistic2;
"bsd" = lib.licenses.bsd3;
"bsd-1-clause" = lib.licenses.bsd1;
"bsd-2-clause" = lib.licenses.bsd2;
"bsd-3" = lib.licenses.bsd3;
"bsd-3-clause" = lib.licenses.bsd3;
"gpl" = lib.licenses.gpl3Only;
"gpl-2" = lib.licenses.gpl2Only;
"gplv2" = lib.licenses.gpl2Only;
"gpl-3" = lib.licenses.gpl3Only;
"gpl-3.0" = lib.licenses.gpl3Only;
"gplv3" = lib.licenses.gpl3Only;
"lgpl" = lib.licenses.lgpl3Only;
"lgpl-2" = lib.licenses.lgpl2Only;
"lgpl-2.0+" = lib.licenses.lgpl2Plus;
"lgpl-2.1" = lib.licenses.lgpl21Only;
"lgpl-2.1-or-later" = lib.licenses.lgpl21Plus;
"lgpl-3" = lib.licenses.lgpl3Only;
"lgplv3" = lib.licenses.lgpl3Only;
"public-domain" = lib.licenses.publicDomain;
"srfi" = lib.licenses.bsd3;
"unicode" = lib.licenses.ucd;
"unknown" = lib.licenses.free;
"zlib-acknowledgement" = lib.licenses.zlib;
}
).${license} or license;
}
) (lib.importTOML ./deps.toml))
)
);
egg2nix = self.callPackage ./egg2nix.nix { };
})

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,31 @@
{
lib,
eggDerivation,
fetchFromGitHub,
chickenEggs,
}:
eggDerivation {
src = fetchFromGitHub {
owner = "corngood";
repo = "egg2nix";
rev = "chicken-5";
sha256 = "1vfnhbcnyakywgjafhs0k5kpsdnrinzvdjxpz3fkwas1jsvxq3d1";
};
pname = "egg2nix";
version = "c5-git";
buildInputs = with chickenEggs; [
args
matchable
];
meta = {
description = "Generate nix-expression from CHICKEN scheme eggs";
mainProgram = "egg2nix";
homepage = "https://github.com/the-kenny/egg2nix";
license = lib.licenses.bsd3;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ corngood ];
};
}

View File

@@ -0,0 +1,89 @@
{
callPackage,
lib,
stdenv,
chicken,
makeWrapper,
}:
{
src,
buildInputs ? [ ],
chickenInstallFlags ? [ ],
cscOptions ? [ ],
...
}@args:
let
nameVersionAssertion =
pred: lib.assertMsg pred "either name or both pname and version must be given";
pname =
if args ? pname then
assert nameVersionAssertion (!args ? name && args ? version);
args.pname
else
assert nameVersionAssertion (args ? name && !args ? version);
lib.getName args.name;
version = if args ? version then args.version else lib.getVersion args.name;
name = if args ? name then args.name else "${args.pname}-${args.version}";
overrides = callPackage ./overrides.nix { };
override = if builtins.hasAttr pname overrides then builtins.getAttr pname overrides else lib.id;
in
(stdenv.mkDerivation (
{
pname = "chicken-${pname}";
inherit version;
propagatedBuildInputs = buildInputs;
nativeBuildInputs = [
chicken
makeWrapper
];
buildInputs = [ chicken ];
strictDeps = true;
CSC_OPTIONS = lib.concatStringsSep " " cscOptions;
buildPhase = ''
runHook preBuild
chicken-install -cached -no-install -host ${lib.escapeShellArgs chickenInstallFlags}
runHook postBuild
'';
installPhase = ''
runHook preInstall
export CHICKEN_INSTALL_PREFIX=$out
export CHICKEN_INSTALL_REPOSITORY=$out/lib/chicken/${toString chicken.binaryVersion}
chicken-install -cached -host ${lib.escapeShellArgs chickenInstallFlags}
# Patching generated .egg-info instead of original .egg to work around https://bugs.call-cc.org/ticket/1855
csi -e "(write (cons '(version \"${version}\") (read)))" < "$CHICKEN_INSTALL_REPOSITORY/${pname}.egg-info" > "${pname}.egg-info.new"
mv "${pname}.egg-info.new" "$CHICKEN_INSTALL_REPOSITORY/${pname}.egg-info"
for f in $out/bin/*
do
wrapProgram $f \
--prefix CHICKEN_REPOSITORY_PATH : "$out/lib/chicken/${toString chicken.binaryVersion}:$CHICKEN_REPOSITORY_PATH" \
--prefix CHICKEN_INCLUDE_PATH : "$CHICKEN_INCLUDE_PATH:$out/share" \
--prefix PATH : "$out/bin:${chicken}/bin:$CHICKEN_REPOSITORY_PATH"
done
runHook postInstall
'';
dontConfigure = true;
meta = {
inherit (chicken.meta) platforms;
}
// args.meta or { };
}
// removeAttrs args [
"name"
"pname"
"version"
"buildInputs"
"meta"
]
)).overrideAttrs
override

View File

@@ -0,0 +1,314 @@
{
stdenv,
pkgs,
lib,
chickenEggs,
}:
let
inherit (lib) addMetaAttrs;
addToNativeBuildInputs = pkg: old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ lib.toList pkg;
};
addToBuildInputs = pkg: old: {
buildInputs = (old.buildInputs or [ ]) ++ lib.toList pkg;
};
addToPropagatedBuildInputs = pkg: old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ lib.toList pkg;
};
addPkgConfig = old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkg-config ];
};
addToBuildInputsWithPkgConfig = pkg: old: (addPkgConfig old) // (addToBuildInputs pkg old);
addToPropagatedBuildInputsWithPkgConfig =
pkg: old: (addPkgConfig old) // (addToPropagatedBuildInputs pkg old);
broken = addMetaAttrs { broken = true; };
brokenOnDarwin = addMetaAttrs { broken = stdenv.hostPlatform.isDarwin; };
addToCscOptions = opt: old: {
CSC_OPTIONS = lib.concatStringsSep " " ([ old.CSC_OPTIONS or "" ] ++ lib.toList opt);
};
in
{
breadline = addToBuildInputs pkgs.readline;
blas = addToBuildInputsWithPkgConfig pkgs.blas;
blosc = addToBuildInputs pkgs.c-blosc;
botan = addToBuildInputsWithPkgConfig pkgs.botan2;
cairo =
old:
(addToBuildInputsWithPkgConfig pkgs.cairo old)
// (addToPropagatedBuildInputs (with chickenEggs; [
srfi-1
srfi-13
]) old);
cmark = addToBuildInputs pkgs.cmark;
epoxy =
old:
(addToPropagatedBuildInputsWithPkgConfig pkgs.libepoxy old)
// {
env.NIX_CFLAGS_COMPILE = toString [
(
if stdenv.cc.isClang then
"-Wno-error=incompatible-function-pointer-types"
else
"-Wno-error=incompatible-pointer-types"
)
"-Wno-error=int-conversion"
];
};
espeak = addToBuildInputsWithPkgConfig pkgs.espeak-ng;
exif = addToBuildInputsWithPkgConfig pkgs.libexif;
expat =
old:
(addToBuildInputsWithPkgConfig pkgs.expat old)
// {
env.NIX_CFLAGS_COMPILE = toString [
(
if stdenv.cc.isClang then
"-Wno-error=incompatible-function-pointer-types"
else
"-Wno-error=incompatible-pointer-types"
)
];
};
ezxdisp =
old:
(addToBuildInputsWithPkgConfig pkgs.xorg.libX11 old)
// {
env.NIX_CFLAGS_COMPILE = toString [
"-Wno-error=implicit-function-declaration"
];
};
freetype = addToBuildInputsWithPkgConfig pkgs.freetype;
fuse = addToBuildInputsWithPkgConfig pkgs.fuse;
gl-math = old: {
env.NIX_CFLAGS_COMPILE = toString [
"-Wno-error=incompatible-pointer-types"
];
};
gl-utils = addPkgConfig;
glfw3 = addToBuildInputsWithPkgConfig pkgs.glfw3;
glls = addPkgConfig;
glut =
old:
(brokenOnDarwin old)
// lib.optionalAttrs (!stdenv.hostPlatform.isDarwin) (
addToCscOptions [
"-I${(lib.getDev pkgs.libglut)}/include"
"-I${(lib.getDev pkgs.libGL)}/include"
"-I${(lib.getDev pkgs.libGLU)}/include"
] old
)
// (addToBuildInputs pkgs.libglut old);
iconv = addToBuildInputs (lib.optional stdenv.hostPlatform.isDarwin pkgs.libiconv);
icu = addToBuildInputsWithPkgConfig pkgs.icu;
imlib2 = addToBuildInputsWithPkgConfig pkgs.imlib2;
inotify =
old:
(addToBuildInputs (lib.optional stdenv.hostPlatform.isDarwin pkgs.libinotify-kqueue) old)
// lib.optionalAttrs stdenv.hostPlatform.isDarwin (addToCscOptions "-L -linotify" old);
leveldb = addToBuildInputs pkgs.leveldb;
magic = addToBuildInputs pkgs.file;
magic-pipes = addToBuildInputs pkgs.chickenPackages_5.chickenEggs.regex;
mdh =
old:
(addToBuildInputs pkgs.pcre old)
// {
env.NIX_CFLAGS_COMPILE = toString [
"-Wno-error=implicit-function-declaration"
"-Wno-error=implicit-int"
];
};
# missing dependency in upstream egg
mistie = addToPropagatedBuildInputs (with chickenEggs; [ srfi-1 ]);
mosquitto = addToPropagatedBuildInputs [ pkgs.mosquitto ];
nanomsg = addToBuildInputs pkgs.nanomsg;
ncurses = addToBuildInputsWithPkgConfig [ pkgs.ncurses ];
opencl = addToBuildInputs [
pkgs.opencl-headers
pkgs.ocl-icd
];
openssl = addToBuildInputs pkgs.openssl;
plot = addToBuildInputs pkgs.plotutils;
postgresql = addToBuildInputsWithPkgConfig pkgs.libpq;
rocksdb = addToBuildInputs pkgs.rocksdb_8_3;
# missing dependency in upstream egg
s9fes-char-graphics-shapes = addToPropagatedBuildInputs (
with chickenEggs;
[
utf8
s9fes-char-graphics
]
);
# missing dependency in upstream egg
s9fes-char-graphics = addToPropagatedBuildInputs (
with chickenEggs;
[
srfi-1
utf8
record-variants
]
);
scheme2c-compatibility = addPkgConfig;
sdl-base =
old:
(
(addToPropagatedBuildInputsWithPkgConfig pkgs.SDL old)
//
# needed for sdl-config to be in PATH
(addToNativeBuildInputs pkgs.SDL old)
);
sdl2 =
old:
(
(addToPropagatedBuildInputsWithPkgConfig pkgs.SDL2 old)
//
# needed for sdl2-config to be in PATH
(addToNativeBuildInputs pkgs.SDL2 old)
);
sdl2-image =
old:
(
(addToPropagatedBuildInputsWithPkgConfig pkgs.SDL2_image old)
//
# needed for sdl2-config to be in PATH
(addToNativeBuildInputs pkgs.SDL2 old)
);
sdl2-ttf =
old:
(
(addToPropagatedBuildInputsWithPkgConfig pkgs.SDL2_ttf old)
//
# needed for sdl2-config to be in PATH
(addToNativeBuildInputs pkgs.SDL2 old)
);
soil = addToPropagatedBuildInputsWithPkgConfig pkgs.libepoxy;
sqlite3 = addToBuildInputs pkgs.sqlite;
stemmer = old: (addToBuildInputs pkgs.libstemmer old) // (addToCscOptions "-L -lstemmer" old);
stfl =
old: (addToBuildInputs [ pkgs.ncurses pkgs.stfl ] old) // (addToCscOptions "-L -lncurses" old);
taglib =
old:
(addToBuildInputs [ pkgs.zlib pkgs.taglib_1 ] old)
// (
# needed for tablib-config to be in PATH
addToNativeBuildInputs pkgs.taglib_1 old
);
uuid-lib = addToBuildInputs pkgs.libuuid;
webview = addToBuildInputsWithPkgConfig pkgs.webkitgtk_4_0;
ws-client = addToBuildInputs pkgs.zlib;
xlib = addToPropagatedBuildInputs pkgs.xorg.libX11;
yaml = addToBuildInputs pkgs.libyaml;
zlib = addToBuildInputs pkgs.zlib;
zmq = addToBuildInputs pkgs.zeromq;
zstd = addToBuildInputs pkgs.zstd;
# less trivial fixes, should be upstreamed
git =
old:
(addToBuildInputsWithPkgConfig pkgs.libgit2 old)
// {
postPatch = ''
substituteInPlace libgit2.scm \
--replace "asize" "reserved"
'';
};
lazy-ffi =
old:
(addToBuildInputs pkgs.libffi old)
// {
postPatch = ''
substituteInPlace lazy-ffi.scm \
--replace "ffi/ffi.h" "ffi.h"
'';
};
opengl =
old:
(brokenOnDarwin old)
// (addToBuildInputsWithPkgConfig (lib.optionals (!stdenv.hostPlatform.isDarwin) [
pkgs.libGL
pkgs.libGLU
]) old)
// {
postPatch = ''
substituteInPlace opengl.egg \
--replace 'framework ' 'framework" "'
'';
};
posix-shm = old: {
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace build.scm \
--replace "-lrt" ""
'';
};
# platform changes
pledge = addMetaAttrs { platforms = lib.platforms.openbsd; };
unveil = addMetaAttrs { platforms = lib.platforms.openbsd; };
# overrides for chicken 5.4
dbus =
old:
(addToBuildInputsWithPkgConfig [ pkgs.dbus ] old)
// {
# backticks in compiler options
# aren't supported anymore as of chicken 5.4, it seems.
preBuild = ''
substituteInPlace \
dbus.egg dbus.setup \
--replace '`pkg-config --cflags dbus-1`' "$(pkg-config --cflags dbus-1)" \
--replace '`pkg-config --libs dbus-1`' "$(pkg-config --libs dbus-1)"
'';
};
math = old: {
# define-values is used but not imported
# some breaking change happened now it needs to be done
# explicitly?
preBuild = ''
substituteInPlace *.scm **/*.scm \
--replace-quiet 'only chicken.base' 'only chicken.base define-values'
'';
};
socket = old: {
# chicken-do checks for changes to a file that doesn't exist
preBuild = ''
touch socket-config
'';
};
# mark broken
allegro =
old:
(broken old)
// {
# depends on 'chicken' egg, which doesn't exist, so we specify all the deps here (needs to be
# kept around even when marked as broken so that evaluation doesn't break due to the missing
# attribute).
propagatedBuildInputs = [
chickenEggs.foreigners
];
};
ephem = broken;
canvas-draw = broken;
coops-utils = broken;
crypt = broken;
gemini = broken;
gemini-client = broken;
hypergiant = broken;
iup = broken;
kiwi = broken;
lmdb-ht = broken;
mpi = broken;
pyffi = broken;
qt-light = broken;
sundials = broken;
svn-client = broken;
tokyocabinet = broken;
# mark broken darwin
# fatal error: 'mqueue.h' file not found
posix-mq = brokenOnDarwin;
# Undefined symbols for architecture arm64: "_pthread_setschedprio"
pthreads = brokenOnDarwin;
# error: use of undeclared identifier 'B4000000'
stty = brokenOnDarwin;
}

View File

@@ -0,0 +1,43 @@
(import (chicken process-context)
(chicken format)
(chicken string))
(define env-var get-environment-variable)
(define ref alist-ref)
(define egg (read))
(printf "[~A]\n" (env-var "EGG_NAME"))
(define dependencies
(map (lambda (dep)
(->string (if (list? dep)
(car dep)
dep)))
(append
(ref 'dependencies egg eqv? '())
;; TODO separate this into `buildInputs` and `propagatedBuildInputs`
(ref 'build-dependencies egg eqv? '()))))
(printf "dependencies = [~A]\n"
(string-intersperse (map (lambda (dep) (sprintf "~S" dep))
dependencies)
", "))
(define license (ref 'license egg))
(printf "license = ~S\n"
(if (not license)
""
(string-translate (->string (car license))
"ABCDEFGHIJKLMNOPQRSTUVWXYZ "
"abcdefghijklmnopqrstuvwxyz-")))
(printf "sha256 = ~S\n" (env-var "EGG_SHA256"))
(define synopsis (ref 'synopsis egg))
(printf "synopsis = ~S\n"
(if (not synopsis)
""
(car synopsis)))
(printf "version = ~S\n" (env-var "EGG_VERSION"))
(print)

View File

@@ -0,0 +1,6 @@
addChickenRepositoryPath() {
addToSearchPathWithCustomDelimiter : CHICKEN_REPOSITORY_PATH "$1/lib/chicken/11"
addToSearchPathWithCustomDelimiter : CHICKEN_INCLUDE_PATH "$1/share"
}
addEnvHooks "$targetOffset" addChickenRepositoryPath

View File

@@ -0,0 +1,15 @@
#!/usr/bin/env nix-shell
#! nix-shell -I nixpkgs=../../../../.. -i ysh -p oils-for-unix chicken nix-prefetch-git jq
setglobal ENV.URL_PREFIX="https://code.call-cc.org/egg-tarballs/5/"
cd $(nix-prefetch-git --deepClone --quiet \
https://code.call-cc.org/eggs-5-latest | jq --raw-output .path)
echo "# THIS IS A GENERATED FILE. DO NOT EDIT!" > $_this_dir/deps.toml
for i, item in */*/*.egg {
setglobal ENV.EGG_NAME=$(dirname $(dirname $item))
setglobal ENV.EGG_VERSION=$(basename $(dirname $item))
setglobal ENV.EGG_URL="$[ENV.URL_PREFIX]$[ENV.EGG_NAME]/$[ENV.EGG_NAME]-$[ENV.EGG_VERSION].tar.gz"
setglobal ENV.EGG_SHA256=$(nix-prefetch-url $[ENV.EGG_URL])
csi -s $_this_dir/read-egg.scm < $item
} >> $_this_dir/deps.toml

View File

@@ -0,0 +1,88 @@
{
lib,
llvmPackages_18,
fetchzip,
sbcl,
pkg-config,
fmt_9,
gmpxx,
libelf,
boost,
libunwind,
ninja,
}:
let
inherit (llvmPackages_18) stdenv llvm libclang;
in
stdenv.mkDerivation rec {
pname = "clasp";
version = "2.7.0";
src = fetchzip {
url = "https://github.com/clasp-developers/clasp/releases/download/${version}/clasp-${version}.tar.gz";
hash = "sha256-IoEwsMvY/bbb6K6git+7zRGP0DIJDROt69FBQuzApRk=";
};
patches = [
./remove-unused-command-line-argument.patch
];
# Workaround for https://github.com/clasp-developers/clasp/issues/1590
postPatch = ''
echo '(defmethod configure-unit (c (u (eql :git))))' >> src/koga/units.lisp
'';
nativeBuildInputs = [
sbcl
pkg-config
fmt_9
gmpxx
libelf
boost
libunwind
ninja
llvm
libclang
];
ninjaFlags = [
"-C"
"build"
];
configurePhase = ''
export SOURCE_DATE_EPOCH=1
export ASDF_OUTPUT_TRANSLATIONS=$(pwd):$(pwd)/__fasls
sbcl --script koga \
--skip-sync \
--build-mode=bytecode-faso \
--cc=$NIX_CC/bin/cc \
--cxx=$NIX_CC/bin/c++ \
--reproducible-build \
--package-path=/ \
--bin-path=$out/bin \
--lib-path=$out/lib \
--dylib-path=$out/lib \
--share-path=$out/share \
--pkgconfig-path=$out/lib/pkgconfig
'';
postInstall = ''
# --dylib-path not honored. Fix it in post.
mv $out/libclasp* $out/lib/
'';
meta = {
description = "Common Lisp implementation based on LLVM with C++ integration";
license = lib.licenses.lgpl21Plus;
teams = [ lib.teams.lisp ];
platforms = [
"x86_64-linux"
"x86_64-darwin"
];
homepage = "https://github.com/clasp-developers/clasp";
mainProgram = "clasp";
};
}

View File

@@ -0,0 +1,13 @@
diff --git a/src/koga/units.lisp b/src/koga/units.lisp
index 808cebd17..2bbf965fd 100644
--- a/src/koga/units.lisp
+++ b/src/koga/units.lisp
@@ -197,7 +197,7 @@
:type :cxxflags)
#+darwin (append-cflags configuration "-stdlib=libc++" :type :cxxflags)
#+darwin (append-cflags configuration "-I/usr/local/include")
- #+linux (append-cflags configuration "-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-stack-protector -stdlib=libstdc++"
+ #+linux (append-cflags configuration "-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-stack-protector"
:type :cxxflags)
#+linux (append-cflags configuration "-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-stack-protector"
:type :cflags)

View File

@@ -0,0 +1,76 @@
{
lib,
stdenv,
fetchurl,
installShellFiles,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "cmucl-binary";
version = "21d";
srcs = [
(fetchurl {
url =
"http://common-lisp.net/project/cmucl/downloads/release/"
+ finalAttrs.version
+ "/cmucl-${finalAttrs.version}-x86-linux.tar.bz2";
hash = "sha256-RdctcqPTtQh1Yb3BrpQ8jtRFQn85OcwOt1l90H6xDZs=";
})
(fetchurl {
url =
"http://common-lisp.net/project/cmucl/downloads/release/"
+ finalAttrs.version
+ "/cmucl-${finalAttrs.version}-x86-linux.extra.tar.bz2";
hash = "sha256-zEmiW3m5VPpFgPxV1WJNCqgYRlHMovtaMXcgXyNukls=";
})
];
sourceRoot = ".";
outputs = [
"out"
"doc"
"man"
];
nativeBuildInputs = [
installShellFiles
];
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -pv $out $doc/share $man
mv bin lib -t $out
mv -v doc -t $doc/share
installManPage man/man1/*
runHook postInstall
'';
postFixup = ''
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
$out/bin/lisp
'';
meta = with lib; {
description = "CMU implementation of Common Lisp";
homepage = "http://www.cons.org/cmucl/";
license = licenses.publicDomain;
longDescription = ''
CMUCL is a free implementation of the Common Lisp programming language
which runs on most major Unix platforms. It mainly conforms to the
ANSI Common Lisp standard.
'';
mainProgram = "lisp";
teams = [ lib.teams.lisp ];
platforms = [
"i686-linux"
"x86_64-linux"
];
};
})

View File

@@ -0,0 +1,23 @@
From 5c158213fc3afe39ee96be84e255c12d5886ca18 Mon Sep 17 00:00:00 2001
From: Pavel Sobolev <paveloom@riseup.net>
Date: Sat, 1 Apr 2023 17:38:37 +0300
Subject: [PATCH] Add a hash to the `googletest` binary.
---
CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0a06e6f..a614025 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -434,6 +434,7 @@ include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
+ URL_HASH SHA256=5cf189eb6847b4f8fc603a3ffff3b0771c08eec7dd4bd961bfd45477dd13eb73
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
--
2.39.2

View File

@@ -0,0 +1,143 @@
{
cacert,
cmake,
fetchFromGitHub,
git,
lib,
lld,
ninja,
nix-update-script,
perl,
python3,
stdenv,
}:
let
version = "0.16.1";
src = fetchFromGitHub {
owner = "exaloop";
repo = "codon";
rev = "v${version}";
hash = "sha256-s2GqiFcekXRts8BU5CSmTrkFZ9xLqq4A5MybhB1o1Gg=";
};
depsDir = "deps";
codon-llvm = stdenv.mkDerivation {
pname = "codon-llvm";
version = "unstable-2022-09-23";
src = fetchFromGitHub {
owner = "exaloop";
repo = "llvm-project";
rev = "55b0b8fa1c9f9082b535628fc9fa6313280c0b9a";
hash = "sha256-03SPQgNdrpR6/JZ5aR/ntoh/FnZvCjT/6bTAcZaFafw=";
};
nativeBuildInputs = [
cmake
git
lld
ninja
python3
];
cmakeFlags = [
"-DLLVM_ENABLE_RTTI=ON"
"-DLLVM_ENABLE_TERMINFO=OFF"
"-DLLVM_ENABLE_ZLIB=OFF"
"-DLLVM_INCLUDE_TESTS=OFF"
"-DLLVM_TARGETS_TO_BUILD=all"
"-DLLVM_USE_LINKER=lld"
"-S ../llvm"
];
};
codon-deps = stdenv.mkDerivation {
name = "codon-deps-${version}.tar.gz";
inherit src;
nativeBuildInputs = [
cacert
cmake
git
perl
python3
];
dontBuild = true;
cmakeFlags = [
"-DCPM_DOWNLOAD_ALL=ON"
"-DCPM_SOURCE_CACHE=${depsDir}"
"-DLLVM_DIR=${codon-llvm}/lib/cmake/llvm"
];
installPhase = ''
# Prune the `.git` directories
find ${depsDir} -name .git -type d -prune -exec rm -rf {} \;;
# Build a reproducible tar, per instructions at https://reproducible-builds.org/docs/archives/
tar --owner=0 --group=0 --numeric-owner --format=gnu \
--sort=name --mtime="@$SOURCE_DATE_EPOCH" \
-czf $out \
${depsDir} \
cmake \
_deps/googletest-subbuild/googletest-populate-prefix/src/*.zip
'';
outputHash =
if stdenv.hostPlatform.isDarwin then
"sha256-KfemYV42xBAhsPbwTkzdc3GxCVHiWRbyUZORPWxx4vg="
else
"sha256-a1zGSpbMjfQBrcgW/aiIdKX8+uI3p/S9pgZjHe2HtWs=";
outputHashAlgo = "sha256";
};
in
stdenv.mkDerivation {
pname = "codon";
inherit src version;
patches = [
# Without the hash, CMake will try to replace the `.zip` file
./Add-a-hash-to-the-googletest-binary.patch
];
nativeBuildInputs = [
cmake
git
lld
ninja
perl
python3
];
postUnpack = ''
mkdir -p $sourceRoot/build
tar -xf ${codon-deps} -C $sourceRoot/build
'';
cmakeFlags = [
"-DCPM_SOURCE_CACHE=${depsDir}"
"-DLLVM_DIR=${codon-llvm}/lib/cmake/llvm"
"-DLLVM_USE_LINKER=lld"
];
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
ln -s $out/lib/codon/*.dylib $out/lib/
'';
passthru.updateScript = nix-update-script { };
meta = {
description = "High-performance, zero-overhead, extensible Python compiler using LLVM";
homepage = "https://docs.exaloop.io/codon";
maintainers = [ ];
license = lib.licenses.bsl11;
platforms = lib.platforms.all;
broken = true; # `codon-llvm` build fails on darwin and linux
};
}

View File

@@ -0,0 +1,38 @@
{
fetchFromGitHub,
gradle_7,
jdk11,
lib,
stdenv,
rsync,
runCommand,
testers,
}:
let
corretto = import ./mk-corretto.nix rec {
inherit
lib
stdenv
rsync
runCommand
testers
;
jdk = jdk11;
gradle = gradle_7;
extraConfig = [
# jdk11 is built with --disable-warnings-as-errors (see openjdk/11.nix)
# because of several compile errors. We need to include this parameter for
# Corretto, too.
"--disable-warnings-as-errors"
];
version = "11.0.26.4.1";
src = fetchFromGitHub {
owner = "corretto";
repo = "corretto-11";
rev = version;
hash = "sha256-buJlSvmyOVeMwaP9oDcHhG+Sabr1exf0nRUt4O7MaIY=";
};
};
in
corretto

View File

@@ -0,0 +1,43 @@
{
fetchFromGitHub,
fetchurl,
gradle_7,
jdk17,
lib,
stdenv,
rsync,
runCommand,
testers,
}:
let
corretto = import ./mk-corretto.nix rec {
inherit
lib
stdenv
rsync
runCommand
testers
;
jdk = jdk17;
gradle = gradle_7;
version = "17.0.14.7.1";
src = fetchFromGitHub {
owner = "corretto";
repo = "corretto-17";
rev = version;
hash = "sha256-ohQrguEJ8QvTaNjyQxKFujGhXNxCQTGkLILurzD7cy0=";
};
};
in
corretto.overrideAttrs (
final: prev: {
# Corretto17 has incorporated this patch already so it fails to apply.
# We thus skip it here.
# See https://github.com/corretto/corretto-17/pull/158
patches = lib.remove (fetchurl {
url = "https://git.alpinelinux.org/aports/plain/community/openjdk17/FixNullPtrCast.patch?id=41e78a067953e0b13d062d632bae6c4f8028d91c";
sha256 = "sha256-LzmSew51+DyqqGyyMw2fbXeBluCiCYsS1nCjt9hX6zo=";
}) (prev.patches or [ ]);
}
)

View File

@@ -0,0 +1,33 @@
{
corretto21,
fetchFromGitHub,
gradle_7,
jdk21,
lib,
stdenv,
rsync,
runCommand,
testers,
}:
let
corretto = import ./mk-corretto.nix rec {
inherit
lib
stdenv
rsync
runCommand
testers
;
jdk = jdk21;
gradle = gradle_7;
version = "21.0.6.7.1";
src = fetchFromGitHub {
owner = "corretto";
repo = "corretto-21";
rev = version;
hash = "sha256-kF7Quf8bU5scfunmwfEYLkje/jEJOx7CFnBIUWCovzI=";
};
};
in
corretto

View File

@@ -0,0 +1,126 @@
{
jdk,
version,
src,
lib,
stdenv,
gradle,
extraConfig ? [ ],
rsync,
runCommand,
testers,
}:
# Each Corretto version is based on a corresponding OpenJDK version. So
# building Corretto is more or less the same as building OpenJDK. Hence, the
# Corretto derivation overrides the corresponding OpenJDK derivation in order
# to have access to all the version-specific fixes for the various OpenJDK
# builds. However, Corretto uses `gradle` as build tool (which in turn will
# invoke `make`). The configure/build phases are adapted as needed.
# The version scheme is different between OpenJDK & Corretto.
# See https://github.com/corretto/corretto-17/blob/release-17.0.8.8.1/build.gradle#L40
# "major.minor.security.build.revision"
let
majorVersion = builtins.head (lib.strings.splitString "." version); # same as "featureVersion" for OpenJDK
pname = "corretto${majorVersion}";
in
jdk.overrideAttrs (
finalAttrs: oldAttrs: {
inherit pname version src;
name = "${pname}-${version}";
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [
jdk
gradle
rsync
];
dontConfigure = true;
postPatch =
let
extra_config = builtins.concatStringsSep " " extraConfig;
in
''
# The rpm/deb task definitions require a Gradle plugin which we don't
# have and so the build fails. We'll simply remove them here because
# they are not needed anyways.
rm -rf installers/linux/universal/{rpm,deb}
# `/usr/bin/rsync` is invoked to copy the source tree. We don't have that.
for file in $(find installers -name "build.gradle"); do
substituteInPlace $file --replace-warn "workingDir '/usr/bin'" "workingDir '.'"
done
gradleFlagsArray+=(-Pcorretto.extra_config="${extra_config}")
'';
# since we dontConfigure, we must run this manually
preBuild = "gradleConfigureHook";
# The Linux installer is placed at linux/universal/tar whereas the MacOS
# one is at mac/tar.
gradleBuildTask =
if stdenv.hostPlatform.isDarwin then
":installers:mac:tar:build"
else
":installers:linux:universal:tar:packageBuildResults";
postBuild = ''
# Prepare for the installPhase so that it looks like if a normal
# OpenJDK had been built.
dir=build/jdkImageName/images
mkdir -p $dir
file=$(find ./installers -name 'amazon-corretto-${version}*.tar.gz')
tar -xzf $file -C $dir
mv $dir/amazon-corretto-* $dir/jdk
''
+ oldAttrs.postBuild or "";
installPhase = oldAttrs.installPhase + ''
# The installPhase will place everything in $out/lib/openjdk and
# reference through symlinks. We don't rewrite the installPhase but at
# least move the folder to convey that this is not OpenJDK anymore.
mv $out/lib/openjdk $out/lib/corretto
ln -s $out/lib/corretto $out/lib/openjdk
'';
passthru =
let
pkg = finalAttrs.finalPackage;
in
oldAttrs.passthru
// {
tests = {
version = testers.testVersion { package = pkg; };
vendor = runCommand "${pname}-vendor" { nativeBuildInputs = [ pkg ]; } ''
output=$(${pkg.meta.mainProgram} -XshowSettings:properties -version 2>&1 | grep vendor)
grep -Fq "java.vendor = Amazon.com Inc." - <<< "$output" && touch $out
'';
compiler = runCommand "${pname}-compiler" { nativeBuildInputs = [ pkg ]; } ''
cat << EOF > Main.java
class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
EOF
${pkg}/bin/javac Main.java
${pkg}/bin/java Main | grep -q "Hello, World!" && touch $out
'';
};
};
# Some of the OpenJDK derivation set their `pos` by hand. We need to
# overwrite this in order to point to Corretto, not OpenJDK.
pos = __curPos;
meta = oldAttrs.meta // {
homepage = "https://aws.amazon.com/corretto";
license = lib.licenses.gpl2Only;
description = "Amazon's distribution of OpenJDK";
maintainers = with lib.maintainers; [ rollf ];
teams = [ ];
};
}
)

View File

@@ -0,0 +1,210 @@
{
stdenv,
lib,
crystal,
pcre2,
shards,
git,
pkg-config,
which,
linkFarm,
fetchgit,
fetchFromGitHub,
installShellFiles,
removeReferencesTo,
}:
{
# Some projects do not include a lock file, so you can pass one
lockFile ? null,
# Generate shards.nix with `nix-shell -p crystal2nix --run crystal2nix` in the projects root
shardsFile ? null,
# We support different builders. To make things more straight forward, make it
# user selectable instead of trying to autodetect
format ? "make",
installManPages ? true,
# Specify binaries to build in the form { foo.src = "src/foo.cr"; }
# The default `crystal build` options can be overridden with { foo.options = [ "--optionname" ]; }
crystalBinaries ? { },
enableParallelBuilding ? true,
# Copy all shards dependencies instead of symlinking and add write permissions
# to make environment more local-like
copyShardDeps ? false,
...
}@args:
assert (
builtins.elem format [
"make"
"crystal"
"shards"
]
);
let
mkDerivationArgs = removeAttrs args [
"format"
"installManPages"
"lockFile"
"shardsFile"
"crystalBinaries"
];
crystalLib = linkFarm "crystal-lib" (
lib.mapAttrsToList (name: value: {
inherit name;
path = if (builtins.hasAttr "url" value) then fetchgit value else fetchFromGitHub value;
}) (import shardsFile)
);
# We no longer use --no-debug in accordance with upstream's recommendation
defaultOptions = [
"--release"
"--progress"
"--verbose"
];
buildDirectly = shardsFile == null || crystalBinaries != { };
mkCrystalBuildArgs =
bin: attrs:
lib.concatStringsSep " " (
[
"crystal"
"build"
]
++ lib.optionals enableParallelBuilding [
"--threads"
"$NIX_BUILD_CORES"
]
++ [
"-o"
bin
(attrs.src or (throw "No source file for crystal binary ${bin} provided"))
(lib.concatStringsSep " " (attrs.options or defaultOptions))
]
);
in
stdenv.mkDerivation (
mkDerivationArgs
// {
configurePhase =
args.configurePhase or (lib.concatStringsSep "\n" (
[
"runHook preConfigure"
]
++ lib.optional (lockFile != null) "cp ${lockFile} ./shard.lock"
++ lib.optionals (shardsFile != null) [
"test -e lib || mkdir lib"
(
if copyShardDeps then
"for d in ${crystalLib}/*; do cp -r $d/ lib/; done; chmod -R +w lib/"
else
"for d in ${crystalLib}/*; do ln -s $d lib/; done"
)
"cp shard.lock lib/.shards.info"
]
++ [ "runHook postConfigure" ]
));
CRFLAGS = lib.concatStringsSep " " defaultOptions;
PREFIX = placeholder "out";
inherit enableParallelBuilding;
strictDeps = true;
buildInputs =
args.buildInputs or [ ]
++ [ crystal ]
++ lib.optional (lib.versionAtLeast crystal.version "1.8") pcre2;
nativeBuildInputs =
args.nativeBuildInputs or [ ]
++ [
crystal
git
installShellFiles
removeReferencesTo
pkg-config
which
]
++ lib.optional (format != "crystal") shards;
buildPhase =
args.buildPhase or (lib.concatStringsSep "\n" (
[
"runHook preBuild"
]
++ lib.optional (format == "make") "make \${buildTargets:-build} $makeFlags"
++ lib.optionals (format == "crystal") (lib.mapAttrsToList mkCrystalBuildArgs crystalBinaries)
++
lib.optional (format == "shards")
"shards build --local --production ${lib.concatStringsSep " " (args.options or defaultOptions)}"
++ [ "runHook postBuild" ]
));
installPhase =
args.installPhase or (lib.concatStringsSep "\n" (
[
"runHook preInstall"
]
++ lib.optional (format == "make") "make \${installTargets:-install} $installFlags"
++ lib.optionals (format == "crystal") (
map (bin: ''
install -Dm555 ${
lib.escapeShellArgs [
bin
"${placeholder "out"}/bin/${bin}"
]
}
'') (lib.attrNames crystalBinaries)
)
++ lib.optional (format == "shards") "install -Dm555 bin/* -t $out/bin"
++ [
''
for f in README* *.md LICENSE; do
test -f $f && install -Dm444 $f -t $out/share/doc/${args.pname}
done
''
]
++ (lib.optional installManPages ''
if [ -d man ]; then
installManPage man/*.?
fi
'')
++ [
"remove-references-to -t ${lib.getLib crystal} $out/bin/*"
"runHook postInstall"
]
));
doCheck = args.doCheck or true;
checkPhase =
args.checkPhase or (lib.concatStringsSep "\n" (
[
"runHook preCheck"
]
++ lib.optional (format == "make") "make \${checkTarget:-test} $checkFlags"
++ lib.optional (format != "make") "crystal \${checkTarget:-spec} $checkFlags"
++ [ "runHook postCheck" ]
));
doInstallCheck = args.doInstallCheck or true;
installCheckPhase =
args.installCheckPhase or ''
for f in $out/bin/*; do
if [ $f == $out/bin/*.dwarf ]; then
continue
fi
$f --help > /dev/null
done
'';
meta = args.meta or { } // {
platforms = args.meta.platforms or crystal.meta.platforms;
};
}
)

View File

@@ -0,0 +1,329 @@
{
stdenv,
callPackage,
fetchFromGitHub,
fetchurl,
lib,
replaceVars,
# Dependencies
boehmgc,
coreutils,
git,
gmp,
hostname,
libevent,
libiconv,
libxml2,
libyaml,
libffi,
llvmPackages_19,
llvmPackages_20,
llvmPackages_21,
makeWrapper,
openssl,
pcre2,
pkg-config,
installShellFiles,
readline,
tzdata,
which,
zlib,
}:
# We need to keep around at least the latest version released with a stable
# NixOS
let
archs = {
x86_64-linux = "linux-x86_64";
i686-linux = "linux-i686";
x86_64-darwin = "darwin-universal";
aarch64-darwin = "darwin-universal";
aarch64-linux = "linux-aarch64";
};
arch = archs.${stdenv.system} or (throw "system ${stdenv.system} not supported");
nativeCheckInputs = [
git
gmp
openssl
readline
libxml2
libyaml
libffi
];
binaryUrl =
version: rel:
if arch == archs.aarch64-linux then
"https://dev.alpinelinux.org/archive/crystal/crystal-${version}-aarch64-alpine-linux-musl.tar.gz"
else
"https://github.com/crystal-lang/crystal/releases/download/${version}/crystal-${version}-${toString rel}-${arch}.tar.gz";
genericBinary =
{
version,
sha256s,
rel ? 1,
}:
stdenv.mkDerivation rec {
pname = "crystal-binary";
inherit version;
src = fetchurl {
url = binaryUrl version rel;
sha256 = sha256s.${stdenv.system};
};
buildCommand = ''
mkdir -p $out
tar --strip-components=1 -C $out -xf ${src}
patchShebangs $out/bin/crystal
'';
meta.platforms = lib.attrNames sha256s;
};
generic =
{
version,
sha256,
binary,
llvmPackages,
doCheck ? true,
extraBuildInputs ? [ ],
buildFlags ? [
"all"
"docs"
"release=1"
],
}:
stdenv.mkDerivation (finalAttrs: {
pname = "crystal";
inherit buildFlags doCheck version;
src = fetchFromGitHub {
owner = "crystal-lang";
repo = "crystal";
rev = version;
inherit sha256;
};
patches = [
(replaceVars ./tzdata.patch {
inherit tzdata;
})
];
outputs = [
"out"
"lib"
"bin"
];
postPatch = ''
export TMP=$(mktemp -d)
export HOME=$TMP
export TMPDIR=$TMP
mkdir -p $HOME/test
# Add dependency of crystal to docs to avoid issue on flag changes between releases
# https://github.com/crystal-lang/crystal/pull/8792#issuecomment-614004782
substituteInPlace Makefile \
--replace 'docs: ## Generate standard library documentation' 'docs: crystal ## Generate standard library documentation'
mkdir -p $TMP/crystal
substituteInPlace spec/std/file_spec.cr \
--replace '/bin/ls' '${coreutils}/bin/ls' \
--replace '/usr/share' "$TMP/crystal" \
--replace '/usr' "$TMP" \
--replace '/tmp' "$TMP"
substituteInPlace spec/std/process_spec.cr \
--replace '/bin/cat' '${coreutils}/bin/cat' \
--replace '/bin/ls' '${coreutils}/bin/ls' \
--replace '/usr/bin/env' '${coreutils}/bin/env' \
--replace '"env"' '"${coreutils}/bin/env"' \
--replace '/usr' "$TMP" \
--replace '/tmp' "$TMP"
substituteInPlace spec/std/system_spec.cr \
--replace '`hostname`' '`${hostname}/bin/hostname`'
# See https://github.com/crystal-lang/crystal/issues/8629
substituteInPlace spec/std/socket/udp_socket_spec.cr \
--replace 'it "joins and transmits to multicast groups"' 'pending "joins and transmits to multicast groups"'
''
+ lib.optionalString (stdenv.cc.isClang && (stdenv.cc.libcxx != null)) ''
# Darwin links against libc++ not libstdc++. Newer versions of clang (12+) require
# libc++abi to be linked explicitly (see https://github.com/NixOS/nixpkgs/issues/166205).
substituteInPlace src/llvm/lib_llvm.cr \
--replace '@[Link("stdc++")]' '@[Link("c++")]'
'';
# Defaults are 4
preBuild = ''
export CRYSTAL_WORKERS=$NIX_BUILD_CORES
export threads=$NIX_BUILD_CORES
export CRYSTAL_CACHE_DIR=$TMP
export MACOSX_DEPLOYMENT_TARGET=10.11
export SOURCE_DATE_EPOCH="$(<src/SOURCE_DATE_EPOCH)"
'';
strictDeps = true;
nativeBuildInputs = [
binary
makeWrapper
which
pkg-config
llvmPackages.llvm
installShellFiles
];
buildInputs = [
boehmgc
pcre2
libevent
libyaml
zlib
libxml2
openssl
]
++ extraBuildInputs
++ lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
makeFlags = [
"CRYSTAL_CONFIG_VERSION=${version}"
"progress=1"
];
LLVM_CONFIG = "${llvmPackages.llvm.dev}/bin/llvm-config";
FLAGS = [
"--single-module" # needed for deterministic builds
];
# This makes sure we don't keep depending on the previous version of
# crystal used to build this one.
CRYSTAL_LIBRARY_PATH = "${placeholder "lib"}/crystal";
# We *have* to add `which` to the PATH or crystal is unable to build
# stuff later if which is not available.
installPhase = ''
runHook preInstall
install -Dm755 .build/crystal $bin/bin/crystal
wrapProgram $bin/bin/crystal \
--suffix PATH : ${
lib.makeBinPath [
pkg-config
llvmPackages.clang
which
]
} \
--suffix CRYSTAL_PATH : lib:$lib/crystal \
--suffix PKG_CONFIG_PATH : ${
lib.makeSearchPathOutput "dev" "lib/pkgconfig" finalAttrs.buildInputs
} \
--suffix CRYSTAL_LIBRARY_PATH : ${lib.makeLibraryPath finalAttrs.buildInputs}
install -dm755 $lib/crystal
cp -r src/* $lib/crystal/
install -dm755 $out/share/doc/crystal/api
cp -r docs/* $out/share/doc/crystal/api/
cp -r samples $out/share/doc/crystal/
installShellCompletion --cmd ${finalAttrs.meta.mainProgram} etc/completion.*
installManPage man/crystal.1
install -Dm644 -t $out/share/licenses/crystal LICENSE README.md
mkdir -p $out
ln -s $bin/bin $out/bin
ln -s $bin/share/bash-completion $out/share/bash-completion
ln -s $bin/share/zsh $out/share/zsh
ln -s $bin/share/fish $out/share/fish
ln -s $lib $out/lib
runHook postInstall
'';
enableParallelBuilding = true;
dontStrip = true;
checkTarget = "compiler_spec";
preCheck = ''
export LIBRARY_PATH=${lib.makeLibraryPath nativeCheckInputs}:$LIBRARY_PATH
export PATH=${lib.makeBinPath nativeCheckInputs}:$PATH
'';
passthru.buildBinary = binary;
passthru.buildCrystalPackage = callPackage ./build-package.nix {
crystal = finalAttrs.finalPackage;
};
passthru.llvmPackages = llvmPackages;
meta = with lib; {
inherit (binary.meta) platforms;
description = "Compiled language with Ruby like syntax and type inference";
mainProgram = "crystal";
homepage = "https://crystal-lang.org/";
license = licenses.asl20;
maintainers = with maintainers; [
david50407
manveru
peterhoeg
donovanglover
];
};
});
in
rec {
binaryCrystal_1_10 = genericBinary {
version = "1.10.1";
sha256s = {
x86_64-linux = "sha256-F0LjdV02U9G6B8ApHxClF/o5KvhxMNukSX7Z2CwSNIs=";
aarch64-darwin = "sha256-5kkObQl0VIO6zqQ8TYl0JzYyUmwfmPE9targpfwseSQ=";
x86_64-darwin = "sha256-5kkObQl0VIO6zqQ8TYl0JzYyUmwfmPE9targpfwseSQ=";
aarch64-linux = "sha256-AzFz+nrU/HJmCL1hbCKXf5ej/uypqV1GJPVLQ4J3778=";
};
};
crystal_1_14 = generic {
version = "1.14.1";
sha256 = "sha256-cQWK92BfksOW8GmoXn4BmPGJ7CLyLAeKccOffQMh5UU=";
binary = binaryCrystal_1_10;
llvmPackages = llvmPackages_19;
doCheck = false; # Some compiler spec problems on x86-64_linux with the .0 release
};
crystal_1_15 = generic {
version = "1.15.1";
sha256 = "sha256-L/Q8yZdDq/wn4kJ+zpLfi4pxznAtgjxTCbLnEiCC2K0=";
binary = binaryCrystal_1_10;
llvmPackages = llvmPackages_19;
doCheck = false;
};
crystal_1_16 = generic {
version = "1.16.3";
sha256 = "sha256-U9H1tHUMyDNicZnXzEccDki5bGXdV0B2Wu2PyCksPVI=";
binary = binaryCrystal_1_10;
llvmPackages = llvmPackages_20;
doCheck = false;
};
crystal_1_17 = generic {
version = "1.17.1";
sha256 = "sha256-+wHhozPhpIsfQy1Lw+V48zvuWCfXzT4IC9KA1AU/DLw=";
binary = binaryCrystal_1_10;
llvmPackages = llvmPackages_21;
doCheck = false;
};
crystal = crystal_1_16;
}

View File

@@ -0,0 +1,12 @@
diff --git a/src/crystal/system/unix/time.cr b/src/crystal/system/unix/time.cr
index 333b66075..1c29a0e55 100644
--- a/src/crystal/system/unix/time.cr
+++ b/src/crystal/system/unix/time.cr
@@ -43,6 +43,7 @@ module Crystal::System::Time
# Many systems use /usr/share/zoneinfo, Solaris 2 has
# /usr/share/lib/zoneinfo, IRIX 6 has /usr/lib/locale/TZ.
ZONE_SOURCES = {
+ "@tzdata@/share/zoneinfo/",
"/usr/share/zoneinfo/",
"/usr/share/lib/zoneinfo/",
"/usr/lib/locale/TZ/",

View File

@@ -0,0 +1,100 @@
{
lib,
stdenv,
fetchurl,
unzip,
bintools,
versionCheckHook,
runCommand,
cctools,
darwin,
sources ? import ./sources.nix { inherit fetchurl; },
version ? sources.versionUsed,
}:
assert sources != null && (builtins.isAttrs sources);
stdenv.mkDerivation (finalAttrs: {
pname = "dart";
inherit version;
nativeBuildInputs = [ unzip ];
src =
sources."${version}-${stdenv.hostPlatform.system}"
or (throw "unsupported version/system: ${version}/${stdenv.hostPlatform.system}");
installPhase = ''
runHook preInstall
cp -R . $out
''
+ lib.optionalString (stdenv.hostPlatform.isLinux) ''
find $out/bin -executable -type f -exec patchelf --set-interpreter ${bintools.dynamicLinker} {} \;
''
+ ''
runHook postInstall
'';
dontStrip = true;
doInstallCheck = true;
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "--version";
passthru = {
updateScript = ./update.sh;
tests = {
testCreate = runCommand "dart-test-create" { nativeBuildInputs = [ finalAttrs.finalPackage ]; } ''
PROJECTNAME="dart_test_project"
dart create --no-pub $PROJECTNAME
[[ -d $PROJECTNAME ]]
[[ -f $PROJECTNAME/bin/$PROJECTNAME.dart ]]
touch $out
'';
testCompile =
runCommand "dart-test-compile"
{
nativeBuildInputs = [
finalAttrs.finalPackage
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
cctools
darwin.sigtool
];
}
''
HELLO_MESSAGE="Hello, world!"
echo "void main() => print('$HELLO_MESSAGE');" > hello.dart
dart compile exe hello.dart
PROGRAM_OUT=$(./hello.exe)
[[ "$PROGRAM_OUT" == "$HELLO_MESSAGE" ]]
touch $out
'';
};
};
meta = {
homepage = "https://dart.dev";
maintainers = with lib.maintainers; [ grburst ];
description = "Scalable programming language, with robust libraries and runtimes, for building web, server, and mobile apps";
longDescription = ''
Dart is a class-based, single inheritance, object-oriented language
with C-style syntax. It offers compilation to JavaScript, interfaces,
mixins, abstract classes, reified generics, and optional typing.
'';
mainProgram = "dart";
platforms = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = lib.licenses.bsd3;
};
})

View File

@@ -0,0 +1,25 @@
{ callPackage }:
{
file_picker = callPackage ./file_picker { };
flutter_discord_rpc = callPackage ./flutter_discord_rpc { };
flutter_secure_storage_linux = callPackage ./flutter-secure-storage-linux { };
flutter_vodozemac = callPackage ./flutter_vodozemac { };
flutter_volume_controller = callPackage ./flutter_volume_controller { };
handy_window = callPackage ./handy-window { };
matrix = callPackage ./matrix { };
media_kit_libs_linux = callPackage ./media_kit_libs_linux { };
olm = callPackage ./olm { };
objectbox_flutter_libs = callPackage ./objectbox_flutter_libs { };
pdfrx = callPackage ./pdfrx { };
printing = callPackage ./printing { };
rhttp = callPackage ./rhttp { };
sentry_flutter = callPackage ./sentry_flutter { };
sqlcipher_flutter_libs = callPackage ./sqlcipher_flutter_libs { };
sqlite3 = callPackage ./sqlite3 { };
sqlite3_flutter_libs = callPackage ./sqlite3_flutter_libs { };
system_tray = callPackage ./system-tray { };
super_native_extensions = callPackage ./super_native_extensions { };
volume_controller = callPackage ./volume_controller { };
xdg_directories = callPackage ./xdg_directories { };
}

View File

@@ -0,0 +1,26 @@
{
lib,
stdenv,
zenity,
}:
{ version, src, ... }:
stdenv.mkDerivation {
pname = "file_picker";
inherit version src;
inherit (src) passthru;
postPatch = lib.optionalString (lib.versionOlder version "10.3.0") ''
substituteInPlace lib/src/linux/file_picker_linux.dart \
--replace-fail "isExecutableOnPath('zenity')" "'${lib.getExe zenity}'"
'';
installPhase = ''
runHook preInstall
cp -r . $out
runHook postInstall
'';
}

View File

@@ -0,0 +1,27 @@
{
stdenv,
libsecret,
jsoncpp,
}:
{ version, src, ... }:
stdenv.mkDerivation {
pname = "flutter-secure-storage-linux";
inherit version src;
inherit (src) passthru;
propagatedBuildInputs = [
libsecret
jsoncpp
];
installPhase = ''
runHook preInstall
mkdir -p "$out"
ln -s '${src}'/* "$out"
runHook postInstall
'';
}

View File

@@ -0,0 +1,90 @@
--- old/cargokit/cmake/cargokit.cmake 2024-11-08 13:36:13.345889693 +0800
+++ new/cargokit/cmake/cargokit.cmake 2024-11-08 13:45:26.019632176 +0800
@@ -17,83 +17,22 @@
function(apply_cargokit target manifest_dir lib_name any_symbol_name)
set(CARGOKIT_LIB_NAME "${lib_name}")
- set(CARGOKIT_LIB_FULL_NAME "${CMAKE_SHARED_MODULE_PREFIX}${CARGOKIT_LIB_NAME}${CMAKE_SHARED_MODULE_SUFFIX}")
- if (CMAKE_CONFIGURATION_TYPES)
- set(CARGOKIT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
- set(OUTPUT_LIB "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${CARGOKIT_LIB_FULL_NAME}")
- else()
- set(CARGOKIT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
- set(OUTPUT_LIB "${CMAKE_CURRENT_BINARY_DIR}/${CARGOKIT_LIB_FULL_NAME}")
- endif()
- set(CARGOKIT_TEMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/cargokit_build")
-
- if (FLUTTER_TARGET_PLATFORM)
- set(CARGOKIT_TARGET_PLATFORM "${FLUTTER_TARGET_PLATFORM}")
- else()
- set(CARGOKIT_TARGET_PLATFORM "windows-x64")
- endif()
-
- set(CARGOKIT_ENV
- "CARGOKIT_CMAKE=${CMAKE_COMMAND}"
- "CARGOKIT_CONFIGURATION=$<CONFIG>"
- "CARGOKIT_MANIFEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${manifest_dir}"
- "CARGOKIT_TARGET_TEMP_DIR=${CARGOKIT_TEMP_DIR}"
- "CARGOKIT_OUTPUT_DIR=${CARGOKIT_OUTPUT_DIR}"
- "CARGOKIT_TARGET_PLATFORM=${CARGOKIT_TARGET_PLATFORM}"
- "CARGOKIT_TOOL_TEMP_DIR=${CARGOKIT_TEMP_DIR}/tool"
- "CARGOKIT_ROOT_PROJECT_DIR=${CMAKE_SOURCE_DIR}"
- )
-
- if (WIN32)
- set(SCRIPT_EXTENSION ".cmd")
- set(IMPORT_LIB_EXTENSION ".lib")
- else()
- set(SCRIPT_EXTENSION ".sh")
- set(IMPORT_LIB_EXTENSION "")
- execute_process(COMMAND chmod +x "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}")
- endif()
-
- # Using generators in custom command is only supported in CMake 3.20+
- if (CMAKE_CONFIGURATION_TYPES AND ${CMAKE_VERSION} VERSION_LESS "3.20.0")
- foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES)
- add_custom_command(
- OUTPUT
- "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG}/${CARGOKIT_LIB_FULL_NAME}"
- "${CMAKE_CURRENT_BINARY_DIR}/_phony_"
- COMMAND ${CMAKE_COMMAND} -E env ${CARGOKIT_ENV}
- "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}" build-cmake
- VERBATIM
- )
- endforeach()
- else()
- add_custom_command(
- OUTPUT
- ${OUTPUT_LIB}
- "${CMAKE_CURRENT_BINARY_DIR}/_phony_"
- COMMAND ${CMAKE_COMMAND} -E env ${CARGOKIT_ENV}
- "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}" build-cmake
- VERBATIM
- )
- endif()
-
-
- set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/_phony_" PROPERTIES SYMBOLIC TRUE)
if (TARGET ${target})
# If we have actual cmake target provided create target and make existing
# target depend on it
- add_custom_target("${target}_cargokit" DEPENDS ${OUTPUT_LIB})
+ add_custom_target("${target}_cargokit" DEPENDS @output_lib@)
add_dependencies("${target}" "${target}_cargokit")
- target_link_libraries("${target}" PRIVATE "${OUTPUT_LIB}${IMPORT_LIB_EXTENSION}")
+ target_link_libraries("${target}" PRIVATE @output_lib@)
if(WIN32)
target_link_options(${target} PRIVATE "/INCLUDE:${any_symbol_name}")
endif()
else()
# Otherwise (FFI) just use ALL to force building always
- add_custom_target("${target}_cargokit" ALL DEPENDS ${OUTPUT_LIB})
+ add_custom_target("${target}_cargokit" ALL DEPENDS @output_lib@)
endif()
# Allow adding the output library to plugin bundled libraries
- set("${target}_cargokit_lib" ${OUTPUT_LIB} PARENT_SCOPE)
+ set("${target}_cargokit_lib" @output_lib@ PARENT_SCOPE)
endfunction()

View File

@@ -0,0 +1,48 @@
{
lib,
rustPlatform,
stdenv,
replaceVars,
}:
{ version, src, ... }:
let
rustDep = rustPlatform.buildRustPackage {
pname = "flutter_discord_rpc-rs";
inherit version src;
buildAndTestSubdir = "rust";
cargoHash =
{
_1_0_0 = "sha256-C9WDE9+6V59yNCNVeMUY5lRpMJ+8XWpHpxzdTmz+/Yw=";
}
.${"_" + (lib.replaceStrings [ "." ] [ "_" ] version)} or (throw ''
Unsupported version of pub 'flutter_discord_rpc': '${version}'
Please add cargoHash here. If the cargoHash
is the same with existing versions, add an alias here.
'');
passthru.libraryPath = "lib/libflutter_discord_rpc.so";
};
in
stdenv.mkDerivation {
pname = "flutter_discord_rpc";
inherit version src;
inherit (src) passthru;
patches = [
(replaceVars ./cargokit.patch {
output_lib = "${rustDep}/${rustDep.passthru.libraryPath}";
})
];
installPhase = ''
runHook preInstall
cp -r . $out
runHook postInstall
'';
}

View File

@@ -0,0 +1,72 @@
{
lib,
rustPlatform,
writeText,
stdenv,
}:
{ version, src, ... }:
let
rustDep = rustPlatform.buildRustPackage {
pname = "flutter_vodozemac-rs";
inherit version src;
sourceRoot = "${src.name}/rust";
cargoHash =
{
_0_2_2 = "sha256-Iw0AkHVjR1YmPe+C0YYBTDu5FsRk/ZpaRyBilcvqm6M=";
}
.${"_" + (lib.replaceStrings [ "." ] [ "_" ] version)} or (throw ''
Unsupported version of pub 'flutter_vodozemac': '${version}'
Please add cargoHash here. If the cargoHash
is the same with existing versions, add an alias here.
'');
passthru.libraryPath = "lib/libvodozemac_bindings_dart.so";
};
fakeCargokitCmake = writeText "FakeCargokit.cmake" ''
function(apply_cargokit target manifest_dir lib_name any_symbol_name)
set("''${target}_cargokit_lib" ${rustDep}/${rustDep.passthru.libraryPath} PARENT_SCOPE)
endfunction()
'';
getLibraryPath = ''
String _getLibraryPath() {
if (kIsWeb) {
return './';
}
try {
return Platform.resolvedExecutable + '/../lib/libvodozemac_bindings_dart.so';
} catch (_) {
return './';
}
}
'';
in
stdenv.mkDerivation {
pname = "flutter_vodozemac";
inherit version src;
passthru = src.passthru // {
# vodozemac-wasm in fluffychat will make use of it
inherit (rustDep) cargoDeps;
};
installPhase = ''
runHook preInstall
cp -r "$src" "$out"
pushd $out
chmod +rwx cargokit/cmake/cargokit.cmake
cp ${fakeCargokitCmake} cargokit/cmake/cargokit.cmake
chmod +rw lib/flutter_vodozemac.dart
substituteInPlace lib/flutter_vodozemac.dart \
--replace-warn "libraryPath: './'" "libraryPath: _getLibraryPath()"
echo "${getLibraryPath}" >> lib/flutter_vodozemac.dart
popd
runHook postInstall
'';
}

View File

@@ -0,0 +1,26 @@
{
stdenv,
}:
{ version, src, ... }:
stdenv.mkDerivation {
pname = "flutter_volume_controller";
inherit version src;
inherit (src) passthru;
postPatch = ''
substituteInPlace linux/CMakeLists.txt \
--replace-fail '# Include ALSA' 'find_package(PkgConfig REQUIRED)' \
--replace-fail 'find_package(ALSA REQUIRED)' 'pkg_check_modules(ALSA REQUIRED alsa)'
'';
installPhase = ''
runHook preInstall
mkdir $out
cp -r ./* $out/
runHook postInstall
'';
}

View File

@@ -0,0 +1,32 @@
{
stdenv,
lib,
writeScript,
cairo,
fribidi,
}:
{ version, src, ... }:
stdenv.mkDerivation rec {
pname = "handy-window";
inherit version src;
inherit (src) passthru;
setupHook = writeScript "${pname}-setup-hook" ''
handyWindowConfigureHook() {
export CFLAGS="$CFLAGS -isystem ${lib.getDev fribidi}/include/fribidi -isystem ${lib.getDev cairo}/include"
}
postConfigureHooks+=(handyWindowConfigureHook)
'';
installPhase = ''
runHook preInstall
mkdir -p "$out"
ln -s '${src}'/* "$out"
runHook postInstall
'';
}

View File

@@ -0,0 +1,31 @@
{
stdenv,
lib,
writeScript,
openssl,
}:
{ version, src, ... }:
stdenv.mkDerivation rec {
pname = "matrix";
inherit version src;
inherit (src) passthru;
setupHook = writeScript "${pname}-setup-hook" ''
matrixFixupHook() {
runtimeDependencies+=('${lib.getLib openssl}')
}
preFixupHooks+=(matrixFixupHook)
'';
installPhase = ''
runHook preInstall
mkdir -p "$out"
ln -s '${src}'/* "$out"
runHook postInstall
'';
}

View File

@@ -0,0 +1,38 @@
{
lib,
stdenv,
}:
# Implementation notes
# The patch exploits the fact that the download part is enclosed with "# ---"
# To use this module you will need to pass the CMake variable MIMALLOC_LIB
# example: -DMIMALLOC_LIB=${pkgs.mimalloc}/lib/mimalloc.o
# Direct link for the original CMakeLists.txt: https://raw.githubusercontent.com/media-kit/media-kit/main/libs/linux/media_kit_libs_linux/linux/CMakeLists.txt
{ version, src, ... }:
stdenv.mkDerivation {
pname = "media_kit_libs_linux";
inherit version src;
inherit (src) passthru;
dontBuild = true;
postPatch =
lib.optionalString (lib.versionAtLeast version "1.2.1") ''
sed -i '/if(MIMALLOC_USE_STATIC_LIBS)/,/unset(MIMALLOC_USE_STATIC_LIBS CACHE)/d' linux/CMakeLists.txt
''
+ lib.optionalString (lib.versionOlder version "1.2.1") ''
awk -i inplace 'BEGIN {opened = 0}; /# --*[^$]*/ { print (opened ? "]===]" : "#[===["); opened = !opened }; {print $0}' linux/CMakeLists.txt
'';
installPhase = ''
runHook preInstall
cp -r . $out
runHook postInstall
'';
}

View File

@@ -0,0 +1,46 @@
--- old/linux/CMakeLists.txt
+++ new/linux/CMakeLists.txt
@@ -41,35 +41,6 @@
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
-# ----------------------------------------------------------------------
-# Download and add objectbox-c prebuilt library.
-
-set(OBJECTBOX_VERSION 4.0.2)
-
-set(OBJECTBOX_ARCH ${CMAKE_SYSTEM_PROCESSOR})
-if (${OBJECTBOX_ARCH} MATCHES "x86_64")
- set(OBJECTBOX_ARCH x64)
-elseif (${OBJECTBOX_ARCH} MATCHES "^arm64" OR ${OBJECTBOX_ARCH} MATCHES "^armv8")
- set(OBJECTBOX_ARCH aarch64)
-elseif (${OBJECTBOX_ARCH} MATCHES "^armv7")
- set(OBJECTBOX_ARCH armv7hf)
-elseif (${OBJECTBOX_ARCH} MATCHES "^arm")
- set(OBJECTBOX_ARCH armv6hf)
-endif ()
-
-include(FetchContent)
-FetchContent_Declare(
- objectbox-download
- URL https://github.com/objectbox/objectbox-c/releases/download/v${OBJECTBOX_VERSION}/objectbox-linux-${OBJECTBOX_ARCH}.tar.gz
-)
-
-FetchContent_GetProperties(objectbox-download)
-if(NOT objectbox-download_POPULATED)
- FetchContent_Populate(objectbox-download)
-endif()
-
-# ----------------------------------------------------------------------
-
# List of absolute paths to libraries that should be bundled with the plugin.
# This list could contain prebuilt libraries, or libraries created by an
# external build triggered from this build file.
@@ -77,6 +48,6 @@
# Note: do not link the ObjectBox C library; the Dart library looks for it in a lib subfolder
# where flutter build puts it when added below.
set(objectbox_flutter_libs_bundled_libraries
- "${objectbox-download_SOURCE_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}objectbox${CMAKE_SHARED_LIBRARY_SUFFIX}"
+ "@OBJECTBOX_SHARED_LIBRARY@"
PARENT_SCOPE
)

View File

@@ -0,0 +1,50 @@
{
lib,
stdenv,
fetchzip,
replaceVars,
}:
{ version, src, ... }:
let
selectSystem =
attrs:
attrs.${stdenv.hostPlatform.system}
or (throw "objectbox_flutter_libs: ${stdenv.hostPlatform.system} is not supported");
arch = selectSystem {
x86_64-linux = "x64";
aarch64-linux = "aarch64";
};
objectbox-sync = fetchzip {
url = "https://github.com/objectbox/objectbox-c/releases/download/v4.0.2/objectbox-sync-linux-${arch}.tar.gz";
hash = selectSystem {
x86_64-linux = "sha256-VXTuCYg0ZItK+lAs7xkNlxO0rUPnbRZOP5RAXbcRyjM=";
aarch64-linux = "sha256-kNlrBRR/qDEhdU34f4eDQLgYkYAIfFC8/of4rgL+m6k=";
};
stripRoot = false;
};
in
stdenv.mkDerivation {
pname = "objectbox_flutter_libs";
inherit version src;
inherit (src) passthru;
patches = [
(replaceVars ./CMakeLists.patch {
OBJECTBOX_SHARED_LIBRARY = "${objectbox-sync}/lib/libobjectbox.so";
})
];
installPhase = ''
runHook preInstall
cp -r . $out
runHook postInstall
'';
meta.sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
}

View File

@@ -0,0 +1,31 @@
{
stdenv,
lib,
writeScript,
olm,
}:
{ version, src, ... }:
stdenv.mkDerivation rec {
pname = "olm";
inherit version src;
inherit (src) passthru;
setupHook = writeScript "${pname}-setup-hook" ''
olmFixupHook() {
runtimeDependencies+=('${lib.getLib olm}')
}
preFixupHooks+=(olmFixupHook)
'';
installPhase = ''
runHook preInstall
mkdir -p "$out"
ln -s '${src}'/* "$out"
runHook postInstall
'';
}

View File

@@ -0,0 +1,26 @@
{
stdenv,
pdfium-binaries,
}:
{ version, src, ... }:
stdenv.mkDerivation rec {
pname = "pdfrx";
inherit version src;
inherit (src) passthru;
postPatch = ''
substituteInPlace linux/CMakeLists.txt \
--replace-fail "\''${PDFIUM_DIR}/\''${PDFIUM_RELEASE}" "${pdfium-binaries}"
'';
installPhase = ''
runHook preInstall
mkdir $out
cp -a ./* $out/
runHook postInstall
'';
}

View File

@@ -0,0 +1,37 @@
{
stdenv,
pdfium-binaries,
replaceVars,
}:
{ version, src, ... }:
stdenv.mkDerivation rec {
pname = "printing";
inherit version src;
inherit (src) passthru;
prePatch = ''
if [ -d printing ]; then pushd printing; fi
'';
patches = [
(replaceVars ./printing.patch {
inherit pdfium-binaries;
})
];
postPatch = ''
popd || true
'';
dontBuild = true;
installPhase = ''
runHook preInstall
cp -r . $out
runHook postInstall
'';
}

View File

@@ -0,0 +1,45 @@
--- old/linux/CMakeLists.txt 2024-07-16 18:45:19.000000000 +0800
+++ new/linux/CMakeLists.txt 2024-10-01 01:49:05.544910894 +0800
@@ -16,6 +16,7 @@
set(PROJECT_NAME "printing")
project(${PROJECT_NAME} LANGUAGES CXX)
+set(PDFIUM_DIR @pdfium-binaries@)
set(PDFIUM_VERSION "5200" CACHE STRING "Version of pdfium used")
string(REPLACE "linux-" "" TARGET_ARCH ${FLUTTER_TARGET_PLATFORM})
set(PDFIUM_ARCH ${TARGET_ARCH} CACHE STRING "Architecture of pdfium used")
@@ -32,18 +33,11 @@
)
endif()
-# Download pdfium
-include(../windows/DownloadProject.cmake)
-download_project(PROJ
- pdfium
- URL
- ${PDFIUM_URL})
-
# This value is used when generating builds using this plugin, so it must not be
# changed
set(PLUGIN_NAME "printing_plugin")
-include(${pdfium_SOURCE_DIR}/PDFiumConfig.cmake)
+include(${PDFIUM_DIR}/PDFiumConfig.cmake)
# System-level dependencies.
find_package(PkgConfig REQUIRED)
@@ -67,7 +61,7 @@
target_link_libraries(${PLUGIN_NAME}
PRIVATE PkgConfig::GTK PkgConfig::GTKUnixPrint)
target_link_libraries(${PLUGIN_NAME} PRIVATE pdfium)
-get_filename_component(PDFium_lib_path "${PDFium_LIBRARY}" DIRECTORY)
+set(PDFium_lib_path "${PDFIUM_DIR}/lib")
set_target_properties(${PLUGIN_NAME}
PROPERTIES SKIP_BUILD_RPATH
FALSE
@@ -77,4 +71,4 @@
"$ORIGIN:${PDFium_lib_path}")
# List of absolute paths to libraries that should be bundled with the plugin
-set(printing_bundled_libraries "${PDFium_LIBRARY}" PARENT_SCOPE)
+set(printing_bundled_libraries "${PDFIUM_DIR}/lib/libpdfium.so" PARENT_SCOPE)

View File

@@ -0,0 +1,90 @@
--- old/cargokit/cmake/cargokit.cmake 2024-11-08 13:36:13.345889693 +0800
+++ new/cargokit/cmake/cargokit.cmake 2024-11-08 13:45:26.019632176 +0800
@@ -17,83 +17,22 @@
function(apply_cargokit target manifest_dir lib_name any_symbol_name)
set(CARGOKIT_LIB_NAME "${lib_name}")
- set(CARGOKIT_LIB_FULL_NAME "${CMAKE_SHARED_MODULE_PREFIX}${CARGOKIT_LIB_NAME}${CMAKE_SHARED_MODULE_SUFFIX}")
- if (CMAKE_CONFIGURATION_TYPES)
- set(CARGOKIT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
- set(OUTPUT_LIB "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${CARGOKIT_LIB_FULL_NAME}")
- else()
- set(CARGOKIT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
- set(OUTPUT_LIB "${CMAKE_CURRENT_BINARY_DIR}/${CARGOKIT_LIB_FULL_NAME}")
- endif()
- set(CARGOKIT_TEMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/cargokit_build")
-
- if (FLUTTER_TARGET_PLATFORM)
- set(CARGOKIT_TARGET_PLATFORM "${FLUTTER_TARGET_PLATFORM}")
- else()
- set(CARGOKIT_TARGET_PLATFORM "windows-x64")
- endif()
-
- set(CARGOKIT_ENV
- "CARGOKIT_CMAKE=${CMAKE_COMMAND}"
- "CARGOKIT_CONFIGURATION=$<CONFIG>"
- "CARGOKIT_MANIFEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${manifest_dir}"
- "CARGOKIT_TARGET_TEMP_DIR=${CARGOKIT_TEMP_DIR}"
- "CARGOKIT_OUTPUT_DIR=${CARGOKIT_OUTPUT_DIR}"
- "CARGOKIT_TARGET_PLATFORM=${CARGOKIT_TARGET_PLATFORM}"
- "CARGOKIT_TOOL_TEMP_DIR=${CARGOKIT_TEMP_DIR}/tool"
- "CARGOKIT_ROOT_PROJECT_DIR=${CMAKE_SOURCE_DIR}"
- )
-
- if (WIN32)
- set(SCRIPT_EXTENSION ".cmd")
- set(IMPORT_LIB_EXTENSION ".lib")
- else()
- set(SCRIPT_EXTENSION ".sh")
- set(IMPORT_LIB_EXTENSION "")
- execute_process(COMMAND chmod +x "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}")
- endif()
-
- # Using generators in custom command is only supported in CMake 3.20+
- if (CMAKE_CONFIGURATION_TYPES AND ${CMAKE_VERSION} VERSION_LESS "3.20.0")
- foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES)
- add_custom_command(
- OUTPUT
- "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG}/${CARGOKIT_LIB_FULL_NAME}"
- "${CMAKE_CURRENT_BINARY_DIR}/_phony_"
- COMMAND ${CMAKE_COMMAND} -E env ${CARGOKIT_ENV}
- "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}" build-cmake
- VERBATIM
- )
- endforeach()
- else()
- add_custom_command(
- OUTPUT
- ${OUTPUT_LIB}
- "${CMAKE_CURRENT_BINARY_DIR}/_phony_"
- COMMAND ${CMAKE_COMMAND} -E env ${CARGOKIT_ENV}
- "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}" build-cmake
- VERBATIM
- )
- endif()
-
-
- set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/_phony_" PROPERTIES SYMBOLIC TRUE)
if (TARGET ${target})
# If we have actual cmake target provided create target and make existing
# target depend on it
- add_custom_target("${target}_cargokit" DEPENDS ${OUTPUT_LIB})
+ add_custom_target("${target}_cargokit" DEPENDS @output_lib@)
add_dependencies("${target}" "${target}_cargokit")
- target_link_libraries("${target}" PRIVATE "${OUTPUT_LIB}${IMPORT_LIB_EXTENSION}")
+ target_link_libraries("${target}" PRIVATE @output_lib@)
if(WIN32)
target_link_options(${target} PRIVATE "/INCLUDE:${any_symbol_name}")
endif()
else()
# Otherwise (FFI) just use ALL to force building always
- add_custom_target("${target}_cargokit" ALL DEPENDS ${OUTPUT_LIB})
+ add_custom_target("${target}_cargokit" ALL DEPENDS @output_lib@)
endif()
# Allow adding the output library to plugin bundled libraries
- set("${target}_cargokit_lib" ${OUTPUT_LIB} PARENT_SCOPE)
+ set("${target}_cargokit_lib" @output_lib@ PARENT_SCOPE)
endfunction()

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