add formatter to flake.nix

This commit is contained in:
DavHau 2023-05-29 09:34:51 +02:00
parent 05bef00479
commit 55f78d04fc

View File

@ -28,11 +28,11 @@
# }
nixosGenerate = { pkgs ? null, lib ? nixpkgs.lib, format, system ? null, specialArgs ? { }, modules ? [ ], customFormats ? {} }:
let
extraFormats = lib.mapAttrs' (name: value: lib.nameValuePair
(name)
(value // {
imports = ( value.imports or [] ++ [ ./format-module.nix ] );
let
extraFormats = lib.mapAttrs' (name: value: lib.nameValuePair
(name)
(value // {
imports = ( value.imports or [] ++ [ ./format-module.nix ] );
} )
) customFormats;
formatModule = builtins.getAttr format (self.nixosModules // extraFormats);
@ -58,6 +58,8 @@
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" "x86_64-darwin" "i686-linux" "aarch64-linux" "aarch64-darwin" ];
in {
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
packages = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages."${system}";
in rec {