Skip to content

Commit 0999d37

Browse files
committed
home/webcord: add multiple profiles
1 parent f761cdc commit 0999d37

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

home/applications/webcord.nix

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,36 @@ let
6262

6363
configFile = pkgsStable.writeText "config.json" (builtins.toJSON webcordConfig);
6464

65+
profileNames = [ "personal" "business" ];
66+
6567
mkNixPak = inputs.nixpak.lib.nixpak { lib = stableLib; pkgs = pkgsStable; };
6668
systemConfigOptionals = stableLib.optionals (systemConfig != null);
67-
wrappedWebcord = mkNixPak {
69+
wrappedWebcords = builtins.map (profileName: mkNixPak {
6870
config = { sloth, ... }: {
69-
app.package = pkgsUnstable.webcord;
71+
app.package = (pkgsStable.symlinkJoin {
72+
name = "webcord-${profileName}";
73+
paths = [ (pkgsUnstable.webcord.overrideAttrs {
74+
desktopItems = [];
75+
}) ];
76+
buildInputs = [ pkgsStable.makeWrapper ];
77+
postBuild = /* bash */ ''
78+
makeWrapper '${stableLib.getExe pkgsUnstable.webcord}' $out/bin/webcord-${profileName}
79+
'';
80+
meta.mainProgram = "webcord-${profileName}";
81+
}).overrideAttrs { desktopItems = []; };
7082
dbus.policies = {
7183
"org.freedesktop.portal.*" = "talk";
7284
"ca.desrt.dconf" = "talk";
7385
"org.a11y.Bus" = "talk";
7486
"org.freedesktop.Notifications" = "talk";
7587
};
76-
flatpak = {
77-
appId = "org.discord.webcord";
78-
desktopFile = "webcord.desktop";
79-
};
88+
flatpak.appId = "org.discord.webcord.${profileName}";
8089
locale.enable = true;
8190
etc.sslCertificates.enable = true;
8291
bubblewrap = {
8392
bindEntireStore = false;
8493
bind.rw = [
85-
(sloth.concat' sloth.xdgConfigHome "/WebCord")
94+
[(sloth.concat' sloth.xdgConfigHome "/webcord-${profileName}") (sloth.concat' sloth.xdgConfigHome "/WebCord")]
8695
(sloth.concat' sloth.runtimeDir "/doc") # For the Document portal
8796
[(sloth.concat' sloth.xdgCacheHome "/webcord/tmp") "/tmp"]
8897
];
@@ -112,17 +121,15 @@ let
112121
monitor = true;
113122
};
114123
};
115-
};
124+
}) profileNames;
116125
in
117126

118127
{
119-
home.persistence."${persistenceHomePath}/${name}".directories = stableLib.mkIf useImpermanence [
120-
".config/WebCord"
121-
];
128+
home.persistence."${persistenceHomePath}/${name}".directories = stableLib.mkIf useImpermanence (stableLib.map (name: ".config/webcord-${name}")profileNames);
122129

123-
home.activation.webcordConfig = lib.hm.dag.entryAfter ["writeBoundary"] ''
124-
$DRY_RUN_CMD ${stableLib.getExe' pkgsUnstable.coreutils "install"} -m=644 ${configFile} ${config.xdg.configHome}/WebCord/config.json
125-
'';
130+
home.activation.webcordConfig = lib.hm.dag.entryAfter ["writeBoundary"] (stableLib.strings.concatMapStringsSep "\n" (name: ''
131+
$DRY_RUN_CMD ${stableLib.getExe' pkgsUnstable.coreutils "install"} -m=644 ${configFile} ${config.xdg.configHome}/webcord-${name}/config.json
132+
'') profileNames);
126133

127134
xdg.configFile."WebCord/Themes/style.css".text = /* css */ ''
128135
@import "file://${inputs.discord-css}/style.css";
@@ -135,5 +142,5 @@ in
135142
'';
136143

137144

138-
home.packages = [ wrappedWebcord.config.env ];
145+
home.packages = builtins.map (webcord: webcord.config.env) wrappedWebcords;
139146
}

0 commit comments

Comments
 (0)