mirror of
https://github.com/nix-community/home-manager.git
synced 2026-09-15 11:19:19 +00:00
56 lines
1.4 KiB
Nix
56 lines
1.4 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
name = "flake-edit";
|
|
cfg = config.programs.${name};
|
|
tomlFormat = pkgs.formats.toml { };
|
|
configFile = "config.toml";
|
|
configDir =
|
|
if pkgs.stdenv.hostPlatform.isDarwin then "Library/Application Support" else config.xdg.configHome;
|
|
configPath = "${name}/${configFile}";
|
|
in
|
|
{
|
|
meta.maintainers = with lib.maintainers; [ malix ];
|
|
|
|
options.programs.${name} = {
|
|
enable = lib.mkEnableOption name;
|
|
|
|
package = lib.mkPackageOption pkgs name { nullable = true; };
|
|
|
|
settings = lib.mkOption {
|
|
inherit (tomlFormat) type;
|
|
default = { };
|
|
example = {
|
|
follow = {
|
|
ignore = [
|
|
"systems"
|
|
"crane.flake-utils"
|
|
];
|
|
transitive_min = 2;
|
|
aliases = {
|
|
nixpkgs = [ "nixpkgs-lib" ];
|
|
};
|
|
max_depth = 1;
|
|
};
|
|
};
|
|
description = ''
|
|
Configuration written to {file}`$XDG_CONFIG_HOME/${configPath}` on Linux or
|
|
{file}`$HOME/Library/Application Support/${configPath}` on Darwin.
|
|
See <https://github.com/a-kenji/${name}#configuration> for documentation.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
|
|
|
home.file."${configDir}/${configPath}" = lib.mkIf (cfg.settings != { }) {
|
|
source = tomlFormat.generate configFile cfg.settings;
|
|
};
|
|
};
|
|
}
|