add nim packages

This commit is contained in:
Christian Ulrich 2019-04-17 00:58:15 +02:00
parent 4f24dba2ae
commit 9e6e045e88
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
4 changed files with 149 additions and 0 deletions

View File

@ -1,5 +1,9 @@
self: super:
{
buildNimblePackage = super.callPackage ./pkgs/nim-packages/generic.nix { };
gintro = super.callPackage ./pkgs/nim-packages/gintro/default.nix { };
shinto-cli = super.callPackage ./pkgs/shinto-cli { };
}

View File

@ -0,0 +1,41 @@
{ stdenv, nim }:
{ name, src, nimDeps ? [], buildInputs ? [], nativeBuildInputs ? [],
patches ? [], ... }:
stdenv.mkDerivation {
name = name;
src = src;
patches = patches;
buildInputs = [ nim ] ++ buildInputs;
nativeBuildInputs = nativeBuildInputs;
LD_LIBRARY_PATH = stdenv.lib.makeLibraryPath (buildInputs ++ nativeBuildInputs);
buildPhase = ''
HOME=$TMPDIR
mkdir -p $HOME/.nimble/pkgs
echo "[]" > $HOME/.nimble/packages_official.json
'' + toString (map (dep: ''
if [ -d ${dep}/.nimble ]; then
cp -R ${dep}/.nimble/pkgs $HOME/.nimble/
else
cp -R ${dep} $HOME/.nimble/pkgs/${dep.name}
fi
''
) nimDeps) + ''
nimble install
'';
installPhase = ''
mkdir $out
nimbleDir=$TMPDIR/.nimble
if [ -d $nimbleDir/bin ]; then
cp -RL $nimbleDir/bin $out
fi
numberNimFiles=$(find $nimbleDir/pkgs/${name} -type f -name "*.nim" | wc -l)
numberDirectories=$(find $nimbleDir/pkgs/${name} -mindepth 1 -type d | wc -l)
if [ $numberNimFiles -gt 0 ] || [ $numberDirectories -gt 0 ]; then
mkdir -p $out/.nimble
cp -R $nimbleDir/pkgs $out/.nimble
fi
'';
}

View File

@ -0,0 +1,53 @@
diff --git a/gintro.nimble b/gintro.nimble
index 937984d..e4378bf 100644
--- a/gintro.nimble
+++ b/gintro.nimble
@@ -31,8 +31,6 @@ proc prep =
# quit("gintro: tmp directory already exists!")
mkDir(wd)
cd(wd)
- mkDir("ngtk3")
- cd("ngtk3")
cpFile(this / "tests" / "gen.nim", td / wd / "gen.nim")
cpFile(this / "tests" / "combinatorics.nim", td / wd / "combinatorics.nim")
@@ -40,6 +38,8 @@ proc prep =
cd(td)
cd(wd)
+ mkDir("oldgtk3")
+ cd("oldgtk3")
try:
exec("wget https://raw.githubusercontent.com/StefanSalewski/oldgtk3/master/oldgtk3/gobject.nim -O gobject.nim")
exec("wget https://raw.githubusercontent.com/StefanSalewski/oldgtk3/master/oldgtk3/glib.nim -O glib.nim")
@@ -57,6 +57,7 @@ proc prep =
echo "Nimgrab should be available in Nim/tools directory. You may compile it with 'nim c -d:ssl nimgrab.nim'"
echo "and put it into your search path"
echo "For the unlikely case that you have already full oldgtk3 package installed, we will just try to continue..."
+ cd("..")
exec("nim c gen.nim")
mkDir("nim_gi")
@@ -70,7 +71,6 @@ proc prep =
#task prepare, "preparing gintro":
before install:
-
echo "preparing gintro"
prep()
diff --git a/tests/gen.nim b/tests/gen.nim
index ef3becf..d13eab4 100644
--- a/tests/gen.nim
+++ b/tests/gen.nim
@@ -31,8 +31,8 @@
# This module is really ugly currently -- the first goal was to get a working gi solution
from os import `/`
-import gir
-import glib
+import oldgtk3/gir
+import oldgtk3/glib
import strutils
import sequtils
import streams

View File

@ -0,0 +1,51 @@
{ stdenv, buildNimblePackage, fetchFromGitHub, glib, gobjectIntrospection,
gnome3, cairo, pango, librsvg, libnotify }:
let
oldgtk3 = buildNimblePackage rec {
name = "oldgtk3-${version}";
version = "0.1.0";
src = fetchFromGitHub {
owner = "StefanSalewski";
repo = "oldgtk3";
rev = "8ad4bc7e790c2c4b01eff9ff4f7d7ecc2cac25e3";
sha256 = "1kfv4cwgfygbxfgnsyzcwvy5l17082zx9vb9kc75zj27qhlq9ygd";
};
};
in buildNimblePackage rec {
name = "gintro-${version}";
version = "0.4.17";
src = fetchFromGitHub {
owner = "StefanSalewski";
repo = "gintro";
rev = "v${version}";
sha256 = "1cyif60611gig0r65zlgk15rvxyp00dddqcd9bc54xx3znxmygbv";
};
patches = [ ./allow-preinstalled-oldgtk3.patch ];
nimDeps = [ oldgtk3 ];
buildInputs = [
glib
gobjectIntrospection
gnome3.gdk_pixbuf
gnome3.gtk
gnome3.gtksourceview
gnome3.vte
cairo
pango
librsvg
libnotify
];
meta = with stdenv.lib; {
description = "High level GObject-Introspection based GTK3 bindings for Nim language";
homepage = https://github.com/StefanSalewski/gintro;
license = licenses.mit;
maintainers = with maintainers; [ lurchi ];
platforms = platforms.gnu ++ platforms.linux;
};
}