diff --git a/flake.lock b/flake.lock index ec3c2152a..dd3d4f871 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,150 @@ { "nodes": { + "alejandra": { + "inputs": { + "fenix": "fenix", + "flakeCompat": "flakeCompat", + "nixpkgs": [ + "dream2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1658427149, + "narHash": "sha256-ToD/1z/q5VHsLMrS2h96vjJoLho59eNRtknOUd19ey8=", + "owner": "kamadorueda", + "repo": "alejandra", + "rev": "f5a22afd2adfb249b4e68e0b33aa1f0fb73fb1be", + "type": "github" + }, + "original": { + "owner": "kamadorueda", + "repo": "alejandra", + "type": "github" + } + }, + "all-cabal-json": { + "flake": false, + "locked": { + "lastModified": 1665552503, + "narHash": "sha256-r14RmRSwzv5c+bWKUDaze6pXM7nOsiz1H8nvFHJvufc=", + "owner": "nix-community", + "repo": "all-cabal-json", + "rev": "d7c0434eebffb305071404edcf9d5cd99703878e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "hackage", + "repo": "all-cabal-json", + "type": "github" + } + }, + "crane": { + "flake": false, + "locked": { + "lastModified": 1661875961, + "narHash": "sha256-f1h/2c6Teeu1ofAHWzrS8TwBPcnN+EEu+z1sRVmMQTk=", + "owner": "ipetkov", + "repo": "crane", + "rev": "d9f394e4e20e97c2a60c3ad82c2b6ef99be19e24", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "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": { + "alejandra": "alejandra", + "all-cabal-json": "all-cabal-json", + "crane": "crane", + "devshell": "devshell", + "flake-parts": "flake-parts", + "flake-utils-pre-commit": "flake-utils-pre-commit", + "ghc-utils": "ghc-utils", + "gomod2nix": "gomod2nix", + "mach-nix": "mach-nix", + "nix-pypi-fetcher": "nix-pypi-fetcher", + "nixpkgs": [ + "nixpkgs" + ], + "poetry2nix": "poetry2nix", + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1669743839, + "narHash": "sha256-zxnaRaWfCJxy0JlORD4Kmtzd0pfpcGLnyaCIJY8OlIo=", + "owner": "nix-community", + "repo": "dream2nix", + "rev": "b6af93946130748f72671dfd2ab84a5aeaf1f191", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "dream2nix", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "dream2nix", + "alejandra", + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1657607339, + "narHash": "sha256-HaqoAwlbVVZH2n4P3jN2FFPMpVuhxDy1poNOR7kzODc=", + "owner": "nix-community", + "repo": "fenix", + "rev": "b814c83d9e6aa5a28d0cf356ecfdafb2505ad37d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1668450977, + "narHash": "sha256-cfLhMhnvXn6x1vPm+Jow3RiFAUSCw/l1utktCw5rVA4=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "d591857e9d7dd9ddbfba0ea02b43b927c3c0f1fa", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1667395993, @@ -15,13 +160,132 @@ "type": "github" } }, + "flake-utils-pre-commit": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flakeCompat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "ghc-utils": { + "flake": false, + "locked": { + "lastModified": 1662774800, + "narHash": "sha256-1Rd2eohGUw/s1tfvkepeYpg8kCEXiIot0RijapUjAkE=", + "ref": "refs/heads/master", + "rev": "bb3a2d3dc52ff0253fb9c2812bd7aa2da03e0fea", + "revCount": 1072, + "type": "git", + "url": "https://gitlab.haskell.org/bgamari/ghc-utils" + }, + "original": { + "type": "git", + "url": "https://gitlab.haskell.org/bgamari/ghc-utils" + } + }, + "gomod2nix": { + "flake": false, + "locked": { + "lastModified": 1627572165, + "narHash": "sha256-MFpwnkvQpauj799b4QTBJQFEddbD02+Ln5k92QyHOSk=", + "owner": "tweag", + "repo": "gomod2nix", + "rev": "67f22dd738d092c6ba88e420350ada0ed4992ae8", + "type": "github" + }, + "original": { + "owner": "tweag", + "repo": "gomod2nix", + "type": "github" + } + }, + "mach-nix": { + "flake": false, + "locked": { + "lastModified": 1634711045, + "narHash": "sha256-m5A2Ty88NChLyFhXucECj6+AuiMZPHXNbw+9Kcs7F6Y=", + "owner": "DavHau", + "repo": "mach-nix", + "rev": "4433f74a97b94b596fa6cd9b9c0402104aceef5d", + "type": "github" + }, + "original": { + "id": "mach-nix", + "type": "indirect" + } + }, + "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-pypi-fetcher": { + "flake": false, + "locked": { + "lastModified": 1669065297, + "narHash": "sha256-UStjXjNIuIm7SzMOWvuYWIHBkPUKQ8Id63BMJjnIDoA=", + "owner": "DavHau", + "repo": "nix-pypi-fetcher", + "rev": "a9885ac6a091576b5195d547ac743d45a2a615ac", + "type": "github" + }, + "original": { + "owner": "DavHau", + "repo": "nix-pypi-fetcher", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1669140675, - "narHash": "sha256-npzfyfLECsJWgzK/M4gWhykP2DNAJTYjgY2BWkz/oEQ=", + "lastModified": 1669542132, + "narHash": "sha256-DRlg++NJAwPh8io3ExBJdNW7Djs3plVI5jgYQ+iXAZQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2788904d26dda6cfa1921c5abb7a2466ffe3cb8c", + "rev": "a115bb9bd56831941be3776c8a94005867f316a7", "type": "github" }, "original": { @@ -31,11 +295,124 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1665349835, + "narHash": "sha256-UK4urM3iN80UXQ7EaOappDzcisYIuEURFRoGQ/yPkug=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "34c5293a71ffdb2fe054eb5288adc1882c1eb0b1", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "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" + } + }, + "poetry2nix": { + "flake": false, + "locked": { + "lastModified": 1666918719, + "narHash": "sha256-BkK42fjAku+2WgCOv2/1NrPa754eQPV7gPBmoKQBWlc=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "289efb187123656a116b915206e66852f038720e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "1.36.0", + "repo": "poetry2nix", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-utils": [ + "dream2nix", + "flake-utils-pre-commit" + ], + "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", + "mk-node-package": "mk-node-package", "nixpkgs": "nixpkgs" } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1657557289, + "narHash": "sha256-PRW+nUwuqNTRAEa83SfX+7g+g8nQ+2MMbasQ9nt6+UM=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "caf23f29144b371035b864a1017dbc32573ad56d", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index f05682ef1..e046b16b5 100644 --- a/flake.nix +++ b/flake.nix @@ -2,19 +2,42 @@ description = "Pterodactyl Panel"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; + 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"; + }; }; outputs = { self, - nixpkgs, + dream2nix, flake-utils, + mk-node-package, + nixpkgs, ... }: flake-utils.lib.eachDefaultSystem ( system: let + version = "latest"; + pkgs = import nixpkgs {inherit system;}; + mkNodePackage = mk-node-package.lib."${system}".mkNodePackage; php81WithExtensions = with pkgs; (php81.buildEnv { extensions = { @@ -30,6 +53,7 @@ xdebug.mode=debug ''; }); + composer = with pkgs; (php81Packages.composer.override {php = php81WithExtensions;}); caCertificates = pkgs.runCommand "ca-certificates" {} '' mkdir -p $out/etc/ssl/certs $out/etc/pki/tls/certs @@ -98,34 +122,147 @@ 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]; + }) + .packages + ."${system}" + ."pterodactyl/panel"; + + ui = mkNodePackage { + inherit src version; + + pname = "pterodactyl"; + buildInputs = []; + + buildPhase = '' + yarn run build + ''; + + 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 { - devShell = import ./shell.nix {inherit pkgs php81WithExtensions;}; + defaultPackage = panel; + devShell = import ./shell.nix {inherit composer php81WithExtensions pkgs;}; packages = { - development = pkgs.dockerTools.buildImage { - name = "pterodactyl/development"; - tag = "panel"; + inherit panel; - copyToRoot = pkgs.buildEnv { - name = "image-root"; - paths = with pkgs; [ - dockerTools.fakeNss - caCertificates - caddy - configs - coreutils - mysql80 - nodejs-18_x - nodePackages.npm - nodePackages.pnpm - nodePackages.yarn - php81WithExtensions - (php81Packages.composer.override {php = php81WithExtensions;}) - postgresql_14 - ]; - pathsToLink = ["/bin" "/etc"]; + development = with pkgs; + dockerTools.buildImage { + name = "pterodactyl/development"; + tag = "panel"; + + copyToRoot = pkgs.buildEnv { + name = "image-root"; + paths = [ + dockerTools.fakeNss + caCertificates + caddy + composer + configs + coreutils + mysql80 + nodejs-18_x + nodePackages.npm + nodePackages.pnpm + nodePackages.yarn + php81WithExtensions + postgresql_14 + ]; + 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 = []; + }; }; - }; }; } ); diff --git a/shell.nix b/shell.nix index 682c88f42..7ac24da45 100644 --- a/shell.nix +++ b/shell.nix @@ -1,14 +1,15 @@ { + composer ? null, + php81WithExtensions ? null, pkgs ? import {}, - php81WithExtensions, }: with pkgs; mkShell rec { buildInputs = [ alejandra + composer nodejs-18_x nodePackages.yarn php81WithExtensions - (php81Packages.composer.override {php = php81WithExtensions;}) ]; }