Skip to content

Commit

Permalink
google-java-format: add aosp-style, includes, excludes
Browse files Browse the repository at this point in the history
  • Loading branch information
sebaszv committed Nov 6, 2024
1 parent 746901b commit 8b2166b
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions programs/google-java-format.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,38 @@ in
options.programs.google-java-format = {
enable = lib.mkEnableOption "google-java-format";
package = lib.mkPackageOption pkgs "google-java-format" { };

aospStyle = lib.mkOption {
description = ''
Whether to use AOSP (Android Open Source Project) indentation.
In a few words, use 4-space indentation rather than the conventional
2-space indentation width that Google uses.
'';
type = lib.types.bool;
example = true;
default = false;
};

includes = lib.mkOption {
description = "Path/file patterns to include for google-java-format";
type = lib.types.listOf lib.types.str;
default = [ "*.java" ];
};
excludes = lib.mkOption {
description = "Path/file patterns to exclude for google-java-format";
type = lib.types.listOf lib.types.str;
default = [ ];
};
};

config = lib.mkIf cfg.enable {
settings.formatter.google-java-format = {
command = cfg.package;
options = [ "--replace" ];
includes = [ "*.java" ];
options = [ "--replace" ] ++ (lib.optional cfg.aospStyle "--aosp");

inherit (cfg)
includes
excludes;
};
};
}

0 comments on commit 8b2166b

Please sign in to comment.