forked from Fundament-Software/Alicorn0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
127 lines (119 loc) · 4.18 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
description =
"An experimental language for high performance safe convenient metaprogramming";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
luvitpkgs = {
url = "github:aiverson/luvit-nix";
# inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, luvitpkgs, flake-utils, pre-commit-hooks }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
luajit = pkgs.luajit.override {
self = luajit;
version = "2.1.0-beta3";
src = pkgs.fetchFromGitHub {
owner = "LuaJIT";
repo = "LuaJIT";
rev = "50936d784474747b4569d988767f1b5bab8bb6d0";
hash = "sha256-oPU3hwSgL+d/4yW7r7maugDi+LA8QmvFN7ssEgC9B70=";
};
};
alicorn-check = file:
pkgs.runCommandNoCC "alicorn-check-${file}" { } ''
set -euo pipefail
cd ${./.}
mkdir $out
>&2 echo "Checking ${file}"
${pkgs.lib.getExe' luvitpkgs.packages.${system}.luvit "luvit"} ${file}
'';
lqc = luajit.pkgs.buildLuarocksPackage rec {
pname = "lua-quickcheck";
version = "0.2-4";
src = pkgs.fetchFromGitHub {
owner = "luc-tielen";
repo = "lua-quickcheck";
rev = "v${version}";
hash = "sha256-B3Gz0emI3MBwp2Bg149KU02RlzVzbKdVPM+B7ZFH+80";
};
knownRockspec = "${src}/rockspecs/lua-quickcheck-${version}.rockspec";
propagatedBuildInputs =
[ luajit luajit.pkgs.luafilesystem luajit.pkgs.argparse ];
};
in
{
packages = rec {
inherit (pkgs) hello;
default = hello;
};
apps = rec {
hello =
flake-utils.lib.mkApp { drv = self.packages.${system}.hello; };
default = hello;
};
checks = {
terms = alicorn-check "test-terms.lua";
derive-pretty-print = alicorn-check "test-derive-pretty-print.lua";
formatting = pkgs.runCommandNoCC "stylua-check" { } ''
cd ${./.}
mkdir $out
${pkgs.lib.getExe pkgs.stylua} . -c
'';
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
statix.enable = true;
nixpkgs-fmt.enable = true;
stylua.enable = true;
deadnix.enable = true;
};
};
};
# nix fmt's docs say this should only be for *.nix files but we're ignoring that as that's inconvenient
# See https://github.com/NixOS/nix/issues/9132#issuecomment-1754999829
formatter = pkgs.writeShellApplication {
name = "run-formatters";
runtimeInputs = [ pkgs.stylua pkgs.nixpkgs-fmt ];
text = ''
set -xeu
nixpkgs-fmt "$@"
stylua "$@"
'';
};
devShells = rec {
alicorn = pkgs.mkShell {
buildInputs = [
luvitpkgs.packages.${system}.lit
luvitpkgs.packages.${system}.luvit
pkgs.stylua
pkgs.inferno
(pkgs.lua-language-server.overrideAttrs {
version = "unstable";
src = pkgs.fetchFromGitHub {
owner = "luals";
repo = "lua-language-server";
rev = "7d06e5573c8188e61516e987b0d796a40f718b05";
hash = "sha256-mNG/IqRkXHVwUU06e1oD/3WBa5k09ddYUsiQN4MFaOU";
fetchSubmodules = true;
};
})
(luajit.withPackages
(ps: with ps; [ luasocket lpeg inspect luaunit tl lqc ]))
];
shellHook = self.checks.${system}.pre-commit-check.shellHook + ''
export LUA_PATH='${luajit}/share/lua/5.1/?.lua;./?.lua'
'';
};
default = alicorn;
};
});
}