1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-31 04:04:32 +00:00
This commit is contained in:
Robin Stumm 2025-03-30 19:29:19 +02:00 committed by GitHub
commit 396694ff38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 22 deletions

View file

@ -6,10 +6,10 @@ let
cfg = config.programs.broot;
tomlFormat = pkgs.formats.toml { };
jsonFormat = pkgs.formats.json { };
settingsModule = {
freeformType = tomlFormat.type;
freeformType = jsonFormat.type;
options = {
modal = mkEnableOption "modal (vim) mode";
@ -183,7 +183,7 @@ in {
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."broot" = {
xdg.configFile.broot = {
recursive = true;
source = pkgs.symlinkJoin {
name = "xdg.configFile.broot";
@ -194,31 +194,26 @@ in {
# Dummy file to prevent broot from trying to reinstall itself
(pkgs.writeTextDir "launcher/installed-v1" "")
];
postBuild = ''
ln -s ${
tomlFormat.generate "broot-config" cfg.settings
} $out/conf.toml
# Remove conf.hjson, whose content has been merged into programs.broot.settings
rm $out/conf.hjson
${lib.getExe pkgs.jq} --slurp add > $out/conf.hjson \
<(${
lib.getExe pkgs.hjson-go
} -c ${cfg.package.src}/resources/default-conf/conf.hjson) \
${jsonFormat.generate "broot-config.json" cfg.settings}
'';
};
};
programs.broot.settings = builtins.fromJSON (builtins.readFile
(pkgs.runCommand "default-conf.json" {
nativeBuildInputs = [ pkgs.hjson-go ];
}
"hjson-cli -c ${cfg.package.src}/resources/default-conf/conf.hjson > $out"));
programs = {
bash.initExtra = mkIf cfg.enableBashIntegration (shellInit "bash");
programs.bash.initExtra = mkIf cfg.enableBashIntegration (shellInit "bash");
zsh.initContent = mkIf cfg.enableZshIntegration (shellInit "zsh");
programs.zsh.initContent = mkIf cfg.enableZshIntegration (shellInit "zsh");
fish.shellInit = mkIf cfg.enableFishIntegration (shellInit "fish");
programs.fish.shellInit = mkIf cfg.enableFishIntegration (shellInit "fish");
programs.nushell.extraConfig =
mkIf cfg.enableNushellIntegration (shellInit "nushell");
nushell.extraConfig =
mkIf cfg.enableNushellIntegration (shellInit "nushell");
};
};
}

View file

@ -9,7 +9,7 @@
nixpkgs.overlays = [ (self: super: { inherit (realPkgs) broot hjson-go; }) ];
nmt.script = ''
assertFileExists home-files/.config/broot/conf.toml
assertFileContains home-files/.config/broot/conf.toml 'modal = true'
assertFileExists home-files/.config/broot/conf.hjson
assertFileContains home-files/.config/broot/conf.hjson '"modal": true'
'';
}