-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
88 lines (64 loc) · 2.31 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
outputs = { self, nixpkgs }:
let
currentVersion = builtins.readFile ./VERSION;
flakePkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [ self.overlays.default ];
};
buildPackage = pname: luaPackages: with luaPackages;
buildLuaPackage rec {
name = "${pname}-${version}";
inherit pname;
version = "${currentVersion}-${self.shortRev or "dev"}";
src = ./.;
propagatedBuildInputs = [ lua ];
buildInputs = [ busted luacov luacheck ldoc ];
buildPhase = ":";
installPhase = ''
mkdir -p "$out/share/lua/${lua.luaversion}"
cp -r src/${pname} "$out/share/lua/${lua.luaversion}/"
'';
doCheck = true;
checkPhase = "make check";
};
in
{
checks.x86_64-linux = self.packages.x86_64-linux;
packages.x86_64-linux = rec {
default = lua_enum;
lua_enum = buildPackage "enum" flakePkgs.luaPackages;
lua51_enum = buildPackage "enum" flakePkgs.lua51Packages;
lua52_enum = buildPackage "enum" flakePkgs.lua52Packages;
lua53_enum = buildPackage "enum" flakePkgs.lua53Packages;
luajit_enum = buildPackage "enum" flakePkgs.luajitPackages;
};
devShells.x86_64-linux.default = flakePkgs.mkShell {
LUA_PATH = "./src/?.lua;./src/?/init.lua";
buildInputs = (with self.packages.x86_64-linux.default; buildInputs ++ propagatedBuildInputs) ++ (with flakePkgs; [
nixpkgs-fmt
luarocks
]);
};
overlays.default = final: prev: with self.packages.x86_64-linux; {
# NOTE: lua = prev.lua.override { packageOverrides = this: other: {... }}
# Seems to be broken as it does not allow to combine different overlays.
luaPackages = prev.luaPackages // {
enum = lua_enum;
};
lua51Packages = prev.lua51Packages // {
enum = lua51_enum;
};
lua52Packages = prev.lua52Packages // {
enum = lua52_enum;
};
lua53Packages = prev.lua53Packages // {
enum = lua53_enum;
};
luajitPackages = prev.luajitPackages // {
enum = luajit_enum;
};
};
};
}