Added a nixos development build for for local linux development (#105)

- Updated `dream2nix` to the latest version.
- Removed deprecated inputs related to `dream2nix`, including `devshell`, `flake-compat`, `flake-parts`, and others.
- Added new inputs for `purescript-overlay` and `pyproject-nix`.
- Updated `nixpkgs` and `flake-utils` to the latest versions.

This update syncs the project dependencies with the latest available versions, potentially improving stability and compatibility.

* flake building for develop now works

* add composer and php to flake.nix

* added preinstall to flake.nix and more packages

* Added temp buildsteps file

File Is to be renamed and moved before merge with main.
This file contains a modified version of vagrant/provision.sh
specifically made for the nixos development process

* moved from mariadb to mysql

Mariadb kept crashing my computer and causing long hangs in the terminal, so I swapped to mysql for development

* stopped cp of .env.example to .env and fixed access list for mysql

Mysql was granting all writes on "*" to both users, mysql uses "%" as a wildcard, I forgot and messed up

* updated shell.nix to only run composer update when running

* fixed broken minecraft forge egg

* before I break vagrant I took back the old configuration file as well

* Transitioned most systemd tasks to nixos task configurations and replaced /var/www/pterodactyl to cwd

* updated flake.lock with latest nix configuration

* everything up to starting wings is working, time to see if I can get web server working as well

* added "--rm \" to buildsteps

* fixed many issues and working on getting mariadb working properly

* fix: mariadb now gets initialized properly

* fix: update favicon & password reset (#91)

* removed linux info for local development

* chore: moved buildsteps to nix folder

* removed all unnecesary services in configuration.nix

* added docker-compose.yml so that the buildsteps file has something to do

* Switching to using mysql in a docker container over inside the nix flake

* Fix: Changed from nixos-unstable to nixos-24.05 packages

Also added mariadb service back in flake.nix and stop mariadb docker container on nix shutdown

* updated flake.lock to match packager version change

* fix: buildsteps script not connecting to mariadb server

* fix: wings didn't work in cli so made it a docker container and organized docker-compose files

* As we include a Dockerfile now, we need to push .dockerignore for smaller images

* fix: changed directory for wings docker container from ./nix/pterodacytl/<name> to ./<name>

* fix: changed docker-compose paths in flake.nix

* fix: wings docker-compose.yml now uses network_mode host

* added some resets for mariadb and pterodactyl whenever the app is started(subject to change in the future

* updated some nixos specific "Features" and ensure mariadb and wings folders exists

* deleted mariadb reset in buildsteps and added 20 seconds for mariadb to start

deleting the mariadb folders was causing errors to occur, and not waiting long enough causes database connection errors

* added mariadb docker-compose file and added extra stuff to .gitignore

* added nix files to dockerignore

* added linux development guide

* Disable recaptcha on setup

* docs: Formatting fixes

* docs: Linux doesn't use vagrant anymore

* docs: https does not work

I really need to proofread my docs before I push them

* docs: Added Prereqs for linux local development

* docs: we do not need to be told about the docker image twice

* deleted configuration.nix and decreased flake.nix clutter

* docs(README): notes about local development on linux

added info about pterodactyl wings not working in nixos dev environment

* fixed some broken markdown formatting

* Revert last commit

* added one more VERY important step to readme

* added a few fixes with systems other than mine

* added a run.sh file to easily run nixos

* Added a env.nix file because it's configuration is slightly different to normal env

* fix(README): use Git for cloning

* Updated pterodactyl discord links to pyrodactyl links

* added a health check to maria to ensure it's up before continuing

* removed benign sql query and added --no-interaction to key:generate

* updated more pterodactyl links to pyrodactyl links

---------

Co-authored-by: he3als <65787561+he3als@users.noreply.github.com>
This commit is contained in:
Naterfute
2024-10-04 21:29:05 -07:00
committed by GitHub
parent e9c1ed6b58
commit 330735e4ca
14 changed files with 327 additions and 609 deletions

8
.dockerignore Normal file
View File

@@ -0,0 +1,8 @@
Vagrantfile
vagrant/
.swc/
.turbo/
nix/
flake.nix
flake.lock

50
.env.nix Normal file
View File

@@ -0,0 +1,50 @@
APP_ENV=production
APP_DEBUG=false
APP_KEY=base64:70nPUP+VYp/0HXxmnXbM2BJO6E1+JizA1XhAf72bAG8=
APP_THEME=pterodactyl
APP_TIMEZONE=UTC
APP_URL="http://localhost:8000"
APP_LOCALE=en
APP_ENVIRONMENT_ONLY=false
# If you are using a proxy server set this to be
# the Proxy server's ip adddress.
# TRUSTED_PROXIES=*
LOG_CHANNEL=daily
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=panel
DB_USERNAME=pyrodactyluser
DB_PASSWORD=pyrodactyl
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
HASHIDS_SALT=qFr7NZGVVpsX79HvKPqv
HASHIDS_LENGTH=8
MAIL_MAILER=smtp
MAIL_HOST=smtp.example.com
MAIL_PORT=25
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=no-reply@example.com
MAIL_FROM_NAME="Pterodactyl Panel"
# You should set this to your domain to prevent it defaulting to 'localhost', causing
# mail servers such as Gmail to reject your mail.
#
# @see: https://github.com/pterodactyl/panel/pull/3110
# MAIL_EHLO_DOMAIN=panel.example.com
APP_SERVICE_AUTHOR="dev@pyro.host"

View File

@@ -5,23 +5,23 @@ body:
- type: markdown
attributes:
value: |
Bug reports should only be used for reporting issues with how the software works. For assistance installing this software, as well as debugging issues with dependencies, please use our [Discord server](https://discord.gg/pterodactyl).
Bug reports should only be used for reporting issues with how the software works. For assistance installing this software, as well as debugging issues with dependencies, please use our [Discord server](https://pyro.host/discord).
- type: textarea
- type: textarea
attributes:
label: Current Behavior
description: Please provide a clear & concise description of the issue.
validations:
required: true
- type: textarea
- type: textarea
attributes:
label: Expected Behavior
description: Please describe what you expected to happen.
validations:
required: true
- type: textarea
- type: textarea
attributes:
label: Steps to Reproduce
description: Please be as detailed as possible when providing steps to reproduce, failure to provide steps will result in this issue being closed.
@@ -45,14 +45,14 @@ body:
placeholder: 1.4.2
validations:
required: true
- type: input
id: egg-details
attributes:
label: Games and/or Eggs Affected
description: Please include the specific game(s) or egg(s) you are running into this bug with.
placeholder: Minecraft (Paper), Minecraft (Forge)
- type: input
id: docker-image
attributes:
@@ -66,18 +66,18 @@ body:
label: Error Logs
description: |
Run the following command to collect logs on your system.
Wings: `sudo wings diagnostics`
Panel: `tail -n 150 /var/www/pterodactyl/storage/logs/laravel-$(date +%F).log | nc pteropaste.com 99`
placeholder: "https://pteropaste.com/a1h6z"
render: bash
validations:
required: false
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please [search here](https://github.com/pterodactyl/panel/issues) to see if an issue already exists for your problem.
description: Please [search here](https://github.com/pyrohost/pyrodactyl/issues) to see if an issue already exists for your problem.
options:
- label: I have searched the existing issues before opening this issue.
required: true

View File

@@ -1,8 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: Installation Help
url: https://discord.gg/pterodactyl
url: https://pyro.host/discord
about: Please visit our Discord for help with your installation.
- name: General Question
url: https://discord.gg/pterodactyl
about: Please visit our Discord for general questions about Pterodactyl.
url: https://pyro.host/discord
about: Please visit our Discord for general questions about Pyrodactyl.

View File

@@ -5,7 +5,7 @@ body:
- type: checkboxes
attributes:
label: Is there an existing feature request for this?
description: Please [search here](https://github.com/pterodactyl/panel/issues?q=is%3Aissue) to see if someone else has already suggested this.
description: Please [search here](https://github.com/pyrohost/pyrodactyl/issues?q=is%3Aissue) to see if someone else has already suggested this.
options:
- label: I have searched the existing issues before opening this feature request.
required: true

13
.gitignore vendored
View File

@@ -19,9 +19,7 @@ _ide_helper_models.php
public/assets/manifest.json
# For local development with docker
# Remove if we ever put the Dockerfile in the repo
.dockerignore
docker-compose.yml
#docker-compose.yml
# for image related files
misc
@@ -33,8 +31,15 @@ resources/lang/locales.js
/public/build
/public/hot
result
docker-compose.yaml
#docker-compose.yaml
.swc/
.turbo
# Sentry Config File
.env.sentry-build-plugin
# Nix specific stuff
nix/docker/wings/pterodactyl
nix/docker/maria/mariadata
nix/docker/wings/etc/
nix/docker/wings/lib/
nix/docker/maria/mariadb_data/

View File

@@ -38,17 +38,23 @@ Pyrodactyl is the Pterodactyl-based game server management panel that focuses on
## Running Pyrodactyl
> [!TIP]
> Pyrodactyl now [has a Docker image avaliable](https://github.com/pyrohost/pyrodactyl/pkgs/container/pyrodactyl), which for previous users of the Pterodactyl panel in Docker, should make it easy to migrate.
>
> If you want to setup Pyrodactyl in Docker from scratch, see the [`docker-compose.example.yml`](https://github.com/pyrohost/pyrodactyl/blob/main/docker-compose.example.yml).
> [!WARNING]
> Nothing is Perfect, that apply's to this panel.
> If you are migrating your data from pterodactyl, always make sure you take a backup of your pterodactyl database and other relevant data.
### Prerequisites
- Latest LTS version of NodeJS
- Git
### Linux
> [!TIP]
> Pyrodactyl now [has a Docker image avaliable](https://github.com/pyrohost/pyrodactyl/pkgs/container/pyrodactyl), which for previous users of the Pterodactyl panel in Docker, should make it easy to migrate.
>
> If you want to setup Pyrodactyl in Docker from scratch, see the [`docker-compose.example.yml`](https://github.com/pyrohost/pyrodactyl/blob/main/docker-compose.example.yml). You can follow [Pterodactyl's instructions](https://github.com/pterodactyl/panel/tree/1.0-develop/.github/docker#pterodactyl-panel---docker-image) on setting it up.
<details><summary>Running on Linux</summary>
<p>
Setting up Pyrodactyl is a breeze on Linux. Follow the [official Pterodactyl documentation](https://pterodactyl.io/panel/1.0/getting_started.html) for your distribution up to the **Download Files** step.
@@ -60,8 +66,7 @@ mkdir -p /var/www/pterodactyl
cd /var/www/pterodactyl
# Download and extract panel
curl -Lo main.tar.gz https://github.com/pyrohost/pyrodactyl/archive/refs/heads/main.tar.gz
tar -xzf main.tar.gz --strip-components=1 -C /var/www/pterodactyl pyrodactyl-main/
git clone https://github.com/pyrohost/pyrodactyl.git /var/www/pterodactyl --depth=2
# Permissions for caches
chmod -R 755 storage/* bootstrap/cache/
@@ -71,6 +76,7 @@ npm ci && npm run ship
```
Proceed with the rest of the installation as you would with the official panel.
</p></details>
### Windows
@@ -102,74 +108,40 @@ Pyrodactyl is the world's first Pterodactyl panel that can be developed and run
- We do not recommend using Hyper-V as your virtualization layer. If your Vagrant installation asks you for a password, this is because you used Hyper-V. The password will be your Windows password.
- We recommend using VMWare Workstation or VirtualBox instead.
</p>
</details>
</p></details>
<details><summary>On Linux</summary>
<p>
### Extra prerequsites
### Prerequisites
In addition to the previous prerequsites, you need:
- Nix
- Docker
- [Vagrant](https://www.vagrantup.com/)
- `libvirtd`
- `nfs-utils`
Local Development on Linux is A little different, because vagrant is the buggy software that it is, I couldn't get it to run properly... Anywhere, and on no Distro.
So I decided that instead of using Vagrant, I would use nix. This turned out to be a very good idea. Now, using nix the development boots faster because we aren't using
an entire vm to host a development server, it also uses way less resources, and is much easier to configure exactly how you want through the nix/buildsteps.sh file.
### Install nfs-utils
### How to get started
- **Fedora:** `sudo dnf install nfs-utils`
- **Ubuntu/Debian:** `sudo apt-get install nfs-kernel-server`
Afterwards, start it:
- `sudo systemctl start nfs-server`
- To have it start when your computer starts
- `sudo systemctl enable nfs-server`
### Notes about Local Development on Linux
Using [Vagrant](https://www.vagrantup.com) on Linux is incredibly simple. Verify you met the prerequsites above, then follow these simple steps:
To get started, you obviously need nix on your system, and you need to configure nix to support flake files. Depending on your OS, this can vary
1. Clone the Pyrodactyl panel repository
2. Run `npm i` to install all required packages
3. Run `npm run ship` to build Pyrodactyl. This will cache the results of the build and upload sourcemaps to Sentry. Subsequent builds without code changes will finish in milliseconds.
1. run `npm i` to install all the packages necessary.
1. Run `npm run ship` to build Pyrodactyl. This will cache the results of the build and upload sourcemaps to Sentry. Subsequent builds without code changes will finish in milliseconds.
1. Copy `.env.nix` to `.env`
1. Run `nix develop`. This will setup wings and the necessary services in order to run Pyrodactyl's databases, services, and app. This process could take up to 15 minutes.
1. Once you receive a message that says "Pyrodactyl is now up and running at localhost:8000", visit that URL in your browser and login with the default credentials provided in your console. **It's important that you use localhost to connect to Pyrodactyl! If you use 127.0.0.1, you will run into CORS issues and other issues that will not be fixed.**
1. Visit http://localhost:8000/admin to provision your first server on Pyrodactyl!
> [!IMPORTANT]
> In order for `vagrant up` to work, your files must be in the `/var/www/pterodactyl` directory unless manually changed in the `Vagrantfile`!
4. Run `vagrant up`. This will setup wings and the necessary services in order to run Pyrodactyl's databases, services, and app. This process could take up to 15 minutes.
5. Once you receive a message that says "Pyrodactyl is now up and running at localhost:3000", visit that URL in your browser and login with the default credentials provided in your console. **It's important that you use localhost to connect to Pyrodactyl! If you use 127.0.0.1, you will run into CORS issues and other issues that will not be fixed.**
### Notes about Local Development on Linux
- If your having trouble installing Virtualbox on linux, you can try to follow instructions in these [docs](https://github.com/pyrohost/pyrodactyl/blob/main/VirtualBoxSetup.md)
Due to a slight bug or two, pterodactyl wings does not as present work properly using the nixos development environment\
This will hopefully be fixed later, but for now just be warned
- It should be stated that when running on Linux, if you are using a virtual machine manager other than libvirtd, you will have to add your configuration to the [Vagrantfile](https://github.com/pyrohost/pyrodactyl/blob/main/Vagrantfile). If not, it will boot the VM with 512 mb of ram, which is not enough to build Pyrodactyl!
- There might be a weird bug the first time you run `vagrant up`, where you get an error like this:
```
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mount -o vers=3,udp xxx.xxx.xxx.x:/home/user/pyrodactyl /var/www/pterodactyl
Stdout from the command:
Stderr from the command:
mount.nfs: Connection refused
```
If this happens, just re-run `vagrant up` and it should work.
- If you're having permission errors, try running using sudo, e.g `sudo vagrant up`
</p>
</details>
</p></details>
## Star History

281
flake.lock generated
View File

@@ -1,93 +1,15 @@
{
"nodes": {
"devshell": {
"flake": false,
"locked": {
"lastModified": 1663445644,
"narHash": "sha256-+xVlcK60x7VY1vRJbNUEAHi17ZuoQxAIH4S4iUFUGBA=",
"owner": "numtide",
"repo": "devshell",
"rev": "e3dc3e21594fe07bdb24bdf1c8657acaa4cb8f66",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"dream2nix": {
"inputs": {
"devshell": "devshell",
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"nix-unit": "nix-unit",
"nixpkgs": [
"nixpkgs"
],
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1695717405,
"narHash": "sha256-MvHrU3h0Bw57s2p+wCUnSZliR4wvvPi3xkW+MRWB5HU=",
"owner": "nix-community",
"repo": "dream2nix",
"rev": "6dbd59e4a47bd916a655c4425a3e730c6aeae033",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "dream2nix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"dream2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1675933616,
"narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "47478a4a003e745402acf63be7f9a092d51b83d7",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1689068808,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
@@ -96,175 +18,25 @@
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"mk-node-package": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
],
"npmlock2nix": "npmlock2nix",
"pnpm2nix": "pnpm2nix"
},
"locked": {
"lastModified": 1633790997,
"narHash": "sha256-1mk4EwNkWtTNpeRivZmJTzB+92g07maeFRVUMnnRh1U=",
"owner": "winston0410",
"repo": "mkNodePackage",
"rev": "a7eca5e027c8b260dca4ece7d8dd187f92420611",
"type": "github"
},
"original": {
"owner": "winston0410",
"repo": "mkNodePackage",
"type": "github"
}
},
"nix-github-actions": {
"inputs": {
"nixpkgs": [
"dream2nix",
"nix-unit",
"nixpkgs"
]
},
"locked": {
"lastModified": 1688870561,
"narHash": "sha256-4UYkifnPEw1nAzqqPOTL2MvWtm3sNGw1UTYTalkTcGY=",
"owner": "nix-community",
"repo": "nix-github-actions",
"rev": "165b1650b753316aa7f1787f3005a8d2da0f5301",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix-github-actions",
"type": "github"
}
},
"nix-unit": {
"inputs": {
"flake-parts": [
"dream2nix",
"flake-parts"
],
"nix-github-actions": "nix-github-actions",
"nixpkgs": [
"dream2nix",
"nixpkgs"
],
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1690289081,
"narHash": "sha256-PCXQAQt8+i2pkUym9P1JY4JGoeZJLzzxWBhprHDdItM=",
"owner": "adisbladis",
"repo": "nix-unit",
"rev": "a9d6f33e50d4dcd9cfc0c92253340437bbae282b",
"type": "github"
},
"original": {
"owner": "adisbladis",
"repo": "nix-unit",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1695644571,
"narHash": "sha256-asS9dCCdlt1lPq0DLwkVBbVoEKuEuz+Zi3DG7pR/RxA=",
"lastModified": 1726320982,
"narHash": "sha256-RuVXUwcYwaUeks6h3OLrEmg14z9aFXdWppTWPMTwdQw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6500b4580c2a1f3d0f980d32d285739d8e156d92",
"rev": "8f7492cce28977fbf8bd12c72af08b1f6c7c3e49",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"npmlock2nix": {
"flake": false,
"locked": {
"lastModified": 1633729941,
"narHash": "sha256-v2YPcEWI1Wz8ErivorubgLcDT06H6YzFT7uhp1ymqnE=",
"owner": "winston0410",
"repo": "npmlock2nix",
"rev": "6ade47a330b6919defb45c0eb984a64234aa8468",
"type": "github"
},
"original": {
"owner": "winston0410",
"ref": "issue113",
"repo": "npmlock2nix",
"type": "github"
}
},
"pnpm2nix": {
"flake": false,
"locked": {
"lastModified": 1594396611,
"narHash": "sha256-UXOUQ+2A89/zaxYhTHiRrRBU5exbUWrg+FoJYMcNwuI=",
"owner": "nix-community",
"repo": "pnpm2nix",
"rev": "f67be0925a91b92f54d99dbdead7a06920b979ac",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "master",
"repo": "pnpm2nix",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"dream2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1646153636,
"narHash": "sha256-AlWHMzK+xJ1mG267FdT8dCq/HvLCA6jwmx2ZUy5O8tY=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "b6bc0b21e1617e2b07d8205e7fae7224036dfa4b",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"dream2nix": "dream2nix",
"flake-utils": "flake-utils_2",
"mk-node-package": "mk-node-package",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
@@ -282,43 +54,6 @@
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"dream2nix",
"nix-unit",
"nixpkgs"
]
},
"locked": {
"lastModified": 1689620039,
"narHash": "sha256-BtNwghr05z7k5YMdq+6nbue+nEalvDepuA7qdQMAKoQ=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "719c2977f958c41fa60a928e2fbc50af14844114",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",

296
flake.nix
View File

@@ -1,259 +1,71 @@
{
description = "Pterodactyl Panel";
description = "PyroPanel";
inputs = {
dream2nix = {
url = "github:nix-community/dream2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils = {
url = "github:numtide/flake-utils";
};
mk-node-package = {
url = "github:winston0410/mkNodePackage";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
nixpkgs = {
url = "github:NixOS/nixpkgs/nixos-unstable";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
dream2nix,
flake-utils,
mk-node-package,
nixpkgs,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
version = "latest";
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs { inherit system; };
pkgs = import nixpkgs {inherit system;};
mkNodePackage = mk-node-package.lib."${system}".mkNodePackage;
pyrodactylPath = builtins.toString ./.;
php81WithExtensions = with pkgs; (php81.buildEnv {
extensions = {
enabled,
all,
}:
enabled
++ (with all; [
redis
xdebug
]);
extraConfig = ''
xdebug.mode=debug
'';
});
composer = with pkgs; (php81Packages.composer.override {php = php81WithExtensions;});
in {
caCertificates = pkgs.runCommand "ca-certificates" {} ''
mkdir -p $out/etc/ssl/certs $out/etc/pki/tls/certs
ln -s ${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt $out/etc/ssl/certs/ca-bundle.crt
ln -s ${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt $out/etc/ssl/certs/ca-certificates.crt
ln -s ${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt $out/etc/pki/tls/certs/ca-bundle.crt
'';
devShell = pkgs.mkShell {
buildInputs = [
pkgs.php
pkgs.phpPackages.composer
pkgs.redis
pkgs.nginx
pkgs.docker
pkgs.docker-compose
pkgs.mariadb
pkgs.nodejs_20
pkgs.tmux
];
shellHook = let
dataDir = "./data";
in ''
echo "Starting Redis in the dev shell..."
caddyfile = pkgs.writeText "Caddyfile" ''
:80 {
root * /var/www/html/public/
file_server
# Start Redis in the background
# These damn variables causing all sorts of issues when not here
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
redis-server --daemonize yes
header {
-Server
-X-Powered-By
Referrer-Policy "same-origin"
X-Frame-Options "deny"
X-XSS-Protection "1; mode=block"
X-Content-Type-Options "nosniff"
}
echo "Redis is running!"
encode gzip zstd
echo "Resetting MariaDB Data"
# Delete Maria Folders
echo "Delete maria Folders"
rm -fR $(pwd)/nix/docker/maria/mariadb_data
php_fastcgi localhost:9000
# Create Maria Folders
echo "Create maria Folders"
mkdir $(pwd)/nix/docker/maria/mariadb_data
try_files {path} {path}/ /index.php?{query}
}
'';
echo "Starting Pyrodactyl"
bash ./nix/buildsteps.sh
# Define cleanup function to stop services
phpfpmConf = pkgs.writeText "php-fpm.conf" ''
[global]
error_log = /dev/stderr
daemonize = no
cleanup() {
echo "Stopping Redis..."
pkill redis-server
[www]
user = nobody
group = nobody
echo "Stopping mariadb-docker..."
docker-compose --project-directory ./nix/docker/maria/ down
echo "Stopping Pterodactyl wings..."
docker-compose --project-directory ./nix/docker/wings/ down
}
listen = 0.0.0.0:9000
pm = dynamic
pm.start_servers = 4
pm.min_spare_servers = 4
pm.max_spare_servers = 16
pm.max_children = 64
pm.max_requests = 256
clear_env = no
catch_workers_output = yes
decorate_workers_output = no
'';
configs = pkgs.runCommand "configs" {} ''
mkdir -p $out/etc/caddy
ln -s ${caddyfile} $out/etc/caddy/Caddyfile
ln -s ${phpfpmConf} $out/etc/php-fpm.conf
'';
src = with pkgs.lib;
cleanSource (cleanSourceWith {
filter = name: type: let
baseName = baseNameOf (toString name);
in
!(builtins.elem baseName [
".direnv"
".github"
"bootstrap/cache"
"node_modules"
"public/build"
"public/hot"
"storage"
"vendor"
".editorconfig"
".env"
".env.testing"
".envrc"
".gitignore"
".php-cs-fixer.cache"
".phpunit.result.cache"
"BUILDING.md"
"CODE_OF_CONDUCT.md"
"CONTRIBUTING.md"
"docker-compose.development.yaml"
"docker-compose.example.yaml"
"docker-compose.yaml"
"flake.lock"
"flake.nix"
"shell.nix"
]);
src = ./.;
});
app =
(dream2nix.lib.makeFlakeOutputs {
config.projectRoot = src;
source = src;
settings = [
{
translator = "composer-lock";
subsystemInfo.noDev = true;
}
];
systems = [system];
autoProjects = true;
})
.packages
."${system}"
."pterodactyl/panel";
ui = mkNodePackage {
inherit src version;
pname = "pterodactyl";
buildInputs = [];
buildPhase = ''
yarn run build:production
'';
installPhase = ''
mkdir -p $out
cp -r public/build $out
'';
};
panel = pkgs.stdenv.mkDerivation {
inherit src version;
pname = "pterodactyl";
buildInputs = [app ui];
installPhase = ''
cp -r ${app}/lib/vendor/pterodactyl/panel $out
chmod 755 $out
chmod 755 $out/public
mkdir -p $out/public/build
cp -r ${ui}/build/* $out/public/build
rm $out/composer.json.orig
'';
};
in {
defaultPackage = panel;
devShell = import ./shell.nix {inherit composer php81WithExtensions pkgs;};
packages = {
inherit panel;
development = with pkgs;
dockerTools.buildImage {
name = "pterodactyl/development";
tag = "panel";
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [
bash
dockerTools.fakeNss
caCertificates
caddy
composer
configs
coreutils
mysql80
nodejs_18
nodePackages.yarn
php81WithExtensions
];
pathsToLink = ["/bin" "/etc"];
};
};
oci = with pkgs;
dockerTools.buildImage {
name = "pterodactyl/panel";
tag = version;
copyToRoot = buildEnv {
name = "image-root";
paths = [
dockerTools.fakeNss
caCertificates
caddy
configs
php81WithExtensions
panel
];
pathsToLink = ["/bin" "/etc"];
};
config = {
Cmd = [];
};
};
};
}
);
# Register cleanup on shell exit
trap cleanup EXIT
'';
};
});
}

89
nix/buildsteps.sh Executable file
View File

@@ -0,0 +1,89 @@
#!/bin/bash
mysqlrootpass="password"
mysqluser="root"
CONTAINER_NAME="mariadb"
docker-compose --project-directory ./nix/docker/maria/ up -d --force-recreate
until [ "$(docker inspect --format='{{.State.Health.Status}}' $CONTAINER_NAME)" == "healthy" ]; do
echo "Waiting for MariaDB container to be healthy..."
sleep 5
done
echo "MariaDB container is healthy. Proceeding with the script."
# Create the database for the panel
mysql -u "$mysqluser" -p"$mysqlrootpass" -h 127.0.0.1 -e "
CREATE DATABASE IF NOT EXISTS panel;
CREATE USER IF NOT EXISTS 'pyrodactyl'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON panel.* TO 'pyrodactyl'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
"
# Create the database host user
mysql -u "$mysqluser" -p"$mysqlrootpass" -h 127.0.0.1 -e "
CREATE USER IF NOT EXISTS 'pyrodactyluser'@'%' IDENTIFIED BY 'pyrodactyl';
GRANT ALL PRIVILEGES ON panel.* TO 'pyrodactyluser'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
"
# Initialize the Pterodactyl panel
# This cp command breaks my configuration, that is why it's commented
# cp .env.example .env
composer install --no-dev --optimize-autoloader
# PHP Artisan commands
php artisan key:generate --force --no-interaction
php artisan p:environment:setup -n --author dev@pyro.host --url http://localhost:8000 --cache redis --session redis --queue redis
php artisan p:environment:database -n --host 127.0.0.1 --port 3306 --database panel --username pyrodactyluser --password pyrodactyl
php artisan migrate --seed --force
# Create a developer user
# Adding --admin tag just in case it ever gets fixed
php artisan p:user:make -n --email dev@pyro.host --username dev --name-first Developer --name-last User --password password --admin
# --admin probably won't be fixed due to security concerns
mysql -u $mysqluser -p$mysqlrootpass -h 0.0.0.0 -e "USE panel; UPDATE users SET root_admin = 1;" # workaround because --admin is broken
# Make a location and node for the panel
php artisan p:location:make -n --short local --long Local
php artisan p:node:make -n --name local --description "Development Node" --locationId 1 --fqdn localhost --public 1 --scheme http --proxy 0 --maxMemory 1024 --maxDisk 10240 --overallocateMemory 0 --overallocateDisk 0
# Add some dummy allocations to the node
mysql -u "$mysqluser" -p"$mysqlrootpass" -e "USE panel; INSERT INTO allocations (node_id, ip, port) VALUES (1, 'localhost', 25565), (1, 'localhost', 25566), (1, 'localhost', 25567);"
# Disable Recaptcha
mysql -u $mysqluser -p$mysqlrootpass -h 0.0.0.0 -e "USE panel; UPDATE settings SET \`key\`='settings::recaptcha:enabled', value='false' WHERE id=1;"
# Setup wings
#curl -L -o /usr/local/bin/wings "https://github.com/pterodactyl/wings/releases/latest/download/wings_linux_$([[ "$(uname -m)" == "x86_64" ]] && echo "amd64" || echo "arm64")"
#chmod u+x /usr/local/bin/wings
# Delete Wings folders
rm -fR $(pwd)/nix/docker/wings/etc
rm -fR $(pwd)/nix/docker/wings/var
rm -fR $(pwd)/nix/docker/wings/tmp
# create Wings folders
mkdir $(pwd)/nix/docker/wings/etc
mkdir $(pwd)/nix/docker/wings/var
mkdir $(pwd)/nix/docker/wings/tmp
php artisan p:node:configuration 1 >$(pwd)/nix/docker/wings/etc/config.yml
docker-compose --project-directory ./nix/docker/wings up -d --force-recreate
php artisan serve
docker-compose --project-directory ./nix/docker/wings down
docker-compose --project-directory ./nix/docker/maria/ down

View File

@@ -0,0 +1,24 @@
services:
mariadb:
image: mariadb:latest
container_name: mariadb
restart: always
user: "1000:1000"
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
start_period: 10s
interval: 10s
timeout: 5s
retries: 3
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: panel
MYSQL_USER: pyro
MYSQL_PASSWORD: password
volumes:
- ./mariadb_data:/var/lib/mysql
network_mode: host
command: [
'--default-authentication-plugin=mysql_native_password'
]

View File

@@ -0,0 +1,20 @@
services:
pterodactyl-wings:
image: ghcr.io/pterodactyl/wings:latest
container_name: pterodactyl-wings
restart: unless-stopped
network_mode: 'host'
environment:
- TZ=America/Los_Angeles
- WINGS_UID=1001
- WINGS_GID=1001
- WINGS_USERNAME=pyrodactyl
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "/var/lib/docker/containers:/var/lib/docker/containers"
- "./etc:/etc/pterodactyl"
- "./lib:/var/lib/pterodactyl"
- "./log:/var/log/pterodactyl"
- "./tmp:/tmp/pterodactyl"

3
run.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
nix --experimental-features 'nix-command flakes' develop

View File

@@ -1,19 +1,19 @@
{
composer ? null,
php81WithExtensions ? null,
pkgs ? import <nixpkgs> {},
}:
with pkgs;
mkShell rec {
buildInputs = [
alejandra
composer
nodejs_18
nodePackages.yarn
php81WithExtensions
];
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = [
pkgs.php
pkgs.php83Packages.composer
pkgs.mysql
pkgs.redis
pkgs.docker
pkgs.systemd
pkgs.curl
pkgs.cron
];
shellHook = ''
composer update
'';
}
shellHook = ''
PATH="$PATH:${pkgs.docker-compose}/libexec/docker/cli-plugins"
'';
}