1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00
home-manager/modules/programs/sapling.nix
Austin Horstman 86402a17b6 treewide: flatten single file modules
Some files don't need nesting and can be root level again to reduce
conflicts with other PRs.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2025-06-23 16:20:26 -05:00

87 lines
2.1 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkIf mkOption types;
cfg = config.programs.sapling;
iniFormat = pkgs.formats.ini { };
in
{
meta.maintainers = [ lib.maintainers.pbar ];
options = {
programs.sapling = {
enable = lib.mkEnableOption "Sapling";
package = lib.mkPackageOption pkgs "sapling" { nullable = true; };
userName = mkOption {
type = types.str;
description = "Default user name to use.";
};
userEmail = mkOption {
type = types.str;
description = "Default user email to use.";
};
aliases = mkOption {
type = types.attrsOf types.str;
default = { };
description = "Sapling aliases to define.";
};
extraConfig = mkOption {
type = types.attrsOf types.anything;
default = { };
description = "Additional configuration to add.";
};
iniContent = mkOption {
type = iniFormat.type;
internal = true;
};
};
};
config = mkIf cfg.enable (
lib.mkMerge [
{
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
programs.sapling.iniContent.ui = {
username = cfg.userName + " <" + cfg.userEmail + ">";
};
}
(mkIf (!pkgs.stdenv.isDarwin) {
xdg.configFile."sapling/sapling.conf".source = iniFormat.generate "sapling.conf" cfg.iniContent;
})
(mkIf (pkgs.stdenv.isDarwin) {
home.file."Library/Preferences/sapling/sapling.conf".source =
iniFormat.generate "sapling.conf" cfg.iniContent;
})
(mkIf (cfg.aliases != { }) {
programs.sapling.iniContent.alias = cfg.aliases;
})
(mkIf (lib.isAttrs cfg.extraConfig) {
programs.sapling.iniContent = cfg.extraConfig;
})
(mkIf (lib.isString cfg.extraConfig && !pkgs.stdenv.isDarwin) {
xdg.configFile."sapling/sapling.conf".text = cfg.extraConfig;
})
(mkIf (lib.isString cfg.extraConfig && pkgs.stdenv.isDarwin) {
home.file."Library/Preferences/sapling/sapling.conf".text = cfg.extraConfig;
})
]
);
}