mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
discord: add option for different config locations
Different discord branches use different config locations, but home-manager
uses `${configDir}/discord` unconditionally. This adds an option that changes
that to `${configDir}/${configName}`.
This commit is contained in:
@@ -16,6 +16,15 @@ in
|
||||
options.programs.discord = {
|
||||
enable = lib.mkEnableOption "Discord, the chat platform";
|
||||
package = lib.mkPackageOption pkgs "discord" { nullable = true; };
|
||||
configName = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "discord";
|
||||
example = "discordptb";
|
||||
description = ''
|
||||
Name of the subdirectory where {file}`settings.json` is linked under.
|
||||
For example discord-canary uses `discordcanary`.
|
||||
'';
|
||||
};
|
||||
settings = lib.mkOption {
|
||||
description = ''
|
||||
Configuration for Discord.
|
||||
@@ -62,7 +71,7 @@ in
|
||||
in
|
||||
{
|
||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||
home.file."${configDir}/discord/settings.json".source =
|
||||
home.file."${configDir}/${cfg.configName}/settings.json".source =
|
||||
jsonFormat.generate "discord-settings" cfg.settings;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{
|
||||
discord-basic-configuration = ./basic-configuration.nix;
|
||||
discord-non-default-config-dir = ./non-default-config-dir.nix;
|
||||
}
|
||||
|
||||
24
tests/modules/programs/discord/non-default-config-dir.nix
Normal file
24
tests/modules/programs/discord/non-default-config-dir.nix
Normal file
@@ -0,0 +1,24 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
config = {
|
||||
programs.discord = {
|
||||
enable = true;
|
||||
configName = "discordcanary";
|
||||
settings.DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING = true;
|
||||
};
|
||||
|
||||
nmt.script =
|
||||
let
|
||||
configDir =
|
||||
if pkgs.stdenv.hostPlatform.isLinux then
|
||||
"home-files/.config/discordcanary"
|
||||
else
|
||||
"home-files/Library/Application Support/discordcanary";
|
||||
in
|
||||
''
|
||||
assertFileExists "${configDir}/settings.json"
|
||||
assertFileContent "${configDir}/settings.json" \
|
||||
${./basic-settings.json}
|
||||
'';
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user