Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions ci/conform-nvim.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
vimPlugins,
writers,
lib,
writeText,
}:
lib.pipe "${vimPlugins.conform-nvim}/lua/conform/formatters" [
builtins.readDir
builtins.attrNames
(builtins.filter (lib.hasSuffix ".lua"))
(map (lib.removeSuffix ".lua"))
builtins.toJSON
(writeText "conform-formatters")
(writers.writeJSON "conform-formatters.json")
]
10 changes: 3 additions & 7 deletions ci/efmls-configs.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
lib,
writers,
vimPlugins,
writeText,
}:
let
tools = lib.trivial.importJSON "${vimPlugins.efmls-configs-nvim.src}/doc/supported-list.json";
tools = lib.importJSON "${vimPlugins.efmls-configs-nvim.src}/doc/supported-list.json";
languages = lib.attrNames tools;

toLangTools' = lang: kind: lib.map (lib.getAttr "name") (tools.${lang}.${kind} or [ ]);
Expand Down Expand Up @@ -54,8 +54,4 @@ let
};
};
in
writeText "efmls-configs-sources.nix" (
"# WARNING: DO NOT EDIT\n"
+ "# This file is generated with packages.<system>.efmls-configs-sources, which is run automatically by CI\n"
+ (lib.generators.toPretty { } sources)
)
writers.writeJSON "efmls-configs-sources.json" sources
24 changes: 10 additions & 14 deletions ci/generate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,21 @@ writeShellApplication {
shift
done

generate_nix() {
echo "$2"
cp "$1" "$generated_dir/$2.nix"
nixfmt "$generated_dir/$2.nix"
}

generate_json() {
echo "$2"
prettier --parser=json "$1" >"$generated_dir/$2.json"
# Get file part from filepath and remove hash prefix
output_name=$(basename "$1" | cut -d "-" -f "2-")
basename "$1" ".json"
prettier "$1" > "$generated_dir/$output_name"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside: directly calling prettier in the update-script probably isn't the best design. Really, we should be using our treefmt configuration, so that we also get any settings (etc). But doing that without having to evaluate the rest of nixvim's flake may be non-trivial.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree but out of scope for this PR. Though in practice our treefmt prettier is the same as this one for JSON files but of course this would help keep it in sync in the future.

}

mkdir -p "$generated_dir"
generate_nix "${rust-analyzer-options}" "rust-analyzer"
generate_nix "${efmls-configs-sources}" "efmls-configs"
generate_nix "${none-ls-builtins}" "none-ls"

generate_json "${conform-formatters}" "conform-formatters"
generate_json "${lspconfig-servers}" "lspconfig-servers"
generate_json "${lspconfig-servers.unsupported}" "unsupported-lspconfig-servers"
generate_json "${rust-analyzer-options}"
generate_json "${efmls-configs-sources}"
generate_json "${none-ls-builtins}"
generate_json "${conform-formatters}"
generate_json "${lspconfig-servers}"
generate_json "${lspconfig-servers.unsupported}"

if [ -n "$commit" ]; then
cd "$generated_dir"
Expand Down
16 changes: 6 additions & 10 deletions ci/none-ls.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
{
vimPlugins,
writers,
lib,
writeText,
}:
let
builtinSources = lib.trivial.importJSON "${vimPlugins.none-ls-nvim.src}/doc/builtins.json";
builtinSourceNames = lib.mapAttrs (_: lib.attrNames) builtinSources;
in
writeText "none-ls-sources.nix" (
"# WARNING: DO NOT EDIT\n"
+ "# This file is generated with packages.<system>.none-ls-builtins, which is run automatically by CI\n"
+ (lib.generators.toPretty { } builtinSourceNames)
)
lib.pipe "${vimPlugins.none-ls-nvim.src}/doc/builtins.json" [
lib.importJSON
(lib.mapAttrs (_: lib.attrNames))
(writers.writeJSON "none-ls-sources.json")
]
2 changes: 1 addition & 1 deletion ci/nvim-lspconfig/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pandoc,
jq,
}:
runCommand "lspconfig-servers"
runCommand "lspconfig-servers.json"
{
lspconfig = vimPlugins.nvim-lspconfig;
nativeBuildInputs = [
Expand Down
2 changes: 1 addition & 1 deletion ci/nvim-lspconfig/unsupported.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
I.e., files in the old `lua/lspconfig/configs/` directory, that aren't
present in the new `lsp/` directory.
*/
runCommand "unsupported-lspconfig-servers"
runCommand "unsupported-lspconfig-servers.json"
{
nativeBuildInputs = [ jq ];
lspconfig = vimPlugins.nvim-lspconfig;
Expand Down
24 changes: 10 additions & 14 deletions ci/rust-analyzer/default.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#
# This derivation creates a Nix file that describes the Nix module that needs to be instantiated
# This derivation creates a JSON file that describes the Nix module that needs to be instantiated
#
# The create file is of the form:
#
# {
# "<rust-analyzer.option.name>" = {
# description = "<option description>";
# type = {
# kind = "<name of the type>";
# # Other values depending on the kind, like values for enum or subTypes for oneOf
# };
# };
# "<rust-analyzer.option.name>": {
# "description": "<option description>",
# "type": {
# "kind": "<name of the type>"
# <Other values depending on the kind, like values for enum or subTypes for oneOf>
# }
# }
# }
#
{
lib,
writers,
rust-analyzer,
writeText,
pandoc,
runCommand,
}:
Expand Down Expand Up @@ -227,8 +227,4 @@ let
}
) rustAnalyzerProperties;
in
writeText "rust-analyzer-options.nix" (
"# WARNING: DO NOT EDIT\n"
+ "# This file is generated with packages.<system>.rust-analyzer-options, which is run automatically by CI\n"
+ (lib.generators.toPretty { } (lib.mergeAttrsList rustAnalyzerOptions))
)
writers.writeJSON "rust-analyzer-options.json" (lib.mergeAttrsList rustAnalyzerOptions)
Loading