mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-21 09:49: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:
parent
8638426397
commit
39b7903eab
4 changed files with 46 additions and 18 deletions
|
|
@ -229,12 +229,19 @@ in
|
|||
|
||||
xdg.configFile =
|
||||
let
|
||||
settings = {
|
||||
"helix/config.toml" = mkIf (cfg.settings != { }) {
|
||||
settings =
|
||||
let
|
||||
hasSettings = cfg.settings != { };
|
||||
hasExtraConfig = cfg.extraConfig != null;
|
||||
in
|
||||
{
|
||||
"helix/config.toml" = mkIf (hasSettings || hasExtraConfig) {
|
||||
source =
|
||||
let
|
||||
configFile = tomlFormat.generate "config.toml" cfg.settings;
|
||||
extraConfigFile = pkgs.writeText "extra-config.toml" ("\n" + cfg.extraConfig);
|
||||
extraConfigFile = pkgs.writeText "extra-config.toml" (
|
||||
lib.optionalString hasSettings "\n" + cfg.extraConfig
|
||||
);
|
||||
in
|
||||
pkgs.runCommand "helix-config.toml" { } ''
|
||||
cat ${configFile} ${extraConfigFile} >> $out
|
||||
|
|
|
|||
|
|
@ -1 +1,4 @@
|
|||
{ helix-example-settings = ./example-settings.nix; }
|
||||
{
|
||||
helix-example-settings = ./example-settings.nix;
|
||||
helix-only-extraconfig = ./only-extraconfig.nix;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
[editor]
|
||||
auto-pairs = false
|
||||
16
tests/modules/programs/helix/only-extraconfig.nix
Normal file
16
tests/modules/programs/helix/only-extraconfig.nix
Normal 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}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue