Add flake.nix, non-legacy builds, composer update, fix redirects

This commit is contained in:
Samuel Štancl 2025-09-28 22:55:47 +02:00
parent a675535e98
commit ab2fe374b9
16 changed files with 1108 additions and 504 deletions

4
.gitignore vendored
View file

@ -3,11 +3,11 @@ node_modules
yarn.lock yarn.lock
dist/tailwind.css dist/tailwind.css
result
build_local build_local
build_staging build_staging
build_production build_production
build_staging build_staging
vendor vendor
cache cache
source/assets/build/mix-manifest.json source/assets/build/mix-manifest.json

View file

@ -5,3 +5,23 @@ For the main repository, see [stancl/tenancy](https://github.com/stancl/tenancy)
## Dev ## Dev
You can use `npm run watch`, `npm run dev`, and `npm run production`. You can use `npm run watch`, `npm run dev`, and `npm run production`.
## Nix
A lot of the dependencies in this repo are pretty legacy software by now, so to make building easier
and more reproducible in the long term, we use Nix to wrap the build process.
Devshell: `nix develop`
Run (dev, watcher): `nix run`
Run (prod build into build_production): `nix run .#production`
Build (reproducible via Nix, result symlinked from store): `nix build`
Build (same as above, but using localhost:8000 as the base URL, prod *non-legacy* build): `nix build .#local`
Build (same as `#local` but only including /docs and /assets): `nix build .#minimalLocal`
Legacy builds assume it's the v3 site on the tenancyforlaravel.com domain. Non-legacy builds do not and as such remove some root level links on the frontend
(in other words non-legacy builds support minimal builds.)

View file

@ -1,4 +1,7 @@
{ {
"name": "stancl/tenancy-docs",
"description": "Tenancy for Laravel docs",
"license": "MIT",
"require": { "require": {
"tightenco/jigsaw": "^1.3", "tightenco/jigsaw": "^1.3",
"tightenco/jigsaw-docs-template": "^1.0", "tightenco/jigsaw-docs-template": "^1.0",
@ -9,4 +12,4 @@
"App\\Listeners\\": "listeners/" "App\\Listeners\\": "listeners/"
} }
} }
} }

1290
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -3,6 +3,7 @@
use Illuminate\Support\Str; use Illuminate\Support\Str;
return [ return [
'legacy' => intval(env('DOCS_LEGACY_DEPLOYMENT', '1')),
'baseUrl' => 'http://localhost:3000', 'baseUrl' => 'http://localhost:3000',
'production' => false, 'production' => false,
'siteName' => 'Tenancy for Laravel', 'siteName' => 'Tenancy for Laravel',

147
flake.lock generated Normal file
View file

@ -0,0 +1,147 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1747046372,
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1758690382,
"narHash": "sha256-NY3kSorgqE5LMm1LqNwGne3ZLMF2/ILgLpFr1fS4X3o=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e643668fd71b949c53f8626614b21ff71a07379d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1758262103,
"narHash": "sha256-aBGl3XEOsjWw6W3AHiKibN7FeoG73dutQQEqnd/etR8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "12bd230118a1901a4a5d393f9f56b6ad7e571d01",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"phps": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs_2",
"utils": "utils"
},
"locked": {
"lastModified": 1758973129,
"narHash": "sha256-Kyrk9w/7PguWmnxPSx6DZzr3A07ZBzyV/4O8O52VDAM=",
"owner": "fossar",
"repo": "nix-phps",
"rev": "b325c114bef951cc334d1883fe6c17b286b59728",
"type": "github"
},
"original": {
"owner": "fossar",
"repo": "nix-phps",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"phps": "phps"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"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"
}
},
"utils": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

106
flake.nix Normal file
View file

@ -0,0 +1,106 @@
{
description = "PHP 7.4 development environment for tenancy docs";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
phps.url = "github:fossar/nix-phps";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, phps, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
php74 = phps.packages.${system}.php74;
in
{
devShells.default = pkgs.mkShell {
packages = [
php74
php74.packages.composer
pkgs.nodejs_24
];
shellHook = ''
echo "Welcome to the tenancy docs development environment!"
echo "PHP version: $(php -v | head -n 1)"
echo "Node.js version: $(node -v)"
echo "You can use 'npm run watch' for local development, see package.json for other scripts."
'';
};
# npm run watch
apps.default = {
type = "app";
program = "${pkgs.writeShellApplication {
name = "build-docs";
runtimeInputs = [ php74 php74.packages.composer pkgs.nodejs_24 ];
text = ''
echo "Installing dependencies..."
composer install
npm install
echo "Running npm run watch..."
npm run watch
'';
}}/bin/build-docs";
};
# npm run production
apps.production = {
type = "app";
program = "${pkgs.writeShellApplication {
name = "build-docs";
runtimeInputs = [ php74 php74.packages.composer pkgs.nodejs_24 ];
text = ''
echo "Installing dependencies..."
composer install
npm install
echo "Building production site..."
npm run production
echo "Build complete! Output in build_production/"
'';
}}/bin/build-docs";
};
lib.mkTenancyDocs = { baseUrl ? "https://tenancyforlaravel.com", legacy ? true, minimal ? false }: let
composerDeps = php74.buildComposerProject2 {
pname = "tenancy-docs-composer";
version = "1.0.0";
src = ./.;
vendorHash = "sha256-X7yyQ/fV5vKul+jZlw1vMsPsMrBMVUGhMMDMJDUugsU=";
postInstall = ''
cp -R ./vendor/* $out
'';
};
in pkgs.buildNpmPackage {
pname = "tenancy-docs";
version = "1.0.0";
src = ./.;
nodejs = pkgs.nodejs_24;
npmDepsHash = "sha256-ufeN4BXCAlZZypViznlkXWosSgZ5nsPvMJJ0FVLXxJI=";
buildInputs = [ php74 ];
buildPhase = ''
cp -R ${composerDeps} ./vendor
JIGSAW_BASE_URL="${baseUrl}" DOCS_LEGACY_DEPLOYMENT=${toString legacy} npm run production
'';
installPhase = if minimal then ''
mkdir $out
cp -R ./build_production/docs/ $out/docs
cp -R ./build_production/assets/ $out/assets
'' else ''
cp -R ./build_production/ $out/
'';
};
packages.default = self.lib.${system}.mkTenancyDocs {};
packages.local = self.lib.${system}.mkTenancyDocs { baseUrl = "http://localhost:8000"; legacy = false; };
packages.minimalLocal = self.lib.${system}.mkTenancyDocs { baseUrl = "http://localhost:8000"; legacy = false; minimal = true; };
}
);
}

View file

@ -1,9 +1,9 @@
{ {
"private": true, "private": true,
"scripts": { "scripts": {
"local": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --env=local --config=node_modules/laravel-mix/setup/webpack.config.js", "local": "cross-env NODE_ENV=development NODE_OPTIONS=--openssl-legacy-provider node_modules/webpack/bin/webpack.js --progress --hide-modules --env=local --config=node_modules/laravel-mix/setup/webpack.config.js",
"staging": "cross-env NODE_ENV=staging node_modules/webpack/bin/webpack.js --progress --hide-modules --env=staging --config=node_modules/laravel-mix/setup/webpack.config.js", "staging": "cross-env NODE_ENV=staging NODE_OPTIONS=--openssl-legacy-provider node_modules/webpack/bin/webpack.js --progress --hide-modules --env=staging --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --env=production --config=node_modules/laravel-mix/setup/webpack.config.js", "production": "cross-env NODE_ENV=production NODE_OPTIONS=--openssl-legacy-provider node_modules/webpack/bin/webpack.js --progress --hide-modules --env=production --config=node_modules/laravel-mix/setup/webpack.config.js",
"dev": "npm run local", "dev": "npm run local",
"watch": "npm run local -- --watch" "watch": "npm run local -- --watch"
}, },

View file

@ -27,10 +27,12 @@
<meta name="previewify:image" content="https://tenancyforlaravel.com/assets/img/previewify-image.png"> <meta name="previewify:image" content="https://tenancyforlaravel.com/assets/img/previewify-image.png">
<meta name="theme-color" content="#5850EC"> <meta name="theme-color" content="#5850EC">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> @if($page->legacy)
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="manifest" href="/site.webmanifest"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
@endif
<meta name="docsearch:language" content="en" /> <meta name="docsearch:language" content="en" />
<meta name="docsearch:version" content="{{ $page->version() }}" /> <meta name="docsearch:version" content="{{ $page->version() }}" />
@ -60,7 +62,9 @@
<link href="https://rsms.me/inter/inter.css" rel="stylesheet"> <link href="https://rsms.me/inter/inter.css" rel="stylesheet">
<link rel="stylesheet" href="{{ mix('css/main.css', 'assets/build') }}"> <link rel="stylesheet" href="{{ mix('css/main.css', 'assets/build') }}">
<script async data-api="/_hive" src="/bee.js"></script> @if($page->legacy)
<script async data-api="/_hive" src="/bee.js"></script>
@endif
<script src="{{ mix('js/turbolinks.js', 'assets/build') }}"></script> <script src="{{ mix('js/turbolinks.js', 'assets/build') }}"></script>
@if ($page->docsearchApiKey && $page->docsearchIndexName) @if ($page->docsearchApiKey && $page->docsearchIndexName)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -2,7 +2,7 @@
<html lang="en-US"> <html lang="en-US">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=getting-started"> <meta http-equiv="refresh" content="0; url={{ $page->baseUrl }}/docs/v1/getting-started">
<title>stancl/tenancy</title> <title>stancl/tenancy</title>
</head> </head>
</html> </html>

View file

@ -2,7 +2,7 @@
<html lang="en-US"> <html lang="en-US">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=getting-started"> <meta http-equiv="refresh" content="0; url={{ $page->baseUrl }}/docs/v2/getting-started">
<title>stancl/tenancy</title> <title>stancl/tenancy</title>
</head> </head>
</html> </html>

View file

@ -5,7 +5,7 @@ require('laravel-mix-jigsaw');
mix.disableSuccessNotifications(); mix.disableNotifications();
mix.setPublicPath('source/assets/build'); mix.setPublicPath('source/assets/build');
mix.js('source/_assets/js/main.js', 'js') mix.js('source/_assets/js/main.js', 'js')