-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
92 lines (86 loc) · 3.16 KB
/
flake.nix
File metadata and controls
92 lines (86 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{
description = "A mutable install manager for Vencord";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
treefmt-nix.url = "github:numtide/treefmt-nix";
js-beautify-treewrapped.url = "github:notarin/js-beautify-treewrapped";
};
outputs = {
self,
nixpkgs,
flake-utils,
treefmt-nix,
js-beautify-treewrapped,
...
}:
flake-utils.lib.eachDefaultSystemPassThrough (
system: let
pkgs =
import nixpkgs {
inherit system;
config.allowUnfree = true;
}
// {
js-beautify-treewrapped = js-beautify-treewrapped.packages.${system}.default;
};
lib = pkgs.lib;
# Formatter config, we use treefmt. Config is found in `treefmt.nix`.
treefmt-config = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
in {
formatter.${system} = treefmt-config.config.build.wrapper;
checks.${system} = {
formatting = treefmt-config.config.build.check self;
};
packages.${system} = rec {
default = MuVe;
MuVe = pkgs.discord.overrideAttrs {
postInstall = ''
# We move the original app.asar to _app.asar because that is where
# Vencord expects it to be. The discord code still needs to be
# executed, so vencord runs the original app.asar from there after
# it sets up its own resources.
mv $out/opt/Discord/resources/app.asar $out/opt/Discord/resources/_app.asar
# The asar is just an archive, and thankfully we can just replace
# it with a directory and it'll read the package.json and run
# our index.js instead.
cp -r ${custom_asar} $out/opt/Discord/resources/app.asar
'';
};
custom_asar = let
# Fetching and patching sources
packageJson = builtins.readFile ./asar/package.json;
indexJs = builtins.readFile ./asar/index.js;
patchedIndexJs = builtins.replaceStrings ["~curl~"] [(lib.getExe pkgs.curl)] indexJs;
# Declaring what we pass in
package = packageJson;
index = patchedIndexJs;
in (
pkgs.runCommand "custom-asar" {
inherit package index;
} ''
# Setup workdir
echo -E "$index" > index.js
echo -E "$package" > package.json
# Package workdir to output
${lib.getExe pkgs.asar} p . $out
''
);
};
devShells.${system}.default = pkgs.mkShell {
shellHook = ''
oldHookDir=$(git config --local core.hooksPath)
if [ "$oldHookDir" != "$PWD/.githooks" ]; then
read -rp "Set git hooks to $PWD/.githooks? (y/n) " answer
if [ "$answer" = "y" ]; then
git config core.hooksPath "$PWD"/.githooks
echo "Set git hooks to $PWD/.githooks"
else
echo "Skipping git hooks setup"
fi
fi
'';
};
}
);
}