Skip to content

Commit bf206d1

Browse files
author
jghauser
committed
ci: make flake work with luarocks
1 parent 4e7011d commit bf206d1

File tree

5 files changed

+239
-116
lines changed

5 files changed

+239
-116
lines changed

flake.lock

+36-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+50-56
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,57 @@
11
{
2-
description = "Papis.nvim development environment";
2+
description = "Papis.nvim flake";
33

44
inputs = {
5-
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
5+
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
6+
7+
flake-parts.url = "github:hercules-ci/flake-parts";
68
};
79

8-
outputs = {
10+
outputs = inputs @ {
911
self,
1012
nixpkgs,
13+
flake-parts,
1114
...
1215
}: let
13-
systems = ["x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
14-
forAllSystems = f:
15-
builtins.listToAttrs (map (name: {
16-
inherit name;
17-
value = f name;
18-
})
19-
systems);
20-
in {
21-
packages =
22-
forAllSystems
23-
(system: let
24-
pkgs = import nixpkgs {
25-
inherit system;
26-
};
27-
in {
28-
papis-nvim = pkgs.vimUtils.buildVimPlugin {
29-
pname = "papis.nvim";
30-
version = toString (self.shortRev or self.dirtyShortRev or self.lastModified or "unknown");
31-
src = self;
32-
dependencies = [
33-
pkgs.vimPlugins.telescope-nvim
34-
pkgs.vimPlugins.sqlite-lua
35-
pkgs.vimPlugins.plenary-nvim
36-
pkgs.vimPlugins.nui-nvim
37-
pkgs.vimPlugins.nvim-treesitter-parsers.yaml
38-
];
39-
};
40-
});
16+
name = "papis.nvim";
4117

42-
overlays.default = final: prev: {
43-
vimPlugins = prev.vimPlugins.extend (f: p: {
44-
papis-nvim = self.packages.${final.system}.papis-nvim;
45-
});
18+
plugin-overlay = import ./nix/plugin-overlay.nix {
19+
inherit name self;
4620
};
47-
devShells =
48-
forAllSystems
49-
(system: let
21+
in
22+
flake-parts.lib.mkFlake {inherit inputs;} {
23+
systems = [
24+
"x86_64-linux"
25+
"x86_64-darwin"
26+
"aarch64-darwin"
27+
];
28+
perSystem = {
29+
config,
30+
self',
31+
inputs',
32+
system,
33+
...
34+
}: let
35+
ci-overlay = import ./nix/ci-overlay.nix {
36+
inherit self name;
37+
};
38+
5039
pkgs = import nixpkgs {
5140
inherit system;
41+
overlays = [
42+
plugin-overlay
43+
ci-overlay
44+
];
5245
};
53-
in {
54-
default = pkgs.mkShell {
55-
buildInputs = let
56-
custom-nvim = pkgs.neovim.override {
57-
configure = {
58-
customRC = ''
59-
luafile ./tests/minimal_init.lua
60-
'';
61-
packages.myVimPackage.start =
62-
self.packages.${system}.papis-nvim.dependencies
63-
++ [
64-
pkgs.vimPlugins.nvim-cmp
65-
];
66-
};
67-
};
6846

47+
devShell = pkgs.mkShell {
48+
buildInputs = let
6949
nvim-test = pkgs.writeShellApplication {
7050
name = "nvim-test";
7151
text =
7252
# bash
7353
''
74-
${custom-nvim}/bin/nvim -c "lua _Load_papis()" -c "e test.md"
54+
${pkgs.neovim-with-papis}/bin/nvim -c "lua _Load_papis()" -c "e test.md"
7555
'';
7656
};
7757
in [
@@ -81,6 +61,20 @@
8161
nvim-test
8262
];
8363
};
84-
});
85-
};
64+
in {
65+
devShells = {
66+
default = devShell;
67+
inherit devShell;
68+
};
69+
70+
packages = rec {
71+
default = papis-nvim;
72+
inherit (pkgs.luajitPackages) papis-nvim;
73+
inherit (pkgs) neovim-with-papis;
74+
};
75+
};
76+
flake = {
77+
overlays.default = plugin-overlay;
78+
};
79+
};
8680
}

nix/ci-overlay.nix

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Add flake.nix test inputs as arguments here
2+
{
3+
self,
4+
name,
5+
}: final: prev: let
6+
mkNvimMinimal = nvim:
7+
with final; let
8+
neovimConfig = neovimUtils.makeNeovimConfig {
9+
withPython3 = true;
10+
viAlias = true;
11+
vimAlias = true;
12+
extraLuaPackages = luaPkgs: [
13+
luaPkgs.papis-nvim
14+
];
15+
plugins = with vimPlugins; [
16+
telescope-nvim
17+
nvim-cmp
18+
(nvim-treesitter.withPlugins (ps:
19+
with ps; [
20+
tree-sitter-yaml
21+
]))
22+
];
23+
};
24+
runtimeDeps = [
25+
yq-go
26+
];
27+
in
28+
final.wrapNeovimUnstable nvim (neovimConfig
29+
// {
30+
wrapperArgs =
31+
lib.escapeShellArgs neovimConfig.wrapperArgs
32+
+ " "
33+
+ ''--set NVIM_APPNAME "nvim-papis"''
34+
+ " "
35+
+ ''--prefix PATH : "${lib.makeBinPath runtimeDeps}"'';
36+
wrapRc = true;
37+
neovimRcContent =
38+
# lua
39+
''
40+
lua << EOF
41+
local o = vim.o
42+
local cmd = vim.cmd
43+
local fn = vim.fn
44+
45+
o.termguicolors = true
46+
o.swapfile = false
47+
48+
vim.opt.runtimepath:prepend(vim.fn.getcwd())
49+
50+
-- setup dependencies
51+
local cmp = require("cmp")
52+
cmp.setup({
53+
mapping = cmp.mapping.preset.insert({
54+
["<C-b>"] = cmp.mapping.scroll_docs(-4),
55+
["<C-f>"] = cmp.mapping.scroll_docs(4),
56+
["<C-Space>"] = cmp.mapping.complete(),
57+
["<C-e>"] = cmp.mapping.abort(),
58+
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
59+
}),
60+
sources = cmp.config.sources({
61+
-- your other source
62+
{ name = "papis" },
63+
}),
64+
})
65+
66+
-- remap leader
67+
vim.g.mapleader = " "
68+
69+
---Sets up papis
70+
---@param opts table? Custom configuration options
71+
---@param autostart? boolean? Enable autostart (defaults to `true`)
72+
---@param rm_db? boolean? Delete db (defaults to `false`)
73+
function _Load_papis(opts, rm_db)
74+
local db_path = vim.fn.stdpath("cache") .. "/papis_db/papis-nvim-test.sqlite3"
75+
local default_config = {
76+
enable_modules = {
77+
["debug"] = true,
78+
["testing"] = true,
79+
},
80+
enable_keymaps = true,
81+
db_path = vim.fn.stdpath("cache") .. "/papis_db/papis-nvim-test.sqlite3",
82+
}
83+
local new_config = vim.tbl_deep_extend("force", default_config, opts or {})
84+
local init_result = require("papis").setup(new_config)
85+
86+
-- remove previous db
87+
if rm_db then
88+
os.remove(db_path)
89+
end
90+
91+
return init_result
92+
end
93+
EOF
94+
'';
95+
});
96+
in {
97+
neovim-with-papis = mkNvimMinimal final.neovim-unwrapped;
98+
}

nix/plugin-overlay.nix

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
name,
3+
self,
4+
}: final: prev: let
5+
papis-nvim-luaPackage-override = luaself: luaprev: {
6+
papis-nvim = luaself.callPackage ({
7+
buildLuarocksPackage,
8+
lua,
9+
luaOlder,
10+
nui-nvim,
11+
sqlite,
12+
plenary-nvim,
13+
pathlib-nvim,
14+
}:
15+
buildLuarocksPackage {
16+
pname = name;
17+
version = "scm-1";
18+
knownRockspec = "${self}/papis.nvim-scm-1.rockspec";
19+
disabled = luaOlder "5.1";
20+
propagatedBuildInputs = [
21+
nui-nvim
22+
sqlite
23+
plenary-nvim
24+
pathlib-nvim
25+
];
26+
src = self;
27+
}) {};
28+
};
29+
30+
lua5_1 = prev.lua5_1.override {
31+
packageOverrides = papis-nvim-luaPackage-override;
32+
};
33+
lua51Packages = prev.lua51Packages // final.lua5_1.pkgs;
34+
luajit = prev.luajit.override {
35+
packageOverrides = papis-nvim-luaPackage-override;
36+
};
37+
luajitPackages = prev.luajitPackages // final.luajit.pkgs;
38+
in {
39+
inherit
40+
lua5_1
41+
lua51Packages
42+
luajit
43+
luajitPackages
44+
;
45+
46+
vimPlugins =
47+
prev.vimPlugins
48+
// {
49+
papis-nvim = final.neovimUtils.buildNeovimPlugin {
50+
pname = name;
51+
src = self;
52+
version = "dev";
53+
};
54+
};
55+
}

0 commit comments

Comments
 (0)