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,173 @@
{
stdenv,
lib,
idris2,
makeBinaryWrapper,
}:
# Usage: let
# pkg = idris2Packages.buildIdris {
# src = ...;
# ipkgName = "my-pkg";
# idrisLibraries = [ ];
# };
# in {
# lib1 = pkg.library { withSource = true; };
#
# # implicitly without source:
# lib2 = pkg.library';
#
# bin = pkg.executable;
# }
#
{
src,
ipkgName, # ipkg filename without the extension
version ? "unversioned",
idrisLibraries, # Other libraries built with buildIdris
...
}@attrs:
let
# loop over idrisLibraries and normalize them by turning any that are
# direct outputs of the buildIdris function into the `.library {}`
# property.
idrisLibraryLibs = map (
idrisLib:
if lib.isDerivation idrisLib then
idrisLib
else if builtins.isFunction idrisLib then
idrisLib { }
else if (builtins.isAttrs idrisLib && idrisLib ? "library") then
idrisLib.library { }
else
throw "Found an Idris2 library dependency that was not the result of the buildIdris function"
) idrisLibraries;
propagate =
libs: lib.unique (lib.concatMap (nextLib: [ nextLib ] ++ nextLib.propagatedIdrisLibraries) libs);
ipkgFileName = ipkgName + ".ipkg";
idrName = "idris2-${idris2.version}";
libSuffix = "lib/${idrName}";
libDirs = libs: (lib.makeSearchPath libSuffix libs) + ":${idris2}/${idrName}";
supportDir = "${idris2}/${idrName}/lib";
drvAttrs = removeAttrs attrs [
"ipkgName"
"idrisLibraries"
];
mkDerivation =
withSource:
let
applyWithSource = lib: if withSource then lib.withSource else lib;
propagatedIdrisLibraries = map applyWithSource (propagate idrisLibraryLibs);
in
stdenv.mkDerivation (
finalAttrs:
drvAttrs
// {
pname = ipkgName;
inherit src version;
nativeBuildInputs = [
idris2
makeBinaryWrapper
]
++ attrs.nativeBuildInputs or [ ];
buildInputs = propagatedIdrisLibraries ++ attrs.buildInputs or [ ];
env.IDRIS2_PACKAGE_PATH = libDirs propagatedIdrisLibraries;
buildPhase = ''
runHook preBuild
idris2 --build ${ipkgFileName}
runHook postBuild
'';
passthru = {
inherit propagatedIdrisLibraries;
}
// (attrs.passthru or { });
shellHook = ''
export IDRIS2_PACKAGE_PATH="${finalAttrs.env.IDRIS2_PACKAGE_PATH}"
'';
}
);
mkExecutable =
withSource:
let
derivation = mkDerivation withSource;
in
derivation.overrideAttrs {
installPhase = ''
runHook preInstall
mkdir -p $out/bin
scheme_app="$(find ./build/exec -name '*_app')"
if [ "$scheme_app" = ''' ]; then
mv -- build/exec/* $out/bin/
chmod +x $out/bin/*
# ^ remove after Idris2 0.8.0 is released. will be superfluous:
# https://github.com/idris-lang/Idris2/pull/3189
else
cd build/exec/*_app
rm -f ./libidris2_support.{so,dylib}
for file in *.so; do
bin_name="''${file%.so}"
mv -- "$file" "$out/bin/$bin_name"
wrapProgram "$out/bin/$bin_name" \
--prefix LD_LIBRARY_PATH : ${supportDir} \
--prefix DYLD_LIBRARY_PATH : ${supportDir}
done
fi
runHook postInstall
'';
# allow an executable's dependencies to be built with source. this is convenient when
# building a development shell for the executable using `mkShell`'s `inputsFrom`.
passthru = derivation.passthru // {
withSource = mkExecutable true;
};
};
mkLibrary =
withSource:
let
installCmd = if withSource then "--install-with-src" else "--install";
derivation = mkDerivation withSource;
in
derivation.overrideAttrs {
installPhase = ''
runHook preInstall
mkdir -p $out/${libSuffix}
export IDRIS2_PREFIX=$out/lib
idris2 ${installCmd} ${ipkgFileName}
runHook postInstall
'';
# allow a library built without source to be changed to one with source
# via a passthru attribute; i.e. `my-pkg.library'.withSource`.
# this is convenient because a library derivation can be distributed as
# without-source by default but downstream projects can still build it
# with-source. We surface this regardless of whether the original library
# was built with source because that allows downstream to call this
# property unconditionally.
passthru = derivation.passthru // {
withSource = mkLibrary true;
};
};
in
{
executable = mkExecutable false;
library =
{
withSource ? false,
}:
mkLibrary withSource;
# Make a library without source; you can still use the `withSource` attribute
# on the resulting derivation to build the library with source at a later time.
library' = mkLibrary false;
}

View File

@@ -0,0 +1,10 @@
{ callPackage }:
{
idris2 = callPackage ./idris2.nix { };
idris2Api = callPackage ./idris2-api.nix { };
idris2Lsp = callPackage ./idris2-lsp.nix { };
pack = callPackage ./pack.nix { };
buildIdris = callPackage ./build-idris.nix { };
}

View File

@@ -0,0 +1,22 @@
{ lib, idris2Packages }:
let
inherit (idris2Packages) idris2 buildIdris;
apiPkg = buildIdris {
inherit (idris2) src version;
ipkgName = "idris2api";
idrisLibraries = [ ];
preBuild = ''
export IDRIS2_PREFIX=$out/lib
make src/IdrisPaths.idr
'';
meta = {
description = "Idris2 Compiler API Library";
homepage = "https://github.com/idris-lang/Idris2";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ mattpolzin ];
inherit (idris2.meta) platforms;
};
};
in
apiPkg.library { }

View File

@@ -0,0 +1,63 @@
{
lib,
fetchFromGitHub,
idris2Packages,
makeWrapper,
}:
let
globalLibraries =
let
idrName = "idris2-${idris2Packages.idris2.version}";
libSuffix = "lib/${idrName}";
in
[
"\\$HOME/.nix-profile/lib/${idrName}"
"/run/current-system/sw/lib/${idrName}"
"${idris2Packages.idris2}/${idrName}"
];
globalLibrariesPath = builtins.concatStringsSep ":" globalLibraries;
inherit (idris2Packages) idris2Api;
lspLib = idris2Packages.buildIdris {
ipkgName = "lsp-lib";
version = "2024-01-21";
src = fetchFromGitHub {
owner = "idris-community";
repo = "LSP-lib";
rev = "03851daae0c0274a02d94663d8f53143a94640da";
hash = "sha256-ICW9oOOP70hXneJFYInuPY68SZTDw10dSxSPTW4WwWM=";
};
idrisLibraries = [ ];
};
lspPkg = idris2Packages.buildIdris {
ipkgName = "idris2-lsp";
version = "2024-01-21";
src = fetchFromGitHub {
owner = "idris-community";
repo = "idris2-lsp";
rev = "a77ef2d563418925aa274fa29f06880dde43f4ec";
hash = "sha256-zjfVfkpiQS9AdmTfq0hYRSelJq5Caa9VGTuFLtSvl5o=";
};
idrisLibraries = [
idris2Api
lspLib
];
nativeBuildInputs = [ makeWrapper ];
postInstall = ''
wrapProgram $out/bin/idris2-lsp \
--suffix IDRIS2_PACKAGE_PATH ':' "${globalLibrariesPath}"
'';
meta = with lib; {
description = "Language Server for Idris2";
mainProgram = "idris2-lsp";
homepage = "https://github.com/idris-community/idris2-lsp";
license = licenses.bsd3;
maintainers = with maintainers; [ mattpolzin ];
};
};
in
lspPkg.executable

View File

@@ -0,0 +1,119 @@
# Almost 1:1 copy of idris2's nix/package.nix. Some work done in their flake.nix
# we do here instead.
{
stdenv,
lib,
chez,
chez-racket,
clang,
gmp,
fetchFromGitHub,
makeWrapper,
gambit,
nodejs,
zsh,
callPackage,
}:
# NOTICE: An `idris2WithPackages` is available at: https://github.com/claymager/idris2-pkgs
let
platformChez =
if (stdenv.system == "x86_64-linux") || (lib.versionAtLeast chez.version "10.0.0") then
chez
else
chez-racket;
in
stdenv.mkDerivation rec {
pname = "idris2";
version = "0.7.0";
src = fetchFromGitHub {
owner = "idris-lang";
repo = "Idris2";
rev = "v${version}";
sha256 = "sha256-VwveX3fZfrxEsytpbOc5Tm6rySpLFhTt5132J6rmrmM=";
};
strictDeps = true;
nativeBuildInputs = [
makeWrapper
clang
platformChez
]
++ lib.optionals stdenv.hostPlatform.isDarwin [ zsh ];
buildInputs = [
platformChez
gmp
];
prePatch = ''
patchShebangs --build tests
'';
makeFlags = [ "PREFIX=$(out)" ] ++ lib.optional stdenv.hostPlatform.isDarwin "OS=";
# The name of the main executable of pkgs.chez is `scheme`
buildFlags = [
"bootstrap"
"SCHEME=scheme"
];
checkTarget = "test";
nativeCheckInputs = [
gambit
nodejs
]; # racket ];
checkFlags = [ "INTERACTIVE=" ];
# TODO: Move this into its own derivation, such that this can be changed
# without having to recompile idris2 every time.
postInstall =
let
name = "${pname}-${version}";
globalLibraries = [
"\\$HOME/.nix-profile/lib/${name}"
"/run/current-system/sw/lib/${name}"
"$out/${name}"
];
globalLibrariesPath = builtins.concatStringsSep ":" globalLibraries;
in
''
# Remove existing idris2 wrapper that sets incorrect LD_LIBRARY_PATH
rm $out/bin/idris2
# The only thing we need from idris2_app is the actual binary
mv $out/bin/idris2_app/idris2.so $out/bin/idris2
rm $out/bin/idris2_app/*
rmdir $out/bin/idris2_app
# idris2 needs to find scheme at runtime to compile
# idris2 installs packages with --install into the path given by
# IDRIS2_PREFIX. We set that to a default of ~/.idris2, to mirror the
# behaviour of the standard Makefile install.
# TODO: Make support libraries their own derivation such that
# overriding LD_LIBRARY_PATH is unnecessary
wrapProgram "$out/bin/idris2" \
--set-default CHEZ "${platformChez}/bin/scheme" \
--run 'export IDRIS2_PREFIX=''${IDRIS2_PREFIX-"$HOME/.idris2"}' \
--suffix IDRIS2_LIBS ':' "$out/${name}/lib" \
--suffix IDRIS2_DATA ':' "$out/${name}/support" \
--suffix IDRIS2_PACKAGE_PATH ':' "${globalLibrariesPath}" \
--suffix DYLD_LIBRARY_PATH ':' "$out/${name}/lib" \
--suffix LD_LIBRARY_PATH ':' "$out/${name}/lib"
'';
# Run package tests
passthru.tests = callPackage ./tests.nix { inherit pname; };
meta = {
description = "Purely functional programming language with first class types";
mainProgram = "idris2";
homepage = "https://github.com/idris-lang/Idris2";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [
fabianhjr
wchresta
mattpolzin
];
inherit (chez.meta) platforms;
};
}

View File

@@ -0,0 +1,84 @@
{
lib,
idris2Packages,
fetchFromGitHub,
clang,
chez,
gmp,
zsh,
makeBinaryWrapper,
stdenv,
}:
let
inherit (idris2Packages) idris2Api buildIdris;
toml = buildIdris {
ipkgName = "toml";
version = "2022-05-05";
src = fetchFromGitHub {
owner = "cuddlefishie";
repo = "toml-idr";
rev = "b4f5a4bd874fa32f20d02311a62a1910dc48123f";
hash = "sha256-+bqfCE6m0aJ+S65urT+zQLuZUtUkC1qcuSsefML/fAE=";
};
idrisLibraries = [ ];
};
filepath = buildIdris {
ipkgName = "filepath";
version = "2023-12-04";
src = fetchFromGitHub {
owner = "stefan-hoeck";
repo = "idris2-filepath";
rev = "eac02d51b631633f32330c788bcebeb24221fa09";
hash = "sha256-noylxQvT2h50H0xmAiwe/cI6vz5gkbOhSD7mXuhJGfU=";
};
idrisLibraries = [ ];
};
packPkg = buildIdris {
ipkgName = "pack";
version = "2024-02-07";
src = fetchFromGitHub {
owner = "stefan-hoeck";
repo = "idris2-pack";
rev = "305123401a28a57b02f750c589c35af628b2a5eb";
hash = "sha256-IPAkwe6fEYWT3mpyKKkUPU0qFJX9gGIM1f7OeNWyB9w=";
};
idrisLibraries = [
idris2Api
toml
filepath
];
nativeBuildInputs = [ makeBinaryWrapper ];
buildInputs = [
gmp
clang
chez
]
++ lib.optionals stdenv.hostPlatform.isDarwin [ zsh ];
postInstall = ''
wrapProgram $out/bin/pack \
--suffix C_INCLUDE_PATH : ${lib.makeIncludePath [ gmp ]} \
--suffix PATH : ${
lib.makeBinPath (
[
clang
chez
]
++ lib.optionals stdenv.hostPlatform.isDarwin [ zsh ]
)
}
'';
meta = {
description = "Idris2 Package Manager with Curated Package Collections";
mainProgram = "pack";
homepage = "https://github.com/stefan-hoeck/idris2-pack";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ mattpolzin ];
inherit (idris2Packages.idris2.meta) platforms;
};
};
in
packPkg.executable

View File

@@ -0,0 +1,263 @@
{
stdenv,
runCommand,
lib,
pname,
idris2,
idris2Packages,
zsh,
tree,
}:
let
testCompileAndRun =
{
testName,
code,
want,
packages ? [ ],
}:
let
packageString = builtins.concatStringsSep " " (map (p: "--package " + p) packages);
in
runCommand "${pname}-${testName}"
{
meta.timeout = 60;
# with idris2 compiled binaries assume zsh is available on darwin, but that
# is not the case with pure nix environments. Thus, we need to include zsh
# when we build for darwin in tests. While this is impure, this is also what
# we find in real darwin hosts.
nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ zsh ];
}
''
set -eo pipefail
cat > packageTest.idr <<HERE
${code}
HERE
${idris2}/bin/idris2 ${packageString} -o packageTest packageTest.idr
GOT=$(./build/exec/packageTest)
if [ "$GOT" = "${want}" ]; then
echo "${testName} SUCCESS: '$GOT' = '${want}'"
else
>&2 echo "Got '$GOT', want: '${want}'"
exit 1
fi
touch $out
'';
testBuildIdris =
{
testName,
buildIdrisArgs,
# function that takes result of `buildIdris` and transforms it (commonly
# by calling `.executable` or `.library {}` upon it):
transformBuildIdrisOutput,
expectedTree,
}:
let
idrisPkg = transformBuildIdrisOutput (idris2Packages.buildIdris buildIdrisArgs);
in
runCommand "${pname}-${testName}"
{
meta.timeout = 60;
nativeBuildInputs = [ tree ];
}
''
GOT="$(tree ${idrisPkg} | tail -n +2)"
if [ "$GOT" = '${expectedTree}' ]; then
echo "${testName} SUCCESS"
else
>&2 echo "Got:
$GOT"
>&2 echo 'want:
${expectedTree}'
exit 1
fi
touch $out
'';
in
{
# Simple hello world compiles, runs and outputs as expected
helloWorld = testCompileAndRun {
testName = "hello-world";
code = ''
module Main
main : IO ()
main = putStrLn "Hello World!"
'';
want = "Hello World!";
};
# Data.Vect.Sort is available via --package contrib
useContrib = testCompileAndRun {
testName = "use-contrib";
packages = [ "contrib" ];
code = ''
module Main
import Data.Vect
import Data.Vect.Sort -- from contrib
vect : Vect 3 Int
vect = 3 :: 1 :: 5 :: Nil
main : IO ()
main = putStrLn $ show (sort vect)
'';
want = "[1, 3, 5]";
};
buildLibrary = testBuildIdris {
testName = "library-package";
buildIdrisArgs = {
ipkgName = "pkg";
idrisLibraries = [ idris2Packages.idris2Api ];
src = runCommand "library-package-src" { } ''
mkdir $out
cat > $out/Main.idr <<EOF
module Main
import Compiler.ANF -- from Idris2Api
hello : String
hello = "world"
EOF
cat > $out/pkg.ipkg <<EOF
package pkg
modules = Main
depends = idris2
EOF
'';
};
transformBuildIdrisOutput = pkg: pkg.library { withSource = false; };
expectedTree = ''
`-- lib
`-- idris2-0.7.0
`-- pkg-0
|-- 2023090800
| |-- Main.ttc
| `-- Main.ttm
`-- pkg.ipkg
5 directories, 3 files'';
};
buildLibraryWithSource = testBuildIdris {
testName = "library-with-source-package";
buildIdrisArgs = {
ipkgName = "pkg";
idrisLibraries = [ idris2Packages.idris2Api ];
src = runCommand "library-package-src" { } ''
mkdir $out
cat > $out/Main.idr <<EOF
module Main
import Compiler.ANF -- from Idris2Api
hello : String
hello = "world"
EOF
cat > $out/pkg.ipkg <<EOF
package pkg
modules = Main
depends = idris2
EOF
'';
};
transformBuildIdrisOutput = pkg: pkg.library { withSource = true; };
expectedTree = ''
`-- lib
`-- idris2-0.7.0
`-- pkg-0
|-- 2023090800
| |-- Main.ttc
| `-- Main.ttm
|-- Main.idr
`-- pkg.ipkg
5 directories, 4 files'';
};
buildLibraryWithSourceRetroactively = testBuildIdris {
testName = "library-with-source-retro-package";
buildIdrisArgs = {
ipkgName = "pkg";
idrisLibraries = [ idris2Packages.idris2Api ];
src = runCommand "library-package-src" { } ''
mkdir $out
cat > $out/Main.idr <<EOF
module Main
import Compiler.ANF -- from Idris2Api
hello : String
hello = "world"
EOF
cat > $out/pkg.ipkg <<EOF
package pkg
modules = Main
depends = idris2
EOF
'';
};
transformBuildIdrisOutput = pkg: pkg.library'.withSource;
expectedTree = ''
`-- lib
`-- idris2-0.7.0
`-- pkg-0
|-- 2023090800
| |-- Main.ttc
| `-- Main.ttm
|-- Main.idr
`-- pkg.ipkg
5 directories, 4 files'';
};
buildExecutable = testBuildIdris {
testName = "executable-package";
buildIdrisArgs = {
ipkgName = "pkg";
idrisLibraries = [ ];
src = runCommand "executable-package-src" { } ''
mkdir $out
cat > $out/Main.idr <<EOF
module Main
main : IO ()
main = putStrLn "hi"
EOF
cat > $out/pkg.ipkg <<EOF
package pkg
modules = Main
main = Main
executable = mypkg
EOF
'';
};
transformBuildIdrisOutput = pkg: pkg.executable;
expectedTree = ''
`-- bin
`-- mypkg
2 directories, 1 file'';
};
}