Skip to content

Instantly share code, notes, and snippets.

@mogenson
Created March 21, 2022 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mogenson/c57060a9dc592ec46871324e94b3a3d3 to your computer and use it in GitHub Desktop.
Save mogenson/c57060a9dc592ec46871324e94b3a3d3 to your computer and use it in GitHub Desktop.
Croissant nix derivation
# lua.nix
{ config, lib, pkgs, ... }:
with pkgs; let
luaprompt = luajitPackages.buildLuarocksPackage {
pname = "luaprompt";
version = "0.7-1";
knownRockspec = (fetchurl {
url = "https://luarocks.org/luaprompt-0.7-1.rockspec";
sha256 = "sha256-jDDLie49dCVDCCSHGdvZQhOncVcGFx90OVSnIHfhPfk=";
}).outPath;
src = fetchgit {
url = "https://github.com/dpapavas/luaprompt";
sha256 = "sha256-wBS2SIBz+Jcg8Uenpoi/oSg81ZQ4vCscoDD4Lb9NtIk=";
};
propagatedBuildInputs = with luajitPackages; [ luajit argparse ];
buildInputs = [ readline ];
extraVariables = rec {
READLINE_INCDIR = "${readline.dev}/include";
HISTORY_INCDIR = READLINE_INCDIR;
READLINE_LIBDIR = "${readline.out}/lib";
HISTORY_LIBDIR = READLINE_LIBDIR;
};
};
hump = callPackage ./lua/hump.nix {
lua = luajit;
buildLuarocksPackage = luajitPackages.buildLuarocksPackage;
};
wcwidth = callPackage ./lua/wcwidth.nix {
lua = luajit;
buildLuarocksPackage = luajitPackages.buildLuarocksPackage;
};
sirocco = callPackage ./lua/sirocco.nix {
lua = luajit;
lua-term = luajitPackages.lua-term;
hump = hump;
wcwidth = wcwidth;
compat53 = luajitPackages.compat53;
bit32 = luajitPackages.bit32;
buildLuarocksPackage = luajitPackages.buildLuarocksPackage;
};
croissant = callPackage ./lua/croissant.nix {
lua = luajit;
hump = hump;
sirocco = sirocco;
argparse = luajitPackages.argparse;
compat53 = luajitPackages.compat53;
lpeg = luajitPackages.lpeg;
buildLuarocksPackage = luajitPackages.buildLuarocksPackage;
};
lua = luajit.withPackages (
ps: with ps; [
luacheck
penlight
luaprompt
croissant
]
);
in
{
home = {
packages = [
lua
luaformatter
sumneko-lua-language-server
];
sessionVariables =
if stdenv.isLinux then {
LUA_PATH = "${lua}/share/lua/${luajit.luaversion}/?.lua";
LUA_CPATH = "${lua}/lib/lua/${luajit.luaversion}/?.so";
} else { };
};
}
# lua/croissant.nix
{ buildLuarocksPackage
, fetchgit
, fetchurl
, lua
, sirocco
, hump
, lpeg
, argparse
, compat53
}:
buildLuarocksPackage {
pname = "croissant";
version = "0.0.1-6";
knownRockspec = (fetchurl {
url = "https://luarocks.org/croissant-0.0.1-6.rockspec";
sha256 = "0jdj7akx9r1ak40ff1997f7i6d5hw8533w21fckdvvpyg01kc8qz";
}).outPath;
src = fetchgit (removeAttrs
(builtins.fromJSON ''{
"url": "https://github.com/giann/croissant",
"rev": "65f2d3d61b9b13bdc380afc2eaf0c7c6ef461be7",
"date": "2019-11-19T07:23:36+01:00",
"path": "/nix/store/lahj87bdnn6w23p2plfddz7gpn5a0s4f-croissant",
"sha256": "0ya8wc97bsnxdccdcfvp2202a8wlypn8gv9hfdx6193qyds2yvp9",
"fetchLFS": false,
"fetchSubmodules": true,
"deepClone": false,
"leaveDotGit": false
}
'') [ "date" "path" ]);
propagatedBuildInputs = [ lua sirocco hump lpeg argparse compat53 ];
meta = {
homepage = "https://github.com/giann/croissant";
description = "A Lua REPL implemented in Lua";
license.fullName = "MIT/X11";
};
}
# lua/hump.nix
{ buildLuarocksPackage
, fetchgit
, lua
, fetchurl
}:
buildLuarocksPackage {
pname = "hump";
version = "0.4-2";
knownRockspec = (fetchurl {
url = "https://luarocks.org/hump-0.4-2.rockspec";
sha256 = "0j89rznvq90bvjsj1mj9plxmxj8c7b4jkqsllw882f8xscdqq2sa";
}).outPath;
src = fetchgit (removeAttrs
(builtins.fromJSON ''{
"url": "https://github.com/vrld/hump",
"rev": "08937cc0ecf72d1a964a8de6cd552c5e136bf0d4",
"date": "2021-03-23T19:50:46+01:00",
"path": "/nix/store/pph6fj29fshcysa3g80qf8vw2znyv238-hump",
"sha256": "0vr8zclf0c1x9mwv49m8ldvsdbidms25agl24rcng3q1n15v4289",
"fetchLFS": false,
"fetchSubmodules": true,
"deepClone": false,
"leaveDotGit": false
}
'') [ "date" "path" ]);
propagatedBuildInputs = [ lua ];
meta = {
homepage = "https://hump.readthedocs.io";
description = "Lightweight game development utilities";
license.fullName = "MIT";
};
}
# lua/sirocco.nix
{ buildLuarocksPackage
, fetchgit
, fetchurl
, lua
, lua-term
, hump
, wcwidth
, compat53
, bit32
}:
buildLuarocksPackage {
pname = "sirocco";
version = "0.0.1-5";
knownRockspec = (fetchurl {
url = "https://luarocks.org/sirocco-0.0.1-5.rockspec";
sha256 = "0bs2zcy8sng4x16clfz47cn4l6fw43rj224vjgmnkfvp9nznd4b4";
}).outPath;
src = fetchgit (removeAttrs
(builtins.fromJSON ''{
"url": "https://github.com/giann/sirocco",
"rev": "b2af2d336e808e763b424d2ea42e6a2c2b4aa24d",
"date": "2019-03-10T06:11:17+01:00",
"path": "/nix/store/jh7vjxmlm7m47n4pydd2x7wph1ga5ljv-sirocco",
"sha256": "1mkkdfjc7zc3as3vpyvqbg3ldgcb2s16lgxc8mrxc74kwiblgird",
"fetchLFS": false,
"fetchSubmodules": true,
"deepClone": false,
"leaveDotGit": false
}
'') [ "date" "path" ]);
propagatedBuildInputs = [ lua lua-term hump wcwidth compat53 bit32 ];
postPatch = ''
sed -e "s,/usr/bin/env stty,/bin/stty," -i sirocco/prompt.lua
'';
meta = {
homepage = "https://github.com/giann/sirocco";
description = "A collection of useful cli prompts";
license.fullName = "MIT/X11";
};
}
# lua/wcwidth.nix
{ buildLuarocksPackage
, fetchgit
, lua
, fetchurl
}:
buildLuarocksPackage {
pname = "wcwidth";
version = "0.5-1";
knownRockspec = (fetchurl {
url = "https://luarocks.org/wcwidth-0.5-1.rockspec";
sha256 = "0hyl8f3fvmiq2grhafz1cbnkp60mb58y2p8jg7yafin9kk69zg64";
}).outPath;
src = fetchgit (removeAttrs
(builtins.fromJSON ''{
"url": "https://github.com/aperezdc/lua-wcwidth",
"rev": "2742b255aec83b80bc288cedc02681a9c1db3208",
"date": "2020-03-29T19:46:48+03:00",
"path": "/nix/store/lysh6077537mwx72k90ak6rp7zzs5fr7-lua-wcwidth",
"sha256": "1ay2dq82lca58na939k0774vq7x0k2hhj059ylhg2wvm9mn3cqxb",
"fetchLFS": false,
"fetchSubmodules": true,
"deepClone": false,
"leaveDotGit": false
}
'') [ "date" "path" ]);
propagatedBuildInputs = [ lua ];
meta = {
homepage = "https://github.com/aperezdc/lua-wcwidth";
description = "Pure Lua implementation of the wcwidth() function";
license.fullName = "MIT/X11";
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment