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:
parent
1772e8fb83
commit
32b42d71b4
3 changed files with 35 additions and 1 deletions
|
|
@ -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}
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue