add papermc
This commit is contained in:
parent
a3e27aecad
commit
1c7b6c4744
5 changed files with 67 additions and 19 deletions
20
.github/workflows/update-flake.yaml
vendored
20
.github/workflows/update-flake.yaml
vendored
|
@ -2,7 +2,7 @@ name: update-flake-lock
|
|||
on:
|
||||
workflow_dispatch: # allows manual triggering
|
||||
schedule:
|
||||
- cron: "31 3 * * 3"
|
||||
- cron: "16 20 * * *"
|
||||
jobs:
|
||||
lockfile:
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -14,11 +14,15 @@ jobs:
|
|||
with:
|
||||
extra_nix_config: |
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Update flake.lock
|
||||
uses: DeterminateSystems/update-flake-lock@v9
|
||||
- name: Update flake.lockfile
|
||||
run: nix flake update
|
||||
- name: Run update script for minecraft
|
||||
run: ./minecraft/update.sh
|
||||
- name: Commit and push
|
||||
uses: technote-space/create-pr-action@v2
|
||||
with:
|
||||
pr-title: "Update flake.lock" # Title of PR to be created
|
||||
pr-labels: | # Labels to be set on the PR
|
||||
dependencies
|
||||
automated
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
COMMIT_MESSAGE: "Update everything"
|
||||
COMMIT_NAME: "GitHub Actions[bot]"
|
||||
COMMIT_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
PR_BRANCH_NAME: 'chore-update-${PR_ID}'
|
||||
PR_TITLE: 'chore: update everything'
|
||||
|
|
23
flake.nix
23
flake.nix
|
@ -12,16 +12,18 @@
|
|||
miifox-net.flake = false;
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
outputs =
|
||||
{ self
|
||||
, nixpkgs
|
||||
, flake-utils
|
||||
, ...
|
||||
} @ inputs:
|
||||
flake-utils.lib.eachSystem ["aarch64-linux" "x86_64-linux"] (
|
||||
system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
in rec {
|
||||
flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ] (
|
||||
system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
in
|
||||
rec {
|
||||
formatter = pkgs.alejandra;
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
|
@ -30,10 +32,11 @@
|
|||
];
|
||||
};
|
||||
|
||||
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
|
||||
./web/old-homepage.nix
|
||||
./web/miifox-net.nix
|
||||
./minecraft/paper.nix
|
||||
]);
|
||||
|
||||
hydraJobs = {
|
||||
|
|
6
minecraft/paper.json
Normal file
6
minecraft/paper.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"version": "1.18.2",
|
||||
"build": 379,
|
||||
"name": "paper-1.18.2-379.jar",
|
||||
"sha256": "672207836693f08ff147539a7c6ae317b5ac35d6dd6539cbd05bed21dcfcbe1f"
|
||||
}
|
31
minecraft/paper.nix
Normal file
31
minecraft/paper.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
version-info = builtins.fromJSON (builtins.readFile ./paper.json);
|
||||
pname = "paper";
|
||||
mcVersion = version-info.version;
|
||||
buildNum = toString version-info.build;
|
||||
in
|
||||
rec {
|
||||
paper-jar = pkgs.fetchurl {
|
||||
url = "https://papermc.io/api/v2/projects/paper/versions/${mcVersion}/builds/${buildNum}/downloads/${version-info.name}";
|
||||
inherit (version-info) sha256;
|
||||
};
|
||||
papermc = pkgs.stdenvNoCC.mkDerivation {
|
||||
pname = "papermc";
|
||||
version = "${mcVersion}-${buildNum}";
|
||||
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
|
||||
buildPhase = ''
|
||||
cat > minecraft-server << EOF
|
||||
#!${pkgs.bash}/bin/sh
|
||||
exec ${pkgs.openjdk17_headless}/bin/java \$@ -jar $out/share/papermc/papermc.jar nogui
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
install -Dm444 ${paper-jar} $out/share/papermc/papermc.jar
|
||||
install -Dm555 -t $out/bin minecraft-server
|
||||
'';
|
||||
};
|
||||
}
|
4
minecraft/update.sh
Executable file
4
minecraft/update.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i bash -p curl jq
|
||||
|
||||
curl -L https://papermc.io/api/v2/projects/paper/versions/1.18.2/builds | jq '{"version":.version, "build":.builds[-1].build, "name":.builds[-1].downloads.application.name, "sha256":.builds[-1].downloads.application.sha256}' > paper.json
|
Reference in a new issue