mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
This change converts redundant attribute assignments of the form `a = a;` or `a = someSet.a;` into cleaner `inherit` statements. This reduces verbosity and follows common Nix style for bringing attributes into scope. Statix Codes: W03 (manual_inherit), W04 (manual_inherit_from) Also include statix and the rule in our configuration.
49 lines
1.2 KiB
Nix
49 lines
1.2 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.programs.mr;
|
|
|
|
listToValue = lib.concatMapStringsSep ", " (lib.generators.mkValueStringDefault { });
|
|
|
|
iniFormat = pkgs.formats.ini { inherit listToValue; };
|
|
in
|
|
{
|
|
meta.maintainers = [ lib.maintainers.nilp0inter ];
|
|
|
|
options.programs.mr = {
|
|
enable = lib.mkEnableOption "mr, a tool to manage all your version control repositories";
|
|
|
|
package = lib.mkPackageOption pkgs "mr" { nullable = true; };
|
|
|
|
settings = lib.mkOption {
|
|
inherit (iniFormat) type;
|
|
default = { };
|
|
description = ''
|
|
Configuration written to {file}`$HOME/.mrconfig`
|
|
See <https://myrepos.branchable.com/>
|
|
for an example configuration.
|
|
'';
|
|
example = lib.literalExpression ''
|
|
{
|
|
foo = {
|
|
checkout = "git clone git@github.com:joeyh/foo.git";
|
|
update = "git pull --rebase";
|
|
};
|
|
".local/share/password-store" = {
|
|
checkout = "git clone git@github.com:myuser/password-store.git";
|
|
};
|
|
}
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
|
home.file.".mrconfig".source = iniFormat.generate ".mrconfig" cfg.settings;
|
|
};
|
|
}
|