-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathflake.nix
More file actions
169 lines (158 loc) · 5.75 KB
/
Copy pathflake.nix
File metadata and controls
169 lines (158 loc) · 5.75 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
{
description = "A library and client implementation of luarocks";
nixConfig = {
extra-substituters = "https://neorocks.cachix.org";
extra-trusted-public-keys = "neorocks.cachix.org-1:WqMESxmVTOJX7qoBC54TwrMMoVI1xAM+7yFin8NRfwk=";
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
crane.url = "github:ipetkov/crane";
flake-parts.url = "github:hercules-ci/flake-parts";
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ {
self,
nixpkgs,
flake-parts,
git-hooks,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = builtins.attrNames nixpkgs.legacyPackages;
perSystem = attrs @ {
system,
pkgs,
...
}: let
pkgs = attrs.pkgs.extend self.overlays.default;
lib = pkgs.lib;
rockspecTests = pkgs.callPackage ./nix/tests/rockspec.nix {};
nvimPluginTests = pkgs.callPackage ./nix/tests/nvim-plugin.nix {};
luxProjectTests = pkgs.callPackage ./nix/tests/lux-project.nix {};
buildLuxHelpersTests = pkgs.callPackage ./nix/tests/build-lux-helpers.nix {};
git-hooks-check = git-hooks.lib.${system}.run {
src = self;
hooks = {
# NOTE: When adding/removing hooks, make sure
# to update CONTRIBUTING.md for non-nix users.
alejandra.enable = true;
rustfmt.enable = true;
taplo = {
enable = true;
name = "taplo";
description = "Format TOML files with taplo fmt";
extraPackages = [pkgs.taplo];
entry = "taplo fmt";
types = ["toml"];
excludes = ["lux-workspace-hack/Cargo.toml"];
};
};
};
in {
packages = with pkgs; {
default = lux-cli;
inherit
lux-cli
lux-lsp
lux-lua51
lux-lua52
lux-lua53
lux-lua54
lux-lua55
lux-luajit
;
};
legacyPackages = pkgs;
devShells = let
isDarwin = pkgs.stdenv.isDarwin;
mkDevShell = extra_pkgs:
pkgs.mkShell {
name = "lux devShell";
shellHook =
lib.optionalString
(!isDarwin)
git-hooks-check.shellHook;
buildInputs =
extra_pkgs
++ (with pkgs; [
rust-analyzer
lspmux
cargo-nextest
cargo-hakari
cargo-insta
cargo-cross
clippy
taplo
# Needed for integration test builds
pkg-config
libxcrypt
cmakeMinimal
zlib
gnum4
])
++ (lib.optional (!isDarwin) self.checks.${system}.git-hooks-check.enabledPackages)
++ (lib.filter (pkg: !(lib.hasPrefix "lua" pkg.name)) pkgs.lux-cli.buildInputs)
++ (lib.filter (pkg: !(lib.hasPrefix "xtask" pkg.name)) pkgs.lux-cli.nativeBuildInputs);
};
mkBuildShell = pkgs':
pkgs'.mkShell {
name = "lux buildShell";
buildInputs =
(lib.filter (pkg: !(lib.hasPrefix "lua" pkg.name)) pkgs'.lux-cli.buildInputs)
++ pkgs'.lux-cli.nativeBuildInputs;
};
in rec {
default = lua51;
lua51 = mkDevShell [pkgs.lua5_1];
lua52 = mkDevShell [pkgs.lua5_2];
lua53 = mkDevShell [pkgs.lua5_3];
lua54 = mkDevShell [pkgs.lua5_4];
lua55 = mkDevShell [pkgs.lua5_5];
luajit = mkDevShell [pkgs.luajit];
# devShells with neovim-unwrapped (for CI integration tests)
lua51-ci = mkDevShell (with pkgs; [lua5_1 neovim-unwrapped]);
lua52-ci = mkDevShell (with pkgs; [lua5_2 neovim-unwrapped]);
lua53-ci = mkDevShell (with pkgs; [lua5_3 neovim-unwrapped]);
lua54-ci = mkDevShell (with pkgs; [lua5_4 neovim-unwrapped]);
lua55-ci = mkDevShell (with pkgs; [lua5_5 neovim-unwrapped]);
luajit-ci = mkDevShell (with pkgs; [luajit neovim-unwrapped]);
cd = mkBuildShell pkgs;
};
checks = rec {
default = tests;
inherit
git-hooks-check
;
tests = pkgs.lux-nextest;
lua-tests = pkgs.lux-nextest-lua;
clippy = pkgs.lux-clippy;
workspace-hack = pkgs.lux-workspace-hack;
rockspec-cjson = rockspecTests.cjson;
rockspec-luassert = rockspecTests.luassert;
rockspec-toml-edit = rockspecTests.toml-edit;
nvim-plugin = nvimPluginTests.test;
nvim-plugin-luxHash = nvimPluginTests.test-luxHash;
lux-project-toml-edit = luxProjectTests.test;
build-lux-helpers = buildLuxHelpersTests.fetchLuxDeps;
build-lux-helpers-import-lock = buildLuxHelpersTests.importLuxLock;
build-lux-helpers-lux-lock = buildLuxHelpersTests.luxLock;
build-lux-helpers-lux-vendor-dir = buildLuxHelpersTests.luxVendorDir;
build-lux-helpers-with-packages = buildLuxHelpersTests.withPackages;
};
formatter = let
config = self.checks.${system}.git-hooks-check.config;
inherit (config) package configFile;
script = ''
${pkgs.lib.getExe package} run --all-files --config ${configFile}
'';
in
pkgs.writeShellScriptBin "pre-commit-run" script;
};
flake = {
overlays.default = with inputs; import ./nix/overlay.nix {inherit self crane;};
};
};
}