1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-21 17:59:39 +01:00

helix: don't ignore extraConfig when no other settings (#7302)

Fix so that you can still generate `programs.helix.extraConfig` without
using `programs.helix.settings`. Useful particularly in the case of
`extraConfig = lib.readFile ./config.toml;`.
This commit is contained in:
crasm 2025-06-22 11:03:39 -04:00 committed by GitHub
parent 8638426397
commit 39b7903eab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 46 additions and 18 deletions

View file

@ -229,24 +229,31 @@ in
xdg.configFile = xdg.configFile =
let let
settings = { settings =
"helix/config.toml" = mkIf (cfg.settings != { }) { let
source = hasSettings = cfg.settings != { };
let hasExtraConfig = cfg.extraConfig != null;
configFile = tomlFormat.generate "config.toml" cfg.settings; in
extraConfigFile = pkgs.writeText "extra-config.toml" ("\n" + cfg.extraConfig); {
in "helix/config.toml" = mkIf (hasSettings || hasExtraConfig) {
pkgs.runCommand "helix-config.toml" { } '' source =
cat ${configFile} ${extraConfigFile} >> $out let
''; configFile = tomlFormat.generate "config.toml" cfg.settings;
extraConfigFile = pkgs.writeText "extra-config.toml" (
lib.optionalString hasSettings "\n" + cfg.extraConfig
);
in
pkgs.runCommand "helix-config.toml" { } ''
cat ${configFile} ${extraConfigFile} >> $out
'';
};
"helix/languages.toml" = mkIf (cfg.languages != { }) {
source = tomlFormat.generate "helix-languages-config" cfg.languages;
};
"helix/ignore" = mkIf (cfg.ignores != [ ]) {
text = lib.concatStringsSep "\n" cfg.ignores + "\n";
};
}; };
"helix/languages.toml" = mkIf (cfg.languages != { }) {
source = tomlFormat.generate "helix-languages-config" cfg.languages;
};
"helix/ignore" = mkIf (cfg.ignores != [ ]) {
text = lib.concatStringsSep "\n" cfg.ignores + "\n";
};
};
themes = lib.mapAttrs' ( themes = lib.mapAttrs' (
n: v: n: v:

View file

@ -1 +1,4 @@
{ helix-example-settings = ./example-settings.nix; } {
helix-example-settings = ./example-settings.nix;
helix-only-extraconfig = ./only-extraconfig.nix;
}

View file

@ -0,0 +1,2 @@
[editor]
auto-pairs = false

View file

@ -0,0 +1,16 @@
{ config, ... }:
{
programs.helix = {
enable = true;
extraConfig = ''
[editor]
auto-pairs = false
'';
};
nmt.script = ''
assertFileContent \
home-files/.config/helix/config.toml \
${./only-extraconfig-expected.toml}
'';
}