nixbld: disable Nix flarum module
hacky and buggy https://github.com/NixOS/nixpkgs/pull/96869
This commit is contained in:
parent
9185cdcec1
commit
7b6ed95090
@ -16,7 +16,6 @@ in
|
||||
[
|
||||
./hardware-configuration.nix
|
||||
./backup-module.nix
|
||||
./flarum.nix
|
||||
(builtins.fetchTarball {
|
||||
url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/fb1cc04c0a517d4200237b02c3472bcaf9104afb/nixos-mailserver-nixos.tar.gz";
|
||||
sha256 = "0vsvgxxg5cgmzwj98171j7h5l028f1yq784alb3lxgbk8znfk51y";
|
||||
@ -647,14 +646,14 @@ in
|
||||
"forum.m-labs.hk" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "nixbld.m-labs.hk";
|
||||
root = "${config.services.flarum.installPath}/public";
|
||||
root = "/var/www/flarum/public";
|
||||
locations."~ \.php$".extraConfig = ''
|
||||
fastcgi_pass unix:${config.services.phpfpm.pools.flarum.socket};
|
||||
fastcgi_index index.php;
|
||||
'';
|
||||
extraConfig = ''
|
||||
index index.php;
|
||||
include ${config.services.flarum.installPath}/.nginx.conf;
|
||||
include /var/www/flarum/.nginx.conf;
|
||||
'';
|
||||
};
|
||||
"call.m-labs.hk" = {
|
||||
@ -699,7 +698,7 @@ in
|
||||
package = pkgs.mariadb;
|
||||
};
|
||||
services.phpfpm.pools.flarum = {
|
||||
user = config.services.flarum.user;
|
||||
user = "nobody";
|
||||
settings = {
|
||||
"listen.owner" = "nginx";
|
||||
"listen.group" = "nginx";
|
||||
|
@ -1,239 +0,0 @@
|
||||
# This file originates from composer2nix
|
||||
|
||||
{ stdenv, lib, writeTextFile, fetchurl, php, unzip, phpPackages }:
|
||||
|
||||
let
|
||||
inherit (phpPackages) composer;
|
||||
buildZipPackage = { name, src }:
|
||||
stdenv.mkDerivation {
|
||||
inherit name src;
|
||||
buildInputs = [ unzip ];
|
||||
buildCommand = ''
|
||||
unzip $src
|
||||
baseDir=$(find . -type d -mindepth 1 -maxdepth 1)
|
||||
cd $baseDir
|
||||
mkdir -p $out
|
||||
mv * $out
|
||||
'';
|
||||
};
|
||||
|
||||
buildPackage =
|
||||
{ name
|
||||
, src
|
||||
, packages ? {}
|
||||
, devPackages ? {}
|
||||
, buildInputs ? []
|
||||
, symlinkDependencies ? false
|
||||
, executable ? false
|
||||
, removeComposerArtifacts ? false
|
||||
, postInstall ? ""
|
||||
, noDev ? false
|
||||
, composerExtraArgs ? ""
|
||||
, unpackPhase ? "true"
|
||||
, buildPhase ? "true"
|
||||
, ...}@args:
|
||||
|
||||
let
|
||||
reconstructInstalled = writeTextFile {
|
||||
name = "reconstructinstalled.php";
|
||||
executable = true;
|
||||
text = ''
|
||||
#! ${php}/bin/php
|
||||
<?php
|
||||
if(file_exists($argv[1]))
|
||||
{
|
||||
$composerLockStr = file_get_contents($argv[1]);
|
||||
|
||||
if($composerLockStr === false)
|
||||
{
|
||||
fwrite(STDERR, "Cannot open composer.lock contents\n");
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$config = json_decode($composerLockStr, true);
|
||||
|
||||
if(array_key_exists("packages", $config))
|
||||
$allPackages = $config["packages"];
|
||||
else
|
||||
$allPackages = array();
|
||||
|
||||
${lib.optionalString (!noDev) ''
|
||||
if(array_key_exists("packages-dev", $config))
|
||||
$allPackages = array_merge($allPackages, $config["packages-dev"]);
|
||||
''}
|
||||
|
||||
$packagesStr = json_encode($allPackages, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
print($packagesStr);
|
||||
}
|
||||
}
|
||||
else
|
||||
print("[]");
|
||||
?>
|
||||
'';
|
||||
};
|
||||
|
||||
constructBin = writeTextFile {
|
||||
name = "constructbin.php";
|
||||
executable = true;
|
||||
text = ''
|
||||
#! ${php}/bin/php
|
||||
<?php
|
||||
$composerJSONStr = file_get_contents($argv[1]);
|
||||
|
||||
if($composerJSONStr === false)
|
||||
{
|
||||
fwrite(STDERR, "Cannot open composer.json contents\n");
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$config = json_decode($composerJSONStr, true);
|
||||
|
||||
if(array_key_exists("bin-dir", $config))
|
||||
$binDir = $config["bin-dir"];
|
||||
else
|
||||
$binDir = "bin";
|
||||
|
||||
if(array_key_exists("bin", $config))
|
||||
{
|
||||
if(!file_exists("vendor/".$binDir))
|
||||
mkdir("vendor/".$binDir);
|
||||
|
||||
foreach($config["bin"] as $bin)
|
||||
symlink("../../".$bin, "vendor/".$binDir."/".basename($bin));
|
||||
}
|
||||
}
|
||||
?>
|
||||
'';
|
||||
};
|
||||
|
||||
bundleDependencies = dependencies:
|
||||
lib.concatMapStrings (dependencyName:
|
||||
let
|
||||
dependency = dependencies.${dependencyName};
|
||||
in
|
||||
''
|
||||
${if dependency.targetDir == "" then ''
|
||||
vendorDir="$(dirname ${dependencyName})"
|
||||
mkdir -p "$vendorDir"
|
||||
${if symlinkDependencies then
|
||||
''ln -s "${dependency.src}" "$vendorDir/$(basename "${dependencyName}")"''
|
||||
else
|
||||
''cp -av "${dependency.src}" "$vendorDir/$(basename "${dependencyName}")"''
|
||||
}
|
||||
'' else ''
|
||||
namespaceDir="${dependencyName}/$(dirname "${dependency.targetDir}")"
|
||||
mkdir -p "$namespaceDir"
|
||||
${if symlinkDependencies then
|
||||
''ln -s "${dependency.src}" "$namespaceDir/$(basename "${dependency.targetDir}")"''
|
||||
else
|
||||
''cp -av "${dependency.src}" "$namespaceDir/$(basename "${dependency.targetDir}")"''
|
||||
}
|
||||
''}
|
||||
'') (builtins.attrNames dependencies);
|
||||
|
||||
extraArgs = removeAttrs args [ "name" "packages" "devPackages" "buildInputs" ];
|
||||
in
|
||||
stdenv.mkDerivation ({
|
||||
name = "composer-${name}";
|
||||
buildInputs = [ php composer ] ++ buildInputs;
|
||||
|
||||
inherit unpackPhase buildPhase;
|
||||
|
||||
installPhase = ''
|
||||
${if executable then ''
|
||||
mkdir -p $out/share/php
|
||||
cp -av $src $out/share/php/$name
|
||||
chmod -R u+w $out/share/php/$name
|
||||
cd $out/share/php/$name
|
||||
'' else ''
|
||||
cp -av $src $out
|
||||
chmod -R u+w $out
|
||||
cd $out
|
||||
''}
|
||||
|
||||
# Remove unwanted files
|
||||
rm -f *.nix
|
||||
|
||||
export HOME=$TMPDIR
|
||||
|
||||
# Remove the provided vendor folder if it exists
|
||||
rm -Rf vendor
|
||||
|
||||
# If there is no composer.lock file, compose a dummy file.
|
||||
# Otherwise, composer attempts to download the package.json file from
|
||||
# the registry which we do not want.
|
||||
if [ ! -f composer.lock ]
|
||||
then
|
||||
cat > composer.lock <<EOF
|
||||
{
|
||||
"packages": []
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Reconstruct the installed.json file from the lock file
|
||||
mkdir -p vendor/composer
|
||||
${php}/bin/php ${reconstructInstalled} composer.lock > vendor/composer/installed.json
|
||||
|
||||
# Copy or symlink the provided dependencies
|
||||
cd vendor
|
||||
${bundleDependencies packages}
|
||||
${lib.optionalString (!noDev) (bundleDependencies devPackages)}
|
||||
cd ..
|
||||
|
||||
# Reconstruct autoload scripts
|
||||
# We use the optimize feature because Nix packages cannot change after they have been built
|
||||
# Using the dynamic loader for a Nix package is useless since there is nothing to dynamically reload.
|
||||
composer dump-autoload --optimize ${lib.optionalString noDev "--no-dev"} ${composerExtraArgs}
|
||||
|
||||
# Run the install step as a validation to confirm that everything works out as expected
|
||||
composer install --optimize-autoloader ${lib.optionalString noDev "--no-dev"} ${composerExtraArgs}
|
||||
|
||||
${lib.optionalString executable ''
|
||||
# Reconstruct the bin/ folder if we deploy an executable project
|
||||
${php}/bin/php ${constructBin} composer.json
|
||||
ln -s $(pwd)/vendor/bin $out/bin
|
||||
''}
|
||||
|
||||
${lib.optionalString (!symlinkDependencies) ''
|
||||
# Patch the shebangs if possible
|
||||
if [ -d $(pwd)/vendor/bin ]
|
||||
then
|
||||
# Look for all executables in bin/
|
||||
for i in $(pwd)/vendor/bin/*
|
||||
do
|
||||
# Look for their location
|
||||
realFile=$(readlink -f "$i")
|
||||
|
||||
# Restore write permissions
|
||||
chmod u+wx "$(dirname "$realFile")"
|
||||
chmod u+w "$realFile"
|
||||
|
||||
# Patch shebang
|
||||
sed -e "s|#!/usr/bin/php|#!${php}/bin/php|" \
|
||||
-e "s|#!/usr/bin/env php|#!${php}/bin/php|" \
|
||||
"$realFile" > tmp
|
||||
mv tmp "$realFile"
|
||||
chmod u+x "$realFile"
|
||||
done
|
||||
fi
|
||||
''}
|
||||
|
||||
if [ "$removeComposerArtifacts" = "1" ]
|
||||
then
|
||||
# Remove composer stuff
|
||||
rm -f composer.json composer.lock
|
||||
fi
|
||||
|
||||
# Execute post install hook
|
||||
runHook postInstall
|
||||
'';
|
||||
} // extraArgs);
|
||||
in
|
||||
{
|
||||
composer = lib.makeOverridable composer;
|
||||
buildZipPackage = lib.makeOverridable buildZipPackage;
|
||||
buildPackage = lib.makeOverridable buildPackage;
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
{
|
||||
"name": "flarum/flarum",
|
||||
"description": "Delightfully simple forum software.",
|
||||
"type": "project",
|
||||
"keywords": [
|
||||
"forum",
|
||||
"discussion"
|
||||
],
|
||||
"homepage": "https://flarum.org/",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Franz Liedke",
|
||||
"email": "franz@develophp.org"
|
||||
},
|
||||
{
|
||||
"name": "Daniel Klabbers",
|
||||
"email": "daniel@klabbers.email",
|
||||
"homepage": "https://luceos.com"
|
||||
},
|
||||
{
|
||||
"name": "David Sevilla Martin",
|
||||
"email": "me+flarum@datitisev.me",
|
||||
"homepage": "https://datitisev.me"
|
||||
},
|
||||
{
|
||||
"name": "Clark Winkelmann",
|
||||
"email": "clark.winkelmann@gmail.com",
|
||||
"homepage": "https://clarkwinkelmann.com"
|
||||
},
|
||||
{
|
||||
"name": "Matthew Kilgore",
|
||||
"email": "matthew@kilgore.dev"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"source": "https://github.com/flarum/flarum",
|
||||
"docs": "https://flarum.org/docs/"
|
||||
},
|
||||
"require": {
|
||||
"flarum/bbcode": "*",
|
||||
"flarum/core": "*",
|
||||
"flarum/emoji": "*",
|
||||
"flarum/flags": "*",
|
||||
"flarum/lang-english": "*",
|
||||
"flarum/likes": "*",
|
||||
"flarum/markdown": "*",
|
||||
"flarum/mentions": "*",
|
||||
"flarum/sticky": "*",
|
||||
"flarum/subscriptions": "*",
|
||||
"flarum/suspend": "*",
|
||||
"flarum/tags": "*",
|
||||
"fof/upload": "*",
|
||||
"fof/subscribed": "*"
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
},
|
||||
"minimum-stability": "beta",
|
||||
"prefer-stable": true
|
||||
}
|
7937
nixbld-etc-nixos/flarum/composer.lock
generated
7937
nixbld-etc-nixos/flarum/composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,13 +0,0 @@
|
||||
{pkgs ? import <nixpkgs> {
|
||||
inherit system;
|
||||
}, system ? builtins.currentSystem, noDev ? false}:
|
||||
|
||||
let
|
||||
composerEnv = import ./composer-env.nix {
|
||||
inherit (pkgs) stdenv lib writeTextFile fetchurl php unzip phpPackages;
|
||||
};
|
||||
in
|
||||
import ./php-packages.nix {
|
||||
inherit composerEnv noDev;
|
||||
inherit (pkgs) fetchurl fetchgit fetchhg fetchsvn;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user