Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add local git uri support for userPlugins and the abbility for userPlugins to specify their own derivation #40

Open
wants to merge 120 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
bbc6eb0
Update README.md
KaylorBen Jul 18, 2024
2ebc6ea
Update README.md
KaylorBen Jul 18, 2024
f6a1568
support helper init
KaylorBen Jul 18, 2024
a51af0b
typo fix
KaylorBen Jul 18, 2024
96b7849
dev branch init
KaylorBen Jul 18, 2024
b673044
dev branch readme
KaylorBen Jul 18, 2024
a42863c
lib init
KaylorBen Jul 19, 2024
8fdfab3
redundant nixos modules removal
KaylorBen Jul 19, 2024
2031cc1
mkVencordCfg name
KaylorBen Jul 19, 2024
e14a411
mkVencordCfg impl
KaylorBen Jul 19, 2024
4389cf1
plugin def changes
KaylorBen Jul 19, 2024
0855f1f
callPackage
KaylorBen Jul 19, 2024
6127a4a
() fix
KaylorBen Jul 19, 2024
7c07640
() fix
KaylorBen Jul 19, 2024
2ed53ee
recursive impl
KaylorBen Jul 19, 2024
7762620
being incredibly safe with ()
KaylorBen Jul 19, 2024
cad6455
replace int enum values
KaylorBen Jul 19, 2024
95f5e27
doc work
KaylorBen Jul 22, 2024
869289c
seperating out doc files
KaylorBen Jul 22, 2024
424af88
renaming of docs
KaylorBen Jul 22, 2024
ab4c75b
plugin docs init
KaylorBen Jul 22, 2024
3198e76
fix README
KaylorBen Jul 22, 2024
1c29062
flake.lock is redundant
KaylorBen Jul 22, 2024
449d47e
trying new doc
KaylorBen Jul 22, 2024
b1a3b7f
standardized doc changes
KaylorBen Jul 22, 2024
7f13c8d
uSRBG -> USRBG
KaylorBen Jul 22, 2024
00dff3a
xSOverlay -> XSOverlay
KaylorBen Jul 22, 2024
8c80010
Update README.md
KaylorBen Jul 22, 2024
27d3f0e
all plugins for vesktop added
KaylorBen Jul 22, 2024
f934a83
vesktop enabled
KaylorBen Jul 22, 2024
4311516
scope fixes
KaylorBen Jul 22, 2024
e9e9c27
vesktop docs
KaylorBen Jul 22, 2024
65fd949
Update README.md
KaylorBen Jul 23, 2024
878176a
Update README.md
KaylorBen Jul 23, 2024
1d01382
enum types
KaylorBen Jul 23, 2024
d9ba0a9
Fix grammar error in the config options.
purrpurrn Jul 24, 2024
08addfb
Another grammar error,
purrpurrn Jul 25, 2024
cc7bc97
webSocketOverlay impl for XSOverlay
KaylorBen Aug 1, 2024
4debeca
Itunes integration for openInApp
KaylorBen Aug 1, 2024
1315b93
mentionAvatars add option to hide @ symbol
KaylorBen Aug 5, 2024
0d73ab4
youtubeAdblock added
KaylorBen Aug 5, 2024
6afb678
XSOverlay old api compat
KaylorBen Aug 5, 2024
eb0877e
maskedLinkPaste removed
KaylorBen Aug 5, 2024
b8c5751
typo
KaylorBen Aug 5, 2024
f31d802
{hm-module,docs/main.md}: add macOS support for vencord and vesktop
DontEatOreo Aug 13, 2024
9b25d47
custom plugin support
KaylorBen Aug 22, 2024
24cbf18
custom vencord package + some doc updates and such
KaylorBen Aug 22, 2024
76b4b70
custom package attempt
KaylorBen Aug 23, 2024
4530a0f
removed non existant script
KaylorBen Aug 23, 2024
6e742d5
extra options implimented
KaylorBen Aug 23, 2024
a6595b8
nixcord good I think
KaylorBen Aug 23, 2024
ac7156f
vencord bump to v1.9.8
KaylorBen Aug 24, 2024
042e96e
vencord updated options
KaylorBen Aug 24, 2024
7bb0d10
docs update
KaylorBen Aug 24, 2024
9556aee
Update main.md
KaylorBen Aug 25, 2024
05ec257
I can't spell
KaylorBen Aug 25, 2024
c515c70
fix (plugins): typo (silentMessageToggle): autoDiable -> autoDisable
NikSneMC Aug 28, 2024
40592d3
fix (plugins): typo (silentMessageToggle): persistentState -> persist…
NikSneMC Aug 28, 2024
74355de
feat: link quickCss.css file only when quickCSS is configured via nix
NikSneMC Aug 28, 2024
60a9a5b
refactor (hm-module): rename function from 964fbc3334f6fa875f6542bc99…
NikSneMC Aug 28, 2024
5683a8f
state + settings for vesktop/discord
KaylorBen Sep 4, 2024
5918304
quick docs for this
KaylorBen Sep 4, 2024
6bf1240
bump vencord to 10.1
KaylorBen Sep 5, 2024
60dfa88
a bunch of updated stuff
KaylorBen Sep 5, 2024
4ec773f
building correctly
KaylorBen Sep 5, 2024
9fcf031
ignore activities updated
KaylorBen Sep 6, 2024
1b9ccb8
fixed vencord config error
KaylorBen Sep 6, 2024
16b2fa8
fix (plugins): moyai
NikSneMC Sep 7, 2024
1ef2206
updated to 1.10.2
KaylorBen Sep 24, 2024
2b25155
1-line errors much better
KaylorBen Sep 24, 2024
ddab030
update 1.10.3
KaylorBen Oct 4, 2024
f20348b
default.nix
KaylorBen Oct 4, 2024
56e2f56
lockfile fixed
KaylorBen Oct 4, 2024
fa8cd0c
move things around
KaylorBen Oct 4, 2024
3c3ed23
fixes
KaylorBen Oct 4, 2024
4e53e8b
1.10.4 update
KaylorBen Oct 16, 2024
145bbc0
Fix plugin name (plugins.nix)
Soikr Oct 7, 2024
c9e829c
`builtins.getEnv "HOME"` -> `config.home.homeDirectory`
DontEatOreo Oct 14, 2024
3b34710
1.10.5 update + pnpm hash change
Soikr Oct 24, 2024
dcc3003
package update
KaylorBen Oct 24, 2024
107632d
Revert "package update"
AwesomeQubic Oct 25, 2024
07f82cf
Fix typo in docs
SystematicError Nov 2, 2024
71f5fdd
Fix typo in option description
SystematicError Nov 2, 2024
656f723
Fix typo in option name
SystematicError Nov 3, 2024
73ca2be
{docs/plugins.md,plugins.nix}: add plugin `fixImagesQuality`
DontEatOreo Oct 24, 2024
d81eaa2
{docs/plugins.md,lib,plugins}: `pronounDB` -> `userMessagesPronouns`
DontEatOreo Oct 24, 2024
6176cf5
warnings: add deprecation notice for `pronounDB`
DontEatOreo Oct 24, 2024
4582bed
just some convention stuff
KaylorBen Nov 5, 2024
93ef2ae
vencord: 1.10.5 -> 1.10.6
DontEatOreo Nov 6, 2024
bbbe26f
hm-module: add `discord.vencord.package`
DontEatOreo Nov 8, 2024
ed3d0b6
docs/main.md: add docs for `programs.nixcord.discord.vencord.package`
DontEatOreo Nov 8, 2024
6da3658
README.md: add a warning for `programs.nixcord.discord.vencord.package`
DontEatOreo Nov 8, 2024
33ffe5d
hm-module.nix: format with `nixfmt-rfc-style`
DontEatOreo Nov 14, 2024
97a97d0
lib.nix: format with `nixfmt-rfc-style`
DontEatOreo Nov 14, 2024
a8f4570
plugins.nix: format with `nixfmt-rfc-style`
DontEatOreo Nov 14, 2024
c6aa98f
warnings.nix: format with `nixfmt-rfc-style`
DontEatOreo Nov 14, 2024
014d82d
default.nix: format with `nixfmt-rfc-style`
DontEatOreo Nov 14, 2024
337a8e4
vencord.nix: 1.10.6 -> 1.10.7
DontEatOreo Nov 14, 2024
9b345a9
plugins.nix: `with lib;` -> `let inherit (lib) ...; in ...`
DontEatOreo Nov 15, 2024
d20898d
.git-blame-ignore-revs: init
DontEatOreo Nov 15, 2024
8ca6fa0
treefmt format
KaylorBen Nov 18, 2024
61980f9
input
KaylorBen Nov 18, 2024
e381893
formatted
KaylorBen Nov 18, 2024
fb168b9
hm-module.nix: drop option `vencord.enable`
DontEatOreo Nov 15, 2024
9d5dc01
Update warnings.nix
Soikr Nov 23, 2024
717c9fb
Did some cleanup, simplification, and added more git options, also ad…
SpiderUnderUrBed Oct 26, 2024
a6e4793
Merge branch 'main' into main
SpiderUnderUrBed Jan 24, 2025
935a6c3
Update hm-module.nix to reflect the changes
SpiderUnderUrBed Jan 24, 2025
8eeec40
vencord-unstable: 43501ba -> ea1e961
github-actions[bot] Jan 28, 2025
85cc320
vencord-unstable: ea1e961 -> a2213d4
github-actions[bot] Jan 29, 2025
a8fd4fe
vencord-unstable: a2213d4 -> 240195f
github-actions[bot] Jan 30, 2025
f60b8b7
vencord: 1.11.2 -> 1.11.3
github-actions[bot] Jan 30, 2025
560bcae
vencord-unstable: 240195f -> 8fccda4
github-actions[bot] Jan 30, 2025
99a4bab
vencord-unstable: 8fccda4 -> a492f76
github-actions[bot] Jan 30, 2025
391e469
vencord-unstable: a492f76 -> 4f5ebec
github-actions[bot] Feb 1, 2025
7fe35f8
vencord-unstable: 4f5ebec -> 6cccb54
github-actions[bot] Feb 2, 2025
4497fa2
vencord: 1.11.3 -> 1.11.4
github-actions[bot] Feb 6, 2025
e08207c
vencord-unstable: 6cccb54 -> 848c229
github-actions[bot] Feb 7, 2025
21e7516
vencord-unstable: 848c229 -> fcf8690
github-actions[bot] Feb 8, 2025
7dc7de5
vencord-unstable: fcf8690 -> 205e07d
github-actions[bot] Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ not be possible.

## Disclaimer
Using Vencord violates Discord's terms of service. Read more about
it at [their github](https://github.com/Vendicated/Vencord)
it at [their github](https://github.com/Vendicated/Vencord)
2 changes: 1 addition & 1 deletion docs/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,4 @@ programs.nixcord.vesktop.settings
programs.nixcord.vesktop.state
# Settings to be placed in vesktop.configDir/state.json
# type: attrs
```
```
2 changes: 1 addition & 1 deletion docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -2003,4 +2003,4 @@ programs.nixcord.config.plugins.webRichPresence.enable
```nix
programs.nixcord.config.plugins.webScreenShareFixes.enable
# Removes 2500kbps bitrate cap on chromium and vesktop clients.
```
```
2 changes: 1 addition & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

178 changes: 128 additions & 50 deletions hm-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
}:
let
cfg = config.programs.nixcord;

inherit (lib)
mkEnableOption
mkOption
Expand All @@ -16,36 +15,122 @@ let
attrsets
lists
;

vencordPkgs = pkgs.callPackage ./vencord.nix { unstable = cfg.discord.vencord.unstable; };

applyPostPatch = pkg: pkg.overrideAttrs (oldAttrs: {
postPatch = ''
ln -s ${userPluginsDirectory} src/userplugins
'';
});

patchedVencord = (applyPostPatch vencordPkgs);

dop = with types; coercedTo package (a: a.outPath) pathInStore;

recursiveUpdateAttrsList =
list:
if (builtins.length list <= 1) then
(builtins.elemAt list 0)
regexDir = "^/.*$";

# Define regular expressions for GitHub and Git URLs
regexGithub = "github:([[:alnum:].-]+)/([[:alnum:]/-]+)/([0-9a-f]{40})";
regexGit = "git[+]file:///([^/]+/)*([^/?]+)(\\?ref=[a-f0-9]{40})?$";

# Define coercion functions for GitHub and Git
coerceGithub = value: let
matches = builtins.match regexGithub value;
owner = builtins.elemAt matches 0;
repo = builtins.elemAt matches 1;
rev = builtins.elemAt matches 2;
in builtins.fetchGit {
url = "https://github.com/${owner}/${repo}";
inherit rev;
};

coerceGit = value: let
# Match using regex, assuming regexGit is defined and captures groups correctly
matches = builtins.match regexGit value;

# Set rev only if matches are found
rev = if matches != null then
let
rawRev = builtins.elemAt matches 2;
in
if rawRev != null && builtins.substring 0 5 rawRev == "?ref="
then builtins.substring 5 (builtins.stringLength rawRev) rawRev
else null
else null;

# Set filepath only if matches are found
filepath = if matches != null then
let
startOffset = 4; # Remove 4 characters from the beginning
endOffset = 45; # Remove 45 characters from the end
fullLength = builtins.stringLength value;
adjustedPathLength = fullLength - startOffset - endOffset;
in
builtins.substring startOffset adjustedPathLength value
else null;

in if filepath != null then
# Call fetchGit only if filepath is valid
builtins.fetchGit (
let
# Only include rev if it's non-null and non-empty
revCondition = if rev != null && rev != "" then { rev = rev; } else {};
in {
url = filepath;
ref = "main";
} // revCondition
)
else
throw "Failed to extract a valid filepath from the given value";

pluginMapper = plugin:
if builtins.match regexGithub plugin != null then
coerceGithub plugin
else if builtins.match regexGit plugin != null then
coerceGit plugin
else if builtins.match regexDir plugin != null then
# If it's a directory, treat it as a path in the Nix store or simply as a directory path
builtins.path {
name = "plugin";
path = builtins.toPath plugin;
}
else if lib.attrsets.isDerivation plugin then
plugin
else
recursiveUpdateAttrsList (
[
(attrsets.recursiveUpdate (builtins.elemAt list 0) (builtins.elemAt list 1))
]
++ (lists.drop 2 list)
);
builtins.path {
name = "plugin";
path = builtins.toPath plugin;
};

applyPostPatch =
pkg:
pkg.overrideAttrs {
postPatch = lib.concatLines (
lib.optional (cfg.userPlugins != { }) "mkdir -p src/userplugins"
++ lib.mapAttrsToList (
name: path:
"ln -s ${lib.escapeShellArg path} src/userplugins/${lib.escapeShellArg name} && ls src/userplugins"
) cfg.userPlugins
);
};

defaultVencord = applyPostPatch (
pkgs.callPackage ./vencord.nix { unstable = cfg.discord.vencord.unstable; }
);
recursiveUpdateAttrsList = list:
if (builtins.length list <= 1) then (builtins.elemAt list 0) else
recursiveUpdateAttrsList ([
(attrsets.recursiveUpdate (builtins.elemAt list 0) (builtins.elemAt list 1))
] ++ (lists.drop 2 list));

pluginDerivations = lib.mapAttrs (_: plugin: pluginMapper plugin) cfg.userPlugins;
apiPath = vencordPkgs.src;
buildDirs = pluginDerivations: lib.mapAttrsToList (name: pluginDir:
let
fullPath = "${pluginDir}";

# Check for a Nix expression and build if present
buildIfExists = if builtins.pathExists "${fullPath}/default.nix" || builtins.pathExists "${fullPath}/shell.nix" then
import fullPath {
inherit pkgs;
}

else
pluginDir;
in
# Return an attribute set with a `name` and `path` for linkFarm
{ name = name; path = buildIfExists; }
) pluginDerivations;
# Build the user plugins directory with linkFarm
userPluginsDirectory = pkgs.linkFarm "userPlugins" (buildDirs pluginDerivations);

in
{
options.programs.nixcord = {
Expand Down Expand Up @@ -84,7 +169,7 @@ in
};
package = mkOption {
type = types.package;
default = defaultVencord;
default = patchedVencord;
description = ''
The Vencord package to use
'';
Expand Down Expand Up @@ -230,30 +315,23 @@ in
for both vencord and vesktop
'';
};
userPlugins =
let
regex = "github:([[:alnum:].-]+)/([[:alnum:]/-]+)/([0-9a-f]{40})";
coerce =
value:
let
matches = builtins.match regex value;
owner = builtins.elemAt matches 0;
repo = builtins.elemAt matches 1;
rev = builtins.elemAt matches 2;
in
builtins.fetchGit {
url = "https://github.com/${owner}/${repo}";
inherit rev;
};
in
mkOption {
type = with types; attrsOf (coercedTo (strMatching regex) coerce dop);
description = "User plugin to fetch and install. Note that any json required must be enabled in extraConfig";
default = { };
example = {
someCoolPlugin = "github:someUser/someCoolPlugin/someHashHere";
};
userPlugins = lib.mkOption {
description = "User plugin to fetch and install. Note that any JSON required must be enabled in extraConfig.";

# Define the type of userPlugins with validation
type = types.attrsOf (types.oneOf [
(types.strMatching regexGithub) # GitHub URL pattern
(types.strMatching regexGit) # Git URL pattern
types.package # Nix packages
types.path # Nix paths
]);

# Example usage of the userPlugins option
example = {
someCoolPlugin = "github:someUser/someCoolPlugin/someHashHere"; # GitHub example
anotherCoolPlugin = "git+file:///path/to/repo?rev=abcdef1234567890abcdef1234567890abcdef12"; # File path example
};
};
parseRules = {
upperNames = mkOption {
type = with types; listOf str;
Expand Down Expand Up @@ -315,7 +393,7 @@ in
{
assertions = [
{
assertion = !(cfg.discord.vencord.package != defaultVencord && cfg.discord.vencord.unstable);
assertion = !(cfg.discord.vencord.package != patchedVencord && cfg.discord.vencord.unstable);
message = "programs.nixcord.discord.vencord: Cannot set both 'package' and 'unstable = true'. Choose one or the other.";
}
];
Expand Down
2 changes: 1 addition & 1 deletion plugins.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3337,4 +3337,4 @@ in
# Required for Vesktop
# Enabling doesn't cause problems for normal client
};
}
}
10 changes: 5 additions & 5 deletions vencord.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
}:

let
stableVersion = "1.11.2";
stableHash = "sha256-18CzWAcBotIdzXFPIptBo20KZxXDVhM7AwwlCnPz+Wk=";
stableVersion = "1.11.4";
stableHash = "sha256-A2vv3ubT+3ksqgLC+RvyGQGlw2GUD3qOyU0ZmQdbC3U=";
stablePnpmDeps = "sha256-ZUwtNtOmxjhOBpYB7vuytunGBRSuVxdlQsceRmeyhhI=";

unstableVersion = "1.11.2-unstable-2025-01-23";
unstableRev = "43501bad07632b586950b5bddfb81e5823786ce9";
unstableHash = "sha256-18CzWAcBotIdzXFPIptBo20KZxXDVhM7AwwlCnPz+Wk=";
unstableVersion = "1.11.4-unstable-2025-02-12";
unstableRev = "205e07d2c5b908f29d2a463845d7a1417a4678ad";
unstableHash = "sha256-A2vv3ubT+3ksqgLC+RvyGQGlw2GUD3qOyU0ZmQdbC3U=";
unstablePnpmDeps = "sha256-ZUwtNtOmxjhOBpYB7vuytunGBRSuVxdlQsceRmeyhhI=";
in
stdenv.mkDerivation (finalAttrs: {
Expand Down