Skip to content

Commit

Permalink
Merge pull request #64 from DontEatOreo/fix-vencord-stable
Browse files Browse the repository at this point in the history
Add update logic for `pnpmDeps.hash`, Add `.gitignore`
  • Loading branch information
KaylorBen authored Jan 12, 2025
2 parents 1a8fb00 + a383eca commit f441cc9
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 10 deletions.
91 changes: 91 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Nix
.direnv
.envrc
outputs/
result-*
result
repl-result-*
/*.log
temp-wrapper.nix

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

### VisualStudioCode ###
.vscode/*

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
63 changes: 55 additions & 8 deletions update-vencord.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ trap cleanup EXIT
OWNER="Vendicated"
REPO="Vencord"

echo "Updating $ABS_NIX_FILE for $OWNER/$REPO ($UPDATE_TYPE)..."

# Create a wrapper that calls the package with the appropriate unstable flag
cat >temp-wrapper.nix <<EOF
{ pkgs ? import <nixpkgs> {} }:
Expand All @@ -38,28 +36,77 @@ cat >temp-wrapper.nix <<EOF
}
EOF

update_hash() {
local type="$1"
local new_hash="$2"
local prefix="${type}PnpmDeps"

sed -i "/^[[:space:]]*${prefix}[[:space:]]*=[[:space:]]*\"sha256-[A-Za-z0-9+/=]\{1,\}\"/c\ ${prefix} = \"sha256-${new_hash}\";" "$ABS_NIX_FILE"
}

update_pnpm_deps() {
local type="$1"
echo "Checking ${type}pnpmDeps"

local is_unstable
is_unstable=$([[ "$type" == "unstable" ]] && echo "true" || echo "false")

if nix-build --pure \
--expr "with import (builtins.getFlake \"nixpkgs\") {}; (callPackage ${ABS_NIX_FILE} { unstable = ${is_unstable}; }).pnpmDeps" \
--no-link &>/dev/null; then
echo "${type}pnpmDeps hash is already correct"
return 0
fi

echo "Current hash invalid. Calculating new pnpmDeps hash for ${type}..."

local build_output
build_output=$(nix-build --pure \
--expr "with import (builtins.getFlake \"nixpkgs\") {}; (callPackage ${ABS_NIX_FILE} { unstable = ${is_unstable}; }).pnpmDeps" \
--no-link 2>&1 || true)

local new_hash
new_hash=$(echo "$build_output" | grep -oP 'got:\s+sha256-\K[A-Za-z0-9+/]*=' || true)

if [ -n "$new_hash" ]; then
update_hash "$type" "$new_hash"
echo "Updated ${type} pnpmDeps hash"

if nix-build --pure \
--expr "with import (builtins.getFlake \"nixpkgs\") {}; (callPackage ${ABS_NIX_FILE} { unstable = ${is_unstable}; }).pnpmDeps" \
--no-link &>/dev/null; then
echo "Verification successful - new hash works"
return 0
else
echo "Error: New hash verification failed"
return 1
fi
else
echo "Failed to extract new pnpmDeps hash"
return 1
fi
}

if [ "$UPDATE_TYPE" = "stable" ]; then
# For stable versions, we're getting latest tag and update
echo "Fetching latest stable version..."
update_pnpm_deps "stable"
if ! nix-update --version-regex 'v(.*)' \
--url "https://github.com/$OWNER/$REPO" \
--format \
-f ./temp-wrapper.nix \
--override-filename "$ABS_NIX_FILE" \
"${REPO}"; then
echo "Failed to update stable version"
exit 1
echo "Failed to update stable version, updating pnpm deps..."
fi
else
# For unstable versions, we're just using branch update
echo "Fetching latest unstable version..."
update_pnpm_deps "unstable"
if ! nix-update --version=branch \
--url "https://github.com/$OWNER/$REPO" \
--format \
-f ./temp-wrapper.nix \
--override-filename "$ABS_NIX_FILE" \
"${REPO}"; then
echo "Failed to update unstable version"
exit 1
echo "Failed to update unstable version, updating pnpm deps..."
fi
fi
5 changes: 3 additions & 2 deletions vencord.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
let
stableVersion = "1.10.9";
stableHash = "sha256-sU2eJUUw7crvzMGGBQP6rbxISkL+S5nmT3QspyYXlRQ=";
stablePnpmDeps = "sha256-vVzERis1W3QZB/i6SQR9dQR56yDWadKWvFr+nLTQY9Y=";

unstableVersion = "1.10.9-unstable-2025-01-10";
unstableRev = "3243120baaa56f65866b532b731bc3426512c90e";
unstableHash = "sha256-ov1qLtBzLAO8k9pokOstEaeS/me+ElVvGzyFTSfaZM0=";

unstablePnpmDeps = "sha256-ZUwtNtOmxjhOBpYB7vuytunGBRSuVxdlQsceRmeyhhI=";
in
stdenv.mkDerivation (finalAttrs: {
pname = "vencord" + lib.optionalString unstable "-unstable";
Expand All @@ -36,7 +37,7 @@ stdenv.mkDerivation (finalAttrs: {

pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) pname src;
hash = "sha256-ZUwtNtOmxjhOBpYB7vuytunGBRSuVxdlQsceRmeyhhI=";
hash = if unstable then unstablePnpmDeps else stablePnpmDeps;
};

nativeBuildInputs = [
Expand Down

0 comments on commit f441cc9

Please sign in to comment.