mirror of
https://github.com/nix-community/home-manager
synced 2024-08-20 11:06:30 +02:00
Currently, dot directories and XDG base directories are used inconsistently in the Home Manager option declarations. This creates ambiguity for the user as to where the location of the file should be albeit this is rarely encountered in practice as it is sufficient to read upstream documentation. The rationale is to make declarations consistent and make a clear distinction between hardcoded and modular specifications. References to ~/.config in relevant nixpkgs modules were untouched as the location is hardcoded upstream[1]. Furthermore, modules of programs which do not follow XDG specifications were also untouched. Generalization of tilde(~) expansions to $HOME were also considered, however there isn't sufficient rationale despite the use of $HOME being more universal. The expansion is standardized in POSIX[2] and is essentially portable across all shells, thus there is no pragmatic value to introducing the change. [1] https://github.com/nixos/nixpkgs/blob/master/pkgs/top-level/impure.nix [2] https://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_01
91 lines
2.5 KiB
Nix
91 lines
2.5 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.programs.atuin;
|
|
|
|
tomlFormat = pkgs.formats.toml { };
|
|
|
|
in {
|
|
meta.maintainers = [ maintainers.hawkw ];
|
|
|
|
options.programs.atuin = {
|
|
enable = mkEnableOption "atuin";
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.atuin;
|
|
defaultText = literalExpression "pkgs.atuin";
|
|
description = "The package to use for atuin.";
|
|
};
|
|
|
|
enableBashIntegration = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
description = ''
|
|
Whether to enable Atuin's Bash integration. This will bind
|
|
<literal>ctrl-r</literal> to open the Atuin history.
|
|
'';
|
|
};
|
|
|
|
enableZshIntegration = mkEnableOption "Zsh integration" // {
|
|
default = true;
|
|
description = ''
|
|
Whether to enable Atuin's Zsh integration.
|
|
</para><para>
|
|
If enabled, this will bind <literal>ctrl-r</literal> and the up-arrow
|
|
key to open the Atuin history.
|
|
'';
|
|
};
|
|
|
|
settings = mkOption {
|
|
type = with types;
|
|
let
|
|
prim = oneOf [ bool int str ];
|
|
primOrPrimAttrs = either prim (attrsOf prim);
|
|
entry = either prim (listOf primOrPrimAttrs);
|
|
entryOrAttrsOf = t: either entry (attrsOf t);
|
|
entries = entryOrAttrsOf (entryOrAttrsOf entry);
|
|
in attrsOf entries // { description = "Atuin configuration"; };
|
|
default = { };
|
|
example = literalExpression ''
|
|
{
|
|
auto_sync = true;
|
|
sync_frequency = "5m";
|
|
sync_address = "https://api.atuin.sh";
|
|
search_mode = "prefix";
|
|
}
|
|
'';
|
|
description = ''
|
|
Configuration written to
|
|
<filename>$XDG_CONFIG_HOME/atuin/config.toml</filename>.
|
|
</para><para>
|
|
See <link xlink:href="https://github.com/ellie/atuin/blob/main/docs/config.md" /> for the full list
|
|
of options.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# Always add the configured `atuin` package.
|
|
home.packages = [ cfg.package ];
|
|
|
|
# If there are user-provided settings, generate the config file.
|
|
xdg.configFile."atuin/config.toml" = mkIf (cfg.settings != { }) {
|
|
source = tomlFormat.generate "atuin-config" cfg.settings;
|
|
};
|
|
|
|
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
|
source "${pkgs.bash-preexec}/share/bash/bash-preexec.sh"
|
|
eval "$(${cfg.package}/bin/atuin init bash)"
|
|
'';
|
|
|
|
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
|
eval "$(${cfg.package}/bin/atuin init zsh)"
|
|
'';
|
|
};
|
|
}
|