push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
{
"serverVersion": "0.19.13",
"uiVersion": "0.19.13",
"serverHash": "sha256-EKZZsJ8B111z+5SC79arMQaPfhQBNX4uYXyRtU8yAJM=",
"serverCargoHash": "sha256-sMPLxuG3leCVHqTK4MD5F3RxbO7u6om/vb0opquoa3I=",
"uiHash": "sha256-SU/JS3LdSm4gEfwG9JXPH0WPzmT/8hiSEpuJdXpaywc=",
"uiPNPMDepsHash": "sha256-tuarUG1uKx6Q1O+rF6DHyK8MEseF9lKk34qtRWWScAg="
}

View File

@@ -0,0 +1,79 @@
{
lib,
stdenv,
rustPlatform,
fetchFromGitHub,
openssl,
libpq,
libiconv,
protobuf,
rustfmt,
nixosTests,
}:
let
pinData = lib.importJSON ./pin.json;
version = pinData.serverVersion;
in
rustPlatform.buildRustPackage rec {
inherit version;
pname = "lemmy-server";
src = fetchFromGitHub {
owner = "LemmyNet";
repo = "lemmy";
rev = version;
hash = pinData.serverHash;
fetchSubmodules = true;
};
preConfigure = ''
echo 'pub const VERSION: &str = "${version}";' > crates/utils/src/version.rs
'';
cargoHash = pinData.serverCargoHash;
buildInputs = [
libpq
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
libiconv
];
# Using OPENSSL_NO_VENDOR is not an option on darwin
# As of version 0.10.35 rust-openssl looks for openssl on darwin
# with a hardcoded path to /usr/lib/libssl.x.x.x.dylib
# https://github.com/sfackler/rust-openssl/blob/master/openssl-sys/build/find_normal.rs#L115
OPENSSL_LIB_DIR = "${lib.getLib openssl}/lib";
OPENSSL_INCLUDE_DIR = "${openssl.dev}/include";
PROTOC = "${protobuf}/bin/protoc";
PROTOC_INCLUDE = "${protobuf}/include";
nativeBuildInputs = [
protobuf
rustfmt
];
checkFlags = [
# test requires database access
"--skip=session_middleware::tests::test_session_auth"
# tests require network access
"--skip=scheduled_tasks::tests::test_nodeinfo_mastodon_social"
"--skip=scheduled_tasks::tests::test_nodeinfo_lemmy_ml"
];
passthru.updateScript = ./update.py;
passthru.tests.lemmy-server = nixosTests.lemmy;
meta = with lib; {
description = "🐀 Building a federated alternative to reddit in rust";
homepage = "https://join-lemmy.org/";
license = licenses.agpl3Only;
maintainers = with maintainers; [
happysalada
billewanick
georgyo
];
mainProgram = "lemmy_server";
};
}

View File

@@ -0,0 +1,97 @@
{
lib,
stdenvNoCC,
libsass,
nodejs,
pnpm_9,
fetchFromGitHub,
nixosTests,
vips,
}:
let
pinData = lib.importJSON ./pin.json;
in
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "lemmy-ui";
version = pinData.uiVersion;
src =
with finalAttrs;
fetchFromGitHub {
owner = "LemmyNet";
repo = pname;
rev = version;
fetchSubmodules = true;
hash = pinData.uiHash;
};
nativeBuildInputs = [
nodejs
pnpm_9.configHook
];
buildInputs = [
libsass
vips
];
extraBuildInputs = [ libsass ];
pnpmDeps = pnpm_9.fetchDeps {
inherit (finalAttrs) pname version src;
fetcherVersion = 1;
hash = pinData.uiPNPMDepsHash;
};
buildPhase = ''
runHook preBuild
pnpm build:prod
runHook postBuild
'';
# installPhase = ''
# runHook preInstall
# mkdir -p $out/{bin,lib/${finalAttrs.pname}}
# mv {dist,node_modules} $out/lib/${finalAttrs.pname}
# runHook postInstall
# '';
preInstall = ''
mkdir $out
cp -R ./dist $out
cp -R ./node_modules $out
'';
preFixup = ''
find $out -name libvips-cpp.so.42 -print0 | while read -d $'\0' libvips; do
echo replacing libvips at $libvips
rm $libvips
ln -s ${lib.getLib vips}/lib/libvips-cpp.so.42 $libvips
done
'';
distPhase = "true";
passthru.updateScript = ./update.py;
passthru.tests.lemmy-ui = nixosTests.lemmy;
passthru.commit_sha = finalAttrs.src.rev;
meta = with lib; {
description = "Building a federated alternative to reddit in rust";
homepage = "https://join-lemmy.org/";
license = licenses.agpl3Only;
maintainers = with maintainers; [
happysalada
billewanick
georgyo
];
inherit (nodejs.meta) platforms;
};
})

View File

@@ -0,0 +1,155 @@
#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3 python3.pkgs.semver nix-prefetch-github
from urllib.request import Request, urlopen
import dataclasses
import subprocess
import os.path
import semver
from typing import (
Optional,
Dict,
List,
)
import json
import os
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
NIXPKGS = os.path.abspath(os.path.join(SCRIPT_DIR, "../../../../"))
OWNER = "LemmyNet"
UI_REPO = "lemmy-ui"
SERVER_REPO = "lemmy"
@dataclasses.dataclass
class Pin:
serverVersion: str
uiVersion: str
serverHash: str = ""
serverCargoHash: str = ""
uiHash: str = ""
uiPNPMDepsHash: str = ""
filename: Optional[str] = None
def write(self) -> None:
if not self.filename:
raise ValueError("No filename set")
with open(self.filename, "w") as fd:
pin = dataclasses.asdict(self)
del pin["filename"]
json.dump(pin, fd, indent=2)
fd.write("\n")
def github_get(path: str) -> Dict:
"""Send a GET request to GitHub, optionally adding GITHUB_TOKEN auth header"""
url = f"https://api.github.com/{path.lstrip('/')}"
print(f"Retrieving {url}")
req = Request(url)
if "GITHUB_TOKEN" in os.environ:
req.add_header("authorization", f"Bearer {os.environ['GITHUB_TOKEN']}")
with urlopen(req) as resp:
return json.loads(resp.read())
def get_latest_release(owner: str, repo: str) -> str:
return github_get(f"/repos/{owner}/{repo}/releases/latest")["tag_name"]
def prefetch_github(owner: str, repo: str, rev: str) -> str:
"""Prefetch GitHub rev and return SRI hash"""
print(f"Prefetching {owner}/{repo}({rev})")
proc = subprocess.run(
["nix-prefetch-github", owner, repo, "--rev", rev, "--fetch-submodules"],
check=True,
stdout=subprocess.PIPE,
)
return json.loads(proc.stdout)["hash"]
def get_latest_tag(owner: str, repo: str, prerelease: bool = False) -> str:
"""Get the latest tag from a GitHub Repo"""
tags: List[str] = []
# As the GitHub API doesn't have any notion of "latest" for tags we need to
# collect all of them and sort so we can figure out the latest one.
i = 0
while i <= 100: # Prevent infinite looping
i += 1
resp = github_get(f"/repos/{owner}/{repo}/tags?page={i}")
if not resp:
break
# Filter out unparseable tags
for tag in resp:
try:
parsed = semver.Version.parse(tag["name"])
if (
semver.Version.parse(tag["name"])
and not prerelease
and parsed.prerelease
): # Filter out release candidates
continue
except ValueError:
continue
else:
tags.append(tag["name"])
# Sort and return latest
return sorted(tags, key=lambda name: semver.Version.parse(name))[-1]
def get_fod_hash(attr: str) -> str:
"""
Get fixed output hash for attribute.
This depends on a fixed output derivation with an empty hash.
"""
print(f"Getting fixed output hash for {attr}")
proc = subprocess.run(["nix-build", NIXPKGS, "-A", attr], stderr=subprocess.PIPE)
if proc.returncode != 1:
raise ValueError("Expected nix-build to fail")
# Iterate list in reverse order so we get the "got:" line early
for line in proc.stderr.decode().split("\n")[::-1]:
cols = line.split()
if cols and cols[0] == "got:":
return cols[1]
raise ValueError("No fixed output hash found")
def make_server_pin(pin: Pin, attr: str) -> None:
pin.serverHash = prefetch_github(OWNER, SERVER_REPO, pin.serverVersion)
pin.write()
pin.serverCargoHash = get_fod_hash(attr)
pin.write()
def make_ui_pin(pin: Pin, attr: str) -> None:
pin.uiHash = prefetch_github(OWNER, UI_REPO, pin.uiVersion)
pin.write()
pin.uiPNPMDepsHash = get_fod_hash(attr)
pin.write()
if __name__ == "__main__":
# Get server version
server_version = get_latest_tag(OWNER, SERVER_REPO)
# Get UI version (not always the same as lemmy-server)
ui_version = get_latest_tag(OWNER, UI_REPO)
pin = Pin(server_version, ui_version, filename=os.path.join(SCRIPT_DIR, "pin.json"))
make_server_pin(pin, "lemmy-server")
make_ui_pin(pin, "lemmy-ui")