Skip to content

Commit 0b4bc9d

Browse files
committed
Optimize checkout output sizes
1 parent 55cf0ca commit 0b4bc9d

File tree

4 files changed

+60
-50
lines changed

4 files changed

+60
-50
lines changed

flake.nix

+8-6
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,14 @@
8787
packages = self.packages.${system};
8888
plugins = pkgs.lazynvimPlugins;
8989

90+
buildPkg = pkg: pkgs.runCommand "${pkg.name}-build" { env.PKG = pkg; } "touch $out";
9091
addAttrsetPrefix = prefix: lib.attrsets.concatMapAttrs (n: v: { "${prefix}${n}" = v; });
9192
localTests = lib.attrsets.concatMapAttrs (
9293
pkgName: pkg:
9394
if (builtins.hasAttr "tests" pkg) then
94-
({ "${pkgName}-build" = pkg; } // (addAttrsetPrefix "${pkgName}-tests-" pkg.tests))
95+
({ "${pkgName}-build" = buildPkg pkg; } // (addAttrsetPrefix "${pkgName}-tests-" pkg.tests))
9596
else
96-
{ "${pkgName}-build" = pkg; }
97+
{ "${pkgName}-build" = buildPkg pkg; }
9798
) self.packages.${system};
9899
in
99100
{
@@ -105,12 +106,13 @@
105106
nativeBuildInputs = [ packages.lazy-nvim ];
106107
}
107108
''
108-
HOME="$PWD" nvim --headless "+Lazy! home" --startuptime out~ +q 2>&1 | tee err
109+
HOME="$PWD" nvim --headless "+Lazy! home" --startuptime out +q 2>&1 | tee err
109110
if grep "^E[0-9]\\+: " err; then
110111
cat err
111112
exit 1
112113
fi
113-
mv out~ "$out"
114+
cat out
115+
touch $out
114116
'';
115117

116118
LazyVimPlugins-outdated =
@@ -122,10 +124,10 @@
122124
}
123125
''
124126
diff --unified $actual $expected
125-
touch "$out"
127+
touch $out
126128
'';
127129

128-
LazyVim-extras-catppuccin = plugins.LazyVim.extras."lazyvim.plugins".catppuccin;
130+
LazyVim-extras-catppuccin = buildPkg plugins.LazyVim.extras."lazyvim.plugins".catppuccin;
129131
LazyVim-extras-all = pkgs.runCommandLocal "LazyVim-extras-all" {
130132
buildInputs = lib'.flattenDerivations plugins.LazyVim.extras;
131133
} "touch $out";

pkgs/lazy-nvim-config.nix

+46-39
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
lib,
33
callPackage,
4+
runCommand,
45
writeTextFile,
56
lazynvimPlugins,
67
lazynvimUtils,
@@ -19,49 +20,55 @@ writeTextFile {
1920
})
2021
'';
2122

22-
passthru.tests = {
23-
example = callPackage ./lazy-nvim-config.nix {
24-
luaRcContent = ''
25-
vim.g.mapleader = " "
26-
vim.g.maplocalleader = "\\"
27-
'';
23+
passthru.tests =
24+
let
25+
example = callPackage ./lazy-nvim-config.nix {
26+
luaRcContent = ''
27+
vim.g.mapleader = " "
28+
vim.g.maplocalleader = "\\"
29+
'';
2830

29-
# https://lazy.folke.io/spec/examples
30-
spec = [
31-
{
32-
url = "folke/tokyonight.nvim";
33-
lazy = false;
34-
priority = 1000;
35-
config = lib.generators.mkLuaInline ''
36-
function()
37-
-- load the colorscheme here
38-
vim.cmd([[colorscheme tokyonight]])
39-
end
40-
'';
41-
}
42-
{
43-
url = "folke/which-key.nvim";
44-
lazy = true;
45-
}
46-
{
47-
url = "nvim-neorg/neorg";
48-
ft = "norg";
49-
opts = {
50-
load = {
51-
"core.defaults" = { };
31+
# https://lazy.folke.io/spec/examples
32+
spec = [
33+
{
34+
url = "folke/tokyonight.nvim";
35+
lazy = false;
36+
priority = 1000;
37+
config = lib.generators.mkLuaInline ''
38+
function()
39+
-- load the colorscheme here
40+
vim.cmd([[colorscheme tokyonight]])
41+
end
42+
'';
43+
}
44+
{
45+
url = "folke/which-key.nvim";
46+
lazy = true;
47+
}
48+
{
49+
url = "nvim-neorg/neorg";
50+
ft = "norg";
51+
opts = {
52+
load = {
53+
"core.defaults" = { };
54+
};
5255
};
53-
};
54-
}
55-
];
56+
}
57+
];
5658

57-
opts = {
58-
install = {
59-
colorscheme = [ "habamax" ];
60-
};
61-
checker = {
62-
enabled = true;
59+
opts = {
60+
install = {
61+
colorscheme = [ "habamax" ];
62+
};
63+
checker = {
64+
enabled = true;
65+
};
6366
};
6467
};
68+
in
69+
{
70+
example = runCommand "lazy-nvim-config-example" {
71+
CONFIG = example;
72+
} "touch $out";
6573
};
66-
};
6774
}

pkgs/lazy-nvim.nix

+5-4
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ in
6666
in
6767
{
6868
help = runCommand "nvim-help" { nativeBuildInputs = [ neovim ]; } ''
69-
nvim --help 2>&1 >out~
70-
mv out~ "$out"
69+
nvim --help 2>&1
70+
touch $out
7171
'';
7272

7373
checkhealth = neovim-checkhealth.override {
@@ -120,12 +120,13 @@ in
120120
};
121121

122122
startuptime = runCommand "nvim-startuptime" { nativeBuildInputs = [ neovim ]; } ''
123-
HOME="$PWD" nvim --headless "+Lazy! home" --startuptime out~ +q 2>&1 | tee err
123+
HOME="$PWD" nvim --headless "+Lazy! home" --startuptime out +q 2>&1 | tee err
124124
if grep "^E[0-9]\\+: " err; then
125125
cat err
126126
exit 1
127127
fi
128-
mv out~ "$out"
128+
cat out
129+
touch $out
129130
'';
130131
};
131132
}

pkgs/neovim-checkhealth.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ runCommand "checkhealth-${pluginName}"
7171
echo "Expected at least one OK" >&2
7272
return 1
7373
else
74-
mv out.txt "$out"
74+
touch $out
7575
fi
7676
''

0 commit comments

Comments
 (0)