Verified Commit 1ba15c10 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch 'dev-spago-next' into dev-add-edge-weight-control

parents abebff62 a5abbf3c
use nix #use nix
use flake
...@@ -11,6 +11,7 @@ reports ...@@ -11,6 +11,7 @@ reports
node_modules node_modules
.DS_Store .DS_Store
/.direnv/
/bower_components/ /bower_components/
/node_modules/ /node_modules/
/.cache/ /.cache/
......
# Thanks to: # Fixing the nixos image saves CI time so it doesn't have to pull new
# https://vadosware.io/post/zero-to-continuous-integrated-testing-a-haskell-project-with-gitlab/ #image every time (nixos/nix updates quite often).
# # image: nixos/nix:latest
# image: nixos/nix:2.22.0
image: nixos/nix:latest
variables:
STACK_ROOT: "${CI_PROJECT_DIR}/.stack-root"
STACK_OPTS: "--system-ghc"
#before_script: #before_script:
#- nix-env -iA nixpkgs.nix nixpkgs.cacert #- nix-env -iA nixpkgs.nix nixpkgs.cacert
...@@ -14,19 +9,18 @@ variables: ...@@ -14,19 +9,18 @@ variables:
#- apt-get install make xz-utils #- apt-get install make xz-utils
stages: stages:
- deps # - deps
- compile - compile
- test - test
deps: # deps:
stage: deps # stage: deps
cache: # cache:
paths: # paths:
- /nix/store # - /nix/store
- node_modules/ # #- node_modules/
#- ${CI_PROJECT_DIR}/bun.lockb # script:
script: # - nix-shell shell.nix --run 'bun install --skip-builds'
- nix-shell shell.nix --run 'bun install --skip-builds'
compile: compile:
stage: compile stage: compile
...@@ -36,10 +30,9 @@ compile: ...@@ -36,10 +30,9 @@ compile:
- node_modules/ - node_modules/
- output/ - output/
- .spago/ - .spago/
#- ${CI_PROJECT_DIR}/bun.lockb
script: script:
- nix-shell shell.nix --run fix-bun - nix --extra-experimental-features "nix-command flakes" run .#compile
- nix-shell shell.nix --run compile
test: test:
stage: test stage: test
...@@ -51,7 +44,8 @@ test: ...@@ -51,7 +44,8 @@ test:
- node_modules/ - node_modules/
- output/ - output/
- .spago/ - .spago/
#- ${CI_PROJECT_DIR}/bun.lockb
script: script:
- nix-shell shell.nix --run fix-bun - nix --extra-experimental-features "nix-command flakes" run .#test-ps
- nix-shell shell.nix --run test-ps
- nix-collect-garbage --delete-older-than 14d
...@@ -53,34 +53,16 @@ nix-env (Nix) 2.11.0 ...@@ -53,34 +53,16 @@ nix-env (Nix) 2.11.0
``` ```
To build the frontend just execute the install script at the root at the project: To build the frontend just execute the install script at the root at the project:
``` ```shell
./install ./install
``` ```
**Local instance is ready!** (Example: http://localhost:8000/) ```shell
nix -L develop
#### [bun](https://bun.sh/)
We use [bun](https://bun.sh/) as the package manager.
Sometimes, when you remove `node_modules` it complains about
`better-sqlite3`:
```
file:///home/przemek/GARGANTEXT/haskell-gargantext/purescript-gargantext/node_modules/spago/bin/bundle.js:61138
throw util.fromLeft(step3);
```
Just issue this (I guess it reinstalls `better-sqlite3` for local bun dev):
```sh
cd node_modules/better-sqlite3
bun install
cd ../..
```
or
```sh
nix-shell shell.nix --run fix-bun
``` ```
**Local instance is ready!** (Example: http://localhost:8000/)
### 2. Use Docker setup ### 2. Use Docker setup
You will need docker and docker-compose installed. You will need docker and docker-compose installed.
...@@ -122,6 +104,6 @@ nix-shell --run build ...@@ -122,6 +104,6 @@ nix-shell --run build
To compile CSS (Sass): To compile CSS (Sass):
```shell ```shell
nix-shell --run "bun css" nix-shell --run "npm run css"
``` ```
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1701282334,
"narHash": "sha256-MxCVrXY6v4QmfTwIysjjaX0XUhqBbxTWWB4HXtDYsdk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "057f9aecfb71c4437d2b27d3323df7f93c010b7e",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"purescript-overlay": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": [
"nixpkgs"
],
"slimlock": "slimlock"
},
"locked": {
"lastModified": 1713366964,
"narHash": "sha256-s1WUptOTTAQ3aW6JlIpDgWofoQF5vp7q8ItbTeSxLL4=",
"owner": "thomashoneyman",
"repo": "purescript-overlay",
"rev": "235afffdb751d83c7775b334e5be944848fc24ad",
"type": "github"
},
"original": {
"owner": "thomashoneyman",
"repo": "purescript-overlay",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"purescript-overlay": "purescript-overlay"
}
},
"slimlock": {
"inputs": {
"nixpkgs": [
"purescript-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1688756706,
"narHash": "sha256-xzkkMv3neJJJ89zo3o2ojp7nFeaZc2G0fYwNXNJRFlo=",
"owner": "thomashoneyman",
"repo": "slimlock",
"rev": "cf72723f59e2340d24881fd7bf61cb113b4c407c",
"type": "github"
},
"original": {
"owner": "thomashoneyman",
"repo": "slimlock",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
{
description = "Gargantext PureScript fronetnd";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
inputs.purescript-overlay = {
url = "github:thomashoneyman/purescript-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, purescript-overlay }:
flake-utils.lib.eachDefaultSystem (system:
#let pkgs = nixpkgs.legacyPackages.${system};
let
pkgs = import nixpkgs {
inherit system;
overlays = [ purescript-overlay.overlays.default ];
};
dependencies = with pkgs; [
purescript
#spago-unstable
nodejs
nodePackages.npm
];
serve = pkgs.writeShellScriptBin "serve" ''
set -e
#yarn server
npm run server
'';
build-watch = pkgs.writeShellScriptBin "build-watch" ''
set -e
echo "Build watch"
npm spago build -w --then browserify
'';
build-zephyr = pkgs.writeShellScriptBin "build-zephyr" ''
set -e
npm spago build --purs-args '--codegen corefn,js'
zephyr -f Main.main
browserify-zephyr
'';
minify-bundle = pkgs.writeShellScriptBin "minify-bundle" ''
set -e
npm run minify
'';
in
{
packages = {
compile = pkgs.writeShellApplication {
name = "compile";
runtimeInputs = dependencies;
text = ''
#!${pkgs.stdenv.shell}
set -e
echo "Installing JS Dependencies"
#${pkgs.nodePackages.npm}/bin/npm install
# https://docs.npmjs.com/cli/v9/commands/npm-ci
${pkgs.nodePackages.npm}/bin/npm ci
#${pkgs.nodePackages.npm}/bin/npm install --dev
echo "Compiling"
${pkgs.nodePackages.npm}/bin/npm run build
'';
};
build = pkgs.writeShellApplication {
name = "build";
runtimeInputs = dependencies;
text = ''
#!${pkgs.stdenv.shell}
set -e
${self.packages.${system}.compile}/bin/compile
echo "Bundling"
${pkgs.nodePackages.npm}/bin/npm run bundle
'';
};
test-ps = pkgs.writeShellApplication {
name = "test-ps";
runtimeInputs = dependencies;
text = ''
#!${pkgs.stdenv.shell}
set -e
${self.packages.${system}.compile}/bin/compile
echo "Testing"
${pkgs.nodePackages.npm}/bin/npm run test
'';
};
repl = pkgs.writeShellApplication {
name = "repl";
runtimeInputs = dependencies;
text = ''
#!${pkgs.stdenv.shell}
${pkgs.nodePackages.npm}/bin/npm run repl
'';
};
build-css = pkgs.writeShellApplication {
name = "build-css";
runtimeInputs = dependencies;
text = ''
#!${pkgs.stdenv.shell}
set -e
#yarn css
${pkgs.nodePackages.npm}/bin/npm run css
'';
};
};
devShells.default = pkgs.mkShell {
name = "purescript-gargantext";
#inputsFrom = builtins.attrValues self.packages.${system};
buildInputs = with pkgs; (dependencies ++ [
# scripts
self.packages.${system}.build
self.packages.${system}.compile
self.packages.${system}.test-ps
self.packages.${system}.repl
self.packages.${system}.build-css
build-watch
build-zephyr
minify-bundle
serve
]);
};
}
);
}
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
# To get infos # To get infos
# nix-shell -p nix-info --run "nix-info -m" # nix-shell -p nix-info --run "nix-info -m"
nix-channel --update # nix-channel --update
nix-env -iA nixpkgs.nix nixpkgs.cacert # nix-env -iA nixpkgs.nix nixpkgs.cacert
nix-shell --show-trace --option build-fallback true --run 'bun install' # nix-shell --show-trace --option build-fallback true --run 'bun install'
nix-shell --show-trace --option build-fallback true --run fix-bun # nix-shell --show-trace --option build-fallback true --run fix-bun
nix-shell --show-trace --option build-fallback true --run build # nix-shell --show-trace --option build-fallback true --run build
#nix run .#install
nix run .#build
Avoids needing xcrun or xcodebuild in PATH for native package builds
diff --git a/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py
index a75d8ee..476440d 100644
--- a/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py
+++ b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py
@@ -522,7 +522,13 @@ class XcodeSettings:
# Since the CLT has no SDK paths anyway, returning None is the
# most sensible route and should still do the right thing.
try:
- return GetStdoutQuiet(["xcrun", "--sdk", sdk, infoitem])
+ #return GetStdoutQuiet(["xcrun", "--sdk", sdk, infoitem])
+ return {
+ "--show-sdk-platform-path": "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform",
+ "--show-sdk-path": "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk",
+ "--show-sdk-build-version": "19A547",
+ "--show-sdk-version": "10.15"
+ }[infoitem]
except GypError:
pass
@@ -1499,7 +1505,8 @@ def XcodeVersion():
version = ""
build = ""
try:
- version_list = GetStdoutQuiet(["xcodebuild", "-version"]).splitlines()
+ #version_list = GetStdoutQuiet(["xcodebuild", "-version"]).splitlines()
+ version_list = []
# In some circumstances xcodebuild exits 0 but doesn't return
# the right results; for example, a user on 10.7 or 10.8 with
# a bogus path set via xcode-select
@@ -1510,7 +1517,8 @@ def XcodeVersion():
version = version_list[0].split()[-1] # Last word on first line
build = version_list[-1].split()[-1] # Last word on last line
except GypError: # Xcode not installed so look for XCode Command Line Tools
- version = CLTVersion() # macOS Catalina returns 11.0.0.0.1.1567737322
+ #version = CLTVersion() # macOS Catalina returns 11.0.0.0.1.1567737322
+ version = "11.0.0.0.1.1567737322"
if not version:
raise GypError("No Xcode or CLT version detected!")
# Be careful to convert "4.2.3" to "0423" and "11.0.0" to "1100":
Disable v8 system instrumentation on Darwin
On Darwin, the v8 system instrumentation requires the header "os/signpost.h"
which is available since apple_sdk 11+. See: https://github.com/nodejs/node/issues/39584
--- old/tools/v8_gypfiles/features.gypi
+++ new/tools/v8_gypfiles/features.gypi
@@ -62,7 +62,7 @@
}, {
'is_component_build': 0,
}],
- ['OS == "win" or OS == "mac"', {
+ ['OS == "win"', {
# Sets -DENABLE_SYSTEM_INSTRUMENTATION. Enables OS-dependent event tracing
'v8_enable_system_instrumentation': 1,
}, {
This patch is based off of npm tag v9.1.5.
This introduces fixes for 4 issues:
1. When node-gyp is included as a dependency in a project, any scripts that run it will not use the copy included in Node. This is problematic because we patch node-gyp to work without xcbuild on Darwin, leading to these packages failing to build with a sandbox on Darwin.
2. When a Git dependency contains install scripts, it has to be built just like any other package. Thus, we need to patch shebangs appropriately, just like in npmConfigHook.
3. We get useless warnings that clog up logs when using a v1 lockfile, so we silence them.
4. npm looks at a hidden lockfile to determine if files have binaries to link into `node_modules/.bin`. When using a v1 lockfile offline, this lockfile does not contain enough info, leading to binaries for packages such as Webpack not being available to scripts. We used to work around this by making npm ignore the hidden lockfile by creating a file, but now we just disable the code path entirely.
To update:
1. Run `git diff` from an npm checkout
2. Run `fix-npm-patch-paths.sh`
3. Include/update this frontmatter, please!
diff --git a/deps/npm/node_modules/@npmcli/run-script/lib/set-path.js b/deps/npm/node_modules/@npmcli/run-script/lib/set-path.js
index c59c270d9..98785192f 100644
--- a/deps/npm/node_modules/@npmcli/run-script/lib/set-path.js
+++ b/deps/npm/node_modules/@npmcli/run-script/lib/set-path.js
@@ -12,7 +12,10 @@ const setPATH = (projectPath, binPaths, env) => {
.reduce((set, p) => set.concat(p.filter(concatted => !set.includes(concatted))), [])
.join(delimiter)
- const pathArr = []
+ // Ensure when using buildNpmPackage hooks that Node.js'
+ // bundled copy of node-gyp is used, instead of any copy
+ // pulled in as a dependency.
+ const pathArr = process.env['NIX_NODEJS_BUILDNPMPACKAGE'] ? [nodeGypPath, PATH] : [];
if (binPaths) {
pathArr.push(...binPaths)
}
@@ -26,7 +29,8 @@ const setPATH = (projectPath, binPaths, env) => {
pp = p
p = dirname(p)
} while (p !== pp)
- pathArr.push(nodeGypPath, PATH)
+ if (!process.env['NIX_NODEJS_BUILDNPMPACKAGE']) { pathArr.push(nodeGypPath, PATH) }
+
const pathVal = pathArr.join(delimiter)
diff --git a/deps/npm/node_modules/pacote/lib/git.js b/deps/npm/node_modules/pacote/lib/git.js
index 1fa8b1f96..a026bb50d 100644
--- a/deps/npm/node_modules/pacote/lib/git.js
+++ b/deps/npm/node_modules/pacote/lib/git.js
@@ -188,6 +188,24 @@ class GitFetcher extends Fetcher {
}
noPrepare.push(this.resolved)
+ if (process.env['NIX_NODEJS_BUILDNPMPACKAGE']) {
+ const spawn = require('@npmcli/promise-spawn')
+
+ const npmWithNixFlags = (args, cmd) => spawn('bash', ['-c', 'npm ' + args + ` $npm${cmd}Flags "$\{npm${cmd}FlagsArray[@]}" $npmFlags "$\{npmFlagsArray[@]}"`], { cwd: dir, env: { ...process.env, _PACOTE_NO_PREPARE_: noPrepare.join('\n') } }, { message: `\`npm ${args}\` failed` })
+ const patchShebangs = () => spawn('bash', ['-c', 'source $stdenv/setup; patchShebangs node_modules'], { cwd: dir })
+
+ // the DirFetcher will do its own preparation to run the prepare scripts
+ // All we have to do is put the deps in place so that it can succeed.
+ //
+ // We ignore this.npmConfig to maintain an environment that's as close
+ // to the rest of the build as possible.
+ return spawn('bash', ['-c', '$prefetchNpmDeps --fixup-lockfile package-lock.json'], { cwd: dir })
+ .then(() => npmWithNixFlags('ci --ignore-scripts', 'Install'))
+ .then(patchShebangs)
+ .then(() => npmWithNixFlags('rebuild', 'Rebuild'))
+ .then(patchShebangs)
+ }
+
// the DirFetcher will do its own preparation to run the prepare scripts
// All we have to do is put the deps in place so that it can succeed.
return npm(
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js
index 2ea66ac33..25e671318 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js
@@ -740,7 +740,7 @@ This is a one-time fix-up, please be patient...
node.package = { ...mani, _id: `${mani.name}@${mani.version}` }
} catch (er) {
const warning = `Could not fetch metadata for ${name}@${id}`
- log.warn(heading, warning, er)
+ if (!process.env['NIX_NODEJS_BUILDNPMPACKAGE']) { log.warn(heading, warning, er) }
}
this.finishTracker(t)
})
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-actual.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-actual.js
index 6c3f917c6..ec21d2cc4 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-actual.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-actual.js
@@ -147,7 +147,7 @@ module.exports = cls => class ActualLoader extends cls {
this[_actualTree].assertRootOverrides()
// if forceActual is set, don't even try the hidden lockfile
- if (!forceActual) {
+ if (!forceActual && !process.env['NIX_NODEJS_BUILDNPMPACKAGE']) {
// Note: hidden lockfile will be rejected if it's not the latest thing
// in the folder, or if any of the entries in the hidden lockfile are
// missing.
Fixes cross compilation to aarch64-linux by reverting
https://github.com/nodejs/node/pull/43200
--- old/configure.py
+++ new/configure.py
@@ -1236,7 +1236,6 @@
# Enable branch protection for arm64
if target_arch == 'arm64':
- o['cflags']+=['-msign-return-address=all']
o['variables']['arm_fpu'] = options.arm_fpu or 'neon'
if options.node_snapshot_main is not None:
{ callPackage, openssl, python3, enableNpm ? true, nodejs, path }:
let
buildNodejs = callPackage "${path}/pkgs/development/web/nodejs/nodejs.nix" {
inherit openssl;
python = python3;
};
in
buildNodejs {
inherit enableNpm;
version = "20.3.1";
sha256 = "sha256-EqgtswZpeVm0OJs1Gl+XhImGsTE/mQGw4LPYz08/mZE=";
patches = [
./nodejs-patches/revert-arm64-pointer-auth.patch
./nodejs-patches/disable-darwin-v8-system-instrumentation-node19.patch
./nodejs-patches/bypass-darwin-xcrun-node16.patch
./nodejs-patches/node-npm-build-npm-package-logic.patch
];
}
...@@ -18,6 +18,7 @@ let ...@@ -18,6 +18,7 @@ let
echo "Installing JS Dependencies" echo "Installing JS Dependencies"
#yarn #yarn
bun install bun install
bun install --dev
echo "Compiling" echo "Compiling"
bun run build bun run build
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment