add glitch-soc module & package & misc

not me forgetting to commit
This commit is contained in:
Jill 2022-11-15 06:19:25 +01:00
parent d83fc92136
commit 27d13902e0
8 changed files with 3426 additions and 8 deletions

View File

@ -30,12 +30,13 @@ in {
# aether??? is that... reference.../.??? aether https://www.curseforge.com/minecraft/mc-mods/aether mod Curseforge minecraft Forge Patreon Chat twitter code license Assets license All rights reserved categories Last Updated apr 17 2021 Game Version 1.12.2 aether
aether = {
conf = {
packages = with pkgs; [ bat duf broot nftables tmux ];
packages = with pkgs; [ bat duf broot nftables tmux bottom ];
shell = pkgs.unstable.fish;
extraGroups = [ "wheel" "nix-users" "dotfiles" ];
initialHashedPassword = "!";
openssh.authorizedKeys.keys = fetchSSHKeys [
"aether@subsurface"
"aether@phone"
];
};
@ -50,7 +51,7 @@ in {
# oatmealine ?? is that a reference to jill oatmealine monoids from the beloved videogame franchise "oateamelin jill monoids???" .oat. zone??? from va11hall-a??? video game???? woman????? minecraft???????
oatmealine = {
conf = {
packages = with pkgs; [ bat tmux micro direnv nix-direnv ripgrep ];
packages = with pkgs; [ bat tmux micro direnv nix-direnv ripgrep _.glitch-soc ];
shell = pkgs.unstable.fish;
extraGroups = [ "wheel" "nix-users" "dotfiles" "yugoslavia" ];
initialHashedPassword = "!";
@ -120,8 +121,8 @@ in {
postgres.enable = true;
nextcloud = {
enable = false;
domain = "cloud.dark-firepit.dev";
enable = true;
domain = "nextcloud.dark-firepit.cloud";
};
gitea = {
@ -132,7 +133,7 @@ in {
matrix.conduit = {
enable = false;
domain = "matrix.aether.gay";
domain = "matrix.dark-firepit.cloud";
};
srb2k = with lib; with builtins; let
@ -196,7 +197,7 @@ in {
kmp_battleaccel on
maxsend max
fr_enabled off
khaosenable off
khaos enable off
wait 1
@ -248,8 +249,8 @@ in {
enable = true;
servers = {
"dark-firepit" = {
enable = true;
autoStart = true;
enable = false;
#autoStart = false;
openFirewall = true;
serverProperties = {
server-port = 25565;
@ -315,6 +316,11 @@ in {
};
};
glitch-soc = {
enable = true;
domain = "feditest.oat.zone";
};
wireguard = {
enable = true;
server = true;
@ -363,6 +369,9 @@ in {
"tac.yugoslavia.best".php = true;
"tac.yugoslavia.best".phpHandlePathing = true;
"pjsk.oat.zone".dataDir = "/var/www/pjsk.oat.zone";
"mayf.pink".dataDir = "/var/www/mayf.pink/public";
"mayf.pink".php = true;
"mayf.pink".phpHandlePathing = true;
};
nitter = {
@ -423,6 +432,14 @@ in {
'';
};
services.nginx.virtualHosts."nitter.oat.zone" = {
locations."/".extraConfig = ''
if ($http_user_agent = 'Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)') {
return 302 $scheme://fxtwitter.com$request_uri;
}
'';
};
security.doas = {
extraRules = [
{ users = [ "aether" ]; noPass = false; persist = true; keepEnv = true; }

View File

@ -0,0 +1,42 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.modules.services.glitch-soc;
in {
options.modules.services.glitch-soc = {
enable = mkOption {
type = types.bool;
default = false;
};
domain = mkOption {
type = types.str;
default = "feditest.oat.zone";
};
};
config = mkIf cfg.enable {
services = {
mastodon = {
enable = true;
configureNginx = true;
localDomain = cfg.domain;
package = pkgs._.glitch-soc;
smtp = {
fromAddress = "mastodon@${cfg.domain}";
user = "mastodon";
};
extraConfig = {
AUTHORIZED_FETCH = "false";
LIMITED_FEDERATION_MODE = "true";
MAX_TOOT_CHARS = "69420";
MAX_DISPLAY_NAME_CHARS = "32";
MAX_BIO_CHARS = "69420";
};
};
};
};
}

View File

@ -0,0 +1,132 @@
{ lib, stdenv, nodejs-slim, mkYarnPackage, fetchFromGitHub, bundlerEnv, nixosTests, pkgs
, yarn, callPackage, imagemagick, ffmpeg, file, ruby_3_0, writeShellScript
, fetchYarnDeps, fixup_yarn_lock
# Allow building a fork or custom version of Mastodon:
, pname ? "glitch-soc"
, version ? import ./version.nix
, srcOverride ? #pkgs.fetchFromGitHub {
#owner = "glitch-soc";
#repo = "mastodon";
#rev = "3f15326a05a926e9f001800a48ac2addbd3aa833";
#sha256 = "1m1agij9i2byiml02yq0h9w6f64jvy2y2ayjm880pg5xm638nqmk";
#}
/home/oatmealine/mastodon
, dependenciesDir ? ./. # Should contain gemset.nix, yarn.nix and package.json.
}:
stdenv.mkDerivation rec {
inherit pname version;
# Using overrideAttrs on src does not build the gems and modules with the overridden src.
# Putting the callPackage up in the arguments list also does not work.
src = if srcOverride != null then srcOverride else callPackage ./source.nix {};
mastodon-gems = bundlerEnv {
name = "${pname}-gems-${version}";
inherit version;
ruby = ruby_3_0;
gemdir = src;
gemset = dependenciesDir + "/gemset.nix";
# This fix (copied from https://github.com/NixOS/nixpkgs/pull/76765) replaces the gem
# symlinks with directories, resolving this error when running rake:
# /nix/store/451rhxkggw53h7253izpbq55nrhs7iv0-mastodon-gems-3.0.1/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/settings.rb:6:in `<module:Bundler>': uninitialized constant Bundler::Settings (NameError)
postBuild = ''
for gem in "$out"/lib/ruby/gems/*/gems/*; do
cp -a "$gem/" "$gem.new"
rm "$gem"
# needed on macOS, otherwise the mv yields permission denied
chmod +w "$gem.new"
mv "$gem.new" "$gem"
done
'';
};
mastodon-modules = stdenv.mkDerivation {
pname = "${pname}-modules";
inherit src version;
yarnOfflineCache = fetchYarnDeps {
yarnLock = "${src}/yarn.lock";
sha256 = "sha256-RQwtybEMwwAoW2DBqX42Q1gmvr12sFWzT2M32TGkOWY=";
};
nativeBuildInputs = [ fixup_yarn_lock nodejs-slim yarn mastodon-gems mastodon-gems.wrappedRuby ];
RAILS_ENV = "production";
NODE_ENV = "production";
buildPhase = ''
export HOME=$PWD
# This option is needed for openssl-3 compatibility
# Otherwise we encounter this upstream issue: https://github.com/mastodon/mastodon/issues/17924
#export NODE_OPTIONS=--openssl-legacy-provider
fixup_yarn_lock ~/yarn.lock
yarn config --offline set yarn-offline-mirror $yarnOfflineCache
yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress
patchShebangs ~/bin
patchShebangs ~/node_modules
# skip running yarn install
rm -rf ~/bin/yarn
OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder \
rails assets:precompile
yarn cache clean --offline
rm -rf ~/node_modules/.cache
'';
installPhase = ''
mkdir -p $out/public
cp -r node_modules $out/node_modules
cp -r public/assets $out/public
cp -r public/packs $out/public
'';
};
propagatedBuildInputs = [ imagemagick ffmpeg file mastodon-gems.wrappedRuby ];
buildInputs = [ mastodon-gems nodejs-slim ];
buildPhase = ''
ln -s ${mastodon-modules}/node_modules node_modules
ln -s ${mastodon-modules}/public/assets public/assets
ln -s ${mastodon-modules}/public/packs public/packs
patchShebangs bin/
for b in $(ls ${mastodon-gems}/bin/)
do
if [ ! -f bin/$b ]; then
ln -s ${mastodon-gems}/bin/$b bin/$b
fi
done
rm -rf log
ln -s /var/log/mastodon log
ln -s /tmp tmp
'';
installPhase = let
run-streaming = writeShellScript "run-streaming.sh" ''
# NixOS helper script to consistently use the same NodeJS version the package was built with.
${nodejs-slim}/bin/node ./streaming
'';
in ''
mkdir -p $out
cp -r * $out/
ln -s ${run-streaming} $out/run-streaming.sh
'';
passthru = {
tests.mastodon = nixosTests.mastodon;
updateScript = callPackage ./update.nix {};
};
meta = with lib; {
description = "Self-hosted, globally interconnected microblogging software based on ActivityPub";
homepage = "https://joinmastodon.org";
license = licenses.agpl3Plus;
platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
maintainers = with maintainers; [ happy-river erictapen izorkin ];
};
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
# This file was generated by pkgs.mastodon.updateScript.
{ fetchgit, applyPatches }: let
src = fetchgit {
url = "https://github.com/glitch-soc/mastodon.git";
rev = "3f15326a05a926e9f001800a48ac2addbd3aa833";
sha256 = "1m1agij9i2byiml02yq0h9w6f64jvy2y2ayjm880pg5xm638nqmk";
};
in applyPatches {
inherit src;
patches = [];
}

View File

@ -0,0 +1,98 @@
#!/usr/bin/env bash
set -e
URL=https://github.com/mastodon/mastodon.git
POSITIONAL=()
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--url)
URL="$2"
shift # past argument
shift # past value
;;
--ver)
VERSION="$2"
shift # past argument
shift # past value
;;
--rev)
REVISION="$2"
shift # past argument
shift # past value
;;
--patches)
PATCHES="$2"
shift # past argument
shift # past value
;;
*) # unknown option
POSITIONAL+=("$1")
shift # past argument
;;
esac
done
if [[ -z "$VERSION" || -n "$POSITIONAL" ]]; then
echo "Usage: update.sh [--url URL] --ver VERSION [--rev REVISION] [--patches PATCHES]"
echo "URL may be any path acceptable to 'git clone' and VERSION the"
echo "semantic version number. If VERSION is not a revision acceptable to"
echo "'git checkout', you must provide one in REVISION. If URL is not"
echo "provided, it defaults to https://github.com/mastodon/mastodon.git."
echo "PATCHES, if provided, should be one or more Nix expressions"
echo "separated by spaces."
exit 1
fi
if [[ -z "$REVISION" ]]; then
REVISION="$VERSION"
fi
rm -f gemset.nix version.nix source.nix
TARGET_DIR="$PWD"
WORK_DIR=$(mktemp -d)
# Check that working directory was created.
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
echo "Could not create temporary directory"
exit 1
fi
# Delete the working directory on exit.
function cleanup {
# Report errors, if any, from nix-prefetch-git
grep "fatal" $WORK_DIR/nix-prefetch-git.out >/dev/stderr || true
rm -rf "$WORK_DIR"
}
trap cleanup EXIT
echo "Fetching source code $REVISION from $URL"
JSON=$(nix-prefetch-git --url "$URL" --rev "$REVISION" 2> $WORK_DIR/nix-prefetch-git.out)
SHA=$(echo $JSON | jq -r .sha256)
FETCHED_SOURCE_DIR=$(grep '^path is' $WORK_DIR/nix-prefetch-git.out | sed 's/^path is //')
echo "Creating version.nix"
echo \"$VERSION\" | sed 's/^"v/"/' > version.nix
cat > source.nix << EOF
# This file was generated by pkgs.mastodon.updateScript.
{ fetchgit, applyPatches }: let
src = fetchgit {
url = "$URL";
rev = "$REVISION";
sha256 = "$SHA";
};
in applyPatches {
inherit src;
patches = [$PATCHES];
}
EOF
SOURCE_DIR="$(nix-build --no-out-link -E '(import <nixpkgs> {}).callPackage ./source.nix {}')"
echo "Creating gemset.nix"
bundix --lockfile="$SOURCE_DIR/Gemfile.lock" --gemfile="$SOURCE_DIR/Gemfile"
echo "" >> $TARGET_DIR/gemset.nix # Create trailing newline to please EditorConfig checks

View File

@ -0,0 +1,4 @@
#!/usr/bin/env nix-shell
#! nix-shell -p jq -p bundix -p nix-prefetch-git -i bash
./update-remote.sh --url https://github.com/glitch-soc/mastodon.git --rev 5db3a14388cf780364b213c63aaf97b6f444ca17 --ver v3.5.1

View File

@ -0,0 +1 @@
"3f15326a05a926e9f001800a48ac2addbd3aa833"