add mastodon
This commit is contained in:
parent
1c7b6c4744
commit
58fe9e8965
9 changed files with 16031 additions and 17 deletions
4
.github/workflows/update-flake.yaml
vendored
4
.github/workflows/update-flake.yaml
vendored
|
@ -18,6 +18,10 @@ jobs:
|
||||||
run: nix flake update
|
run: nix flake update
|
||||||
- name: Run update script for minecraft
|
- name: Run update script for minecraft
|
||||||
run: ./minecraft/update.sh
|
run: ./minecraft/update.sh
|
||||||
|
- name: Run update script for mastodon
|
||||||
|
run: ./mastodon/update.sh
|
||||||
|
- name: Run nix formatter
|
||||||
|
run: nix fmt
|
||||||
- name: Commit and push
|
- name: Commit and push
|
||||||
uses: technote-space/create-pr-action@v2
|
uses: technote-space/create-pr-action@v2
|
||||||
with:
|
with:
|
||||||
|
|
17
flake.lock
generated
17
flake.lock
generated
|
@ -31,6 +31,22 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"mastodon": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1654881571,
|
||||||
|
"narHash": "sha256-ASSrCM0jHMI04U7fFPQdaeDvt/sHzpiWKHSy6+/FW0M=",
|
||||||
|
"owner": "glitch-soc",
|
||||||
|
"repo": "mastodon",
|
||||||
|
"rev": "970f06331bc7e482226e974c468b559a9e2f3fa3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "glitch-soc",
|
||||||
|
"repo": "mastodon",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"miifox-net": {
|
"miifox-net": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -66,6 +82,7 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"clean-s3-cache": "clean-s3-cache",
|
"clean-s3-cache": "clean-s3-cache",
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
|
"mastodon": "mastodon",
|
||||||
"miifox-net": "miifox-net",
|
"miifox-net": "miifox-net",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
|
|
27
flake.nix
27
flake.nix
|
@ -10,20 +10,20 @@
|
||||||
clean-s3-cache.flake = false;
|
clean-s3-cache.flake = false;
|
||||||
miifox-net.url = "git+https://git.chir.rs/CarolineHusky/MiiFox.net";
|
miifox-net.url = "git+https://git.chir.rs/CarolineHusky/MiiFox.net";
|
||||||
miifox-net.flake = false;
|
miifox-net.flake = false;
|
||||||
|
mastodon.url = "github:glitch-soc/mastodon";
|
||||||
|
mastodon.flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs = {
|
||||||
{ self
|
self,
|
||||||
, nixpkgs
|
nixpkgs,
|
||||||
, flake-utils
|
flake-utils,
|
||||||
, ...
|
...
|
||||||
} @ inputs:
|
} @ inputs:
|
||||||
flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ] (
|
flake-utils.lib.eachSystem ["aarch64-linux" "x86_64-linux"] (
|
||||||
system:
|
system: let
|
||||||
let
|
pkgs = import nixpkgs {inherit system;};
|
||||||
pkgs = import nixpkgs { inherit system; };
|
in rec {
|
||||||
in
|
|
||||||
rec {
|
|
||||||
formatter = pkgs.alejandra;
|
formatter = pkgs.alejandra;
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
|
@ -32,11 +32,12 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
packages = pkgs.lib.lists.foldl (a: b: a // b) { } (map (f: import f { inherit pkgs inputs; }) [
|
packages = pkgs.lib.lists.foldl (a: b: a // b) {} (map (f: import f {inherit pkgs inputs;}) [
|
||||||
./scripts/clean-s3-cache.nix
|
./scripts/clean-s3-cache.nix
|
||||||
./web/old-homepage.nix
|
./web/old-homepage.nix
|
||||||
./web/miifox-net.nix
|
./web/miifox-net.nix
|
||||||
./minecraft/paper.nix
|
./minecraft/paper.nix
|
||||||
|
./mastodon
|
||||||
]);
|
]);
|
||||||
|
|
||||||
hydraJobs = {
|
hydraJobs = {
|
||||||
|
|
1
mastodon/README.md
Normal file
1
mastodon/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Based on nixos’ mastodon derivation
|
96
mastodon/default.nix
Normal file
96
mastodon/default.nix
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
{
|
||||||
|
inputs,
|
||||||
|
pkgs,
|
||||||
|
}: let
|
||||||
|
pname = "mastodon-glitch";
|
||||||
|
version = inputs.mastodon.lastModifiedDate;
|
||||||
|
src = inputs.mastodon;
|
||||||
|
in rec {
|
||||||
|
mastodon-yarn = (pkgs.callPackage ./yarn.nix {}).offline_cache;
|
||||||
|
mastodon-gems = pkgs.bundlerEnv {
|
||||||
|
name = "${pname}-gems-${version}";
|
||||||
|
inherit version;
|
||||||
|
ruby = pkgs.ruby_3_0;
|
||||||
|
gemdir = src;
|
||||||
|
gemset = ./gemset.nix;
|
||||||
|
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 = pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "${pname}-modules";
|
||||||
|
inherit src version;
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [fixup_yarn_lock nodejs-slim yarn mastodon-gems mastodon-gems.wrappedRuby];
|
||||||
|
|
||||||
|
RAILS_ENV = "production";
|
||||||
|
NODE_ENV = "production";
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
export HOME=$PWD
|
||||||
|
fixup_yarn_lock ~/yarn.lock
|
||||||
|
yarn config --offline set yarn-offline-mirror ${mastodon-yarn}
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
mastodon = pkgs.stdenv.mkDerivation rec {
|
||||||
|
inherit pname version src;
|
||||||
|
|
||||||
|
propagatedBuildInputs = with pkgs; [imagemagick ffmpeg file mastodon-gems.wrappedRuby];
|
||||||
|
buildInputs = with pkgs; [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 = pkgs.writeShellScript "run-streaming.sh" ''
|
||||||
|
# NixOS helper script to consistently use the same NodeJS version the package was built with.
|
||||||
|
${pkgs.nodejs-slim}/bin/node ./streaming
|
||||||
|
'';
|
||||||
|
in ''
|
||||||
|
mkdir -p $out
|
||||||
|
cp -r * $out/
|
||||||
|
ln -s ${run-streaming} $out/run-streaming.sh
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
3120
mastodon/gemset.nix
Normal file
3120
mastodon/gemset.nix
Normal file
File diff suppressed because it is too large
Load diff
54
mastodon/update.sh
Executable file
54
mastodon/update.sh
Executable file
|
@ -0,0 +1,54 @@
|
||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#! nix-shell -i bash -p bundix yarn2nix yarn nix-prefetch-git
|
||||||
|
set -e
|
||||||
|
|
||||||
|
URL=https://github.com/glitch-soc/mastodon.git
|
||||||
|
REVISION=$(jq -r '.nodes.mastodon.locked.rev' ../flake.lock)
|
||||||
|
|
||||||
|
rm -f gemset.nix yarn.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 //')
|
||||||
|
|
||||||
|
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 {}')"
|
||||||
|
rm 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
|
||||||
|
|
||||||
|
echo "Creating yarn.nix"
|
||||||
|
yarn2nix --lockfile="$SOURCE_DIR/yarn.lock" > $TARGET_DIR/yarn.nix
|
12723
mastodon/yarn.nix
Normal file
12723
mastodon/yarn.nix
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,11 +1,9 @@
|
||||||
{ pkgs, ... }:
|
{pkgs, ...}: let
|
||||||
let
|
|
||||||
version-info = builtins.fromJSON (builtins.readFile ./paper.json);
|
version-info = builtins.fromJSON (builtins.readFile ./paper.json);
|
||||||
pname = "paper";
|
pname = "paper";
|
||||||
mcVersion = version-info.version;
|
mcVersion = version-info.version;
|
||||||
buildNum = toString version-info.build;
|
buildNum = toString version-info.build;
|
||||||
in
|
in rec {
|
||||||
rec {
|
|
||||||
paper-jar = pkgs.fetchurl {
|
paper-jar = pkgs.fetchurl {
|
||||||
url = "https://papermc.io/api/v2/projects/paper/versions/${mcVersion}/builds/${buildNum}/downloads/${version-info.name}";
|
url = "https://papermc.io/api/v2/projects/paper/versions/${mcVersion}/builds/${buildNum}/downloads/${version-info.name}";
|
||||||
inherit (version-info) sha256;
|
inherit (version-info) sha256;
|
||||||
|
|
Reference in a new issue