From 954bacb0a651066ad2279ec8f9a966b0855a899a Mon Sep 17 00:00:00 2001 From: DavHau Date: Tue, 31 Oct 2023 14:55:57 +0300 Subject: [PATCH] chore: more formatter into separate flake module --- flake.nix | 31 +------------------------------ modules/flake-parts/formatter.nix | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 30 deletions(-) create mode 100644 modules/flake-parts/formatter.nix diff --git a/flake.nix b/flake.nix index d4ad9dac..149fdf7e 100644 --- a/flake.nix +++ b/flake.nix @@ -35,35 +35,7 @@ nixpkgs, pre-commit-hooks, ... - } @ inp: let - l = nixpkgs.lib // builtins; - - inputs = inp; - - perSystem = { - config, - pkgs, - system, - inputs', - ... - }: { - apps = { - # passes through extra flags to treefmt - format.type = "app"; - format.program = let - path = l.makeBinPath [ - pkgs.alejandra - pkgs.python3.pkgs.black - ]; - in - l.toString - (pkgs.writeScript "format" '' - export PATH="${path}" - ${pkgs.treefmt}/bin/treefmt --clear-cache "$@" - ''); - }; - }; - in + } @ inputs: flake-parts.lib.mkFlake {inherit inputs;} { imports = [ ./modules/flake-parts/all-modules.nix @@ -75,6 +47,5 @@ "x86_64-darwin" "aarch64-darwin" ]; - inherit perSystem; }; } diff --git a/modules/flake-parts/formatter.nix b/modules/flake-parts/formatter.nix new file mode 100644 index 00000000..b2e4cc89 --- /dev/null +++ b/modules/flake-parts/formatter.nix @@ -0,0 +1,17 @@ +{ + perSystem = { + lib, + pkgs, + ... + }: { + formatter = let + path = lib.makeBinPath [ + pkgs.alejandra + pkgs.python3.pkgs.black + ]; + in (pkgs.writeScriptBin "format" '' + export PATH="${path}" + ${pkgs.treefmt}/bin/treefmt --clear-cache "$@" + ''); + }; +}