From bc3b99c4d90b08726dd919d94eb03563c949d08a Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 16 Dec 2024 13:42:46 +0100 Subject: [PATCH] dev/list-plugins: make it a proper package --- flake-modules/dev/default.nix | 5 +++- flake-modules/dev/devshell.nix | 5 ---- flake-modules/dev/list-plugins/default.nix | 30 +++++++++++++++++++ .../dev/{ => list-plugins}/list-plugins.py | 2 -- 4 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 flake-modules/dev/list-plugins/default.nix rename flake-modules/dev/{ => list-plugins}/list-plugins.py (99%) diff --git a/flake-modules/dev/default.nix b/flake-modules/dev/default.nix index 30aebc6b..9a8543b4 100644 --- a/flake-modules/dev/default.nix +++ b/flake-modules/dev/default.nix @@ -1,7 +1,10 @@ { lib, inputs, ... }: { imports = - [ ./devshell.nix ] + [ + ./devshell.nix + ./list-plugins + ] ++ lib.optional (inputs.git-hooks ? flakeModule) inputs.git-hooks.flakeModule ++ lib.optional (inputs.treefmt-nix ? flakeModule) inputs.treefmt-nix.flakeModule; diff --git a/flake-modules/dev/devshell.nix b/flake-modules/dev/devshell.nix index 7fb553d2..c11746cf 100644 --- a/flake-modules/dev/devshell.nix +++ b/flake-modules/dev/devshell.nix @@ -106,11 +106,6 @@ (cd "$doc_derivation"/share/doc && ${pkgs.lib.getExe pkgs.python3} ${./server.py}) ''; } - { - name = "list-plugins"; - command = ''${pkgs.python3.interpreter} ${./list-plugins.py} "$@"''; - help = "List plugins and get implementation infos"; - } { name = "locate-lsp-packages"; command = ''${pkgs.python3.interpreter} ${./locate-lsp-packages.py}''; diff --git a/flake-modules/dev/list-plugins/default.nix b/flake-modules/dev/list-plugins/default.nix new file mode 100644 index 00000000..69189c39 --- /dev/null +++ b/flake-modules/dev/list-plugins/default.nix @@ -0,0 +1,30 @@ +{ + perSystem = + { + config, + lib, + inputs', + system, + pkgs, + ... + }: + { + packages.list-plugins = pkgs.writers.writePython3Bin "list-plugins" { + # Disable flake8 checks that are incompatible with the ruff ones + flakeIgnore = [ + # line too long + "E501" + # line break before binary operator + "W503" + ]; + } (builtins.readFile ./list-plugins.py); + + devshells.default.commands = [ + { + name = "list-plugins"; + command = ''${lib.getExe config.packages.list-plugins} "$@"''; + help = "List plugins and get implementation infos"; + } + ]; + }; +} diff --git a/flake-modules/dev/list-plugins.py b/flake-modules/dev/list-plugins/list-plugins.py similarity index 99% rename from flake-modules/dev/list-plugins.py rename to flake-modules/dev/list-plugins/list-plugins.py index 259f421e..695afdb7 100755 --- a/flake-modules/dev/list-plugins.py +++ b/flake-modules/dev/list-plugins/list-plugins.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python3 - import glob import re from argparse import ArgumentParser, RawTextHelpFormatter