fixed
diff --git a/.gitmodules b/.gitmodules
index da4b2df..f8e01e9 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,4 +1,4 @@
[submodule "src/reflex/nsfwjs"]
path = src/reflex/nsfwjs
- url = https://github.com/infinitered/nsfwjs
+ url = https://github.com/clicksminuteper/nsfwjs
shallow = true
diff --git a/flake.lock b/flake.lock
index 4435c97..93f2395 100644
--- a/flake.lock
+++ b/flake.lock
@@ -191,11 +191,11 @@
]
},
"locked": {
- "lastModified": 1686173255,
- "narHash": "sha256-G9HiMDCnK+YeIb+lpLxsRg+/Kk2pz/PSlEtFe8Yi138=",
+ "lastModified": 1686323589,
+ "narHash": "sha256-XADn6eWl3670Oj38p0GiN1PaPKvTmDQRQErGLXYjZQU=",
"ref": "refs/heads/master",
- "rev": "f91bc86c6d2b1c2c3c4f476835b5ec01b750e898",
- "revCount": 98,
+ "rev": "aa1dc4ff5759f04cc383a5b38a163b3a7b6ac601",
+ "revCount": 102,
"type": "git",
"url": "ssh://git@github.com/clicksminuteper/pnpm2nix"
},
diff --git a/flake.nix b/flake.nix
index 8c57619..33d0698 100644
--- a/flake.nix
+++ b/flake.nix
@@ -8,64 +8,120 @@
inputs.pnpm2nix.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, flake-utils, clicks-server, pnpm2nix }:
- flake-utils.lib.eachDefaultSystem (system: let
- pkgs = nixpkgs.legacyPackages.${system};
- nodejs = pkgs.nodejs_20;
- nodePackages = pkgs.nodePackages_latest;
- lib = pkgs.lib;
- in rec {
- devShells.default = pkgs.mkShell {
- packages = [ nodejs nodePackages.pnpm pkgs.pkg-config pkgs.fontconfig.dev ];
- shellHook = ''
- unset name
- export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${lib.makeSearchPath "/lib/pkgconfig" [
- pkgs.pixman
- pkgs.cairo.dev
- pkgs.libpng.dev
- pkgs.gnome2.pango.dev
- pkgs.glib.dev
- pkgs.harfbuzz.dev
- pkgs.freetype.dev
- ]}
- '';
- };
+ flake-utils.lib.eachDefaultSystem
+ (system:
+ let
+ pkgs = nixpkgs.legacyPackages.${system};
+ nodejs = pkgs.nodejs_20;
+ nodePackages = pkgs.nodePackages_latest;
+ lib = pkgs.lib;
+ in
+ rec {
+ devShells.default = pkgs.mkShell {
+ packages = [ nodejs nodePackages.pnpm pkgs.pkg-config pkgs.fontconfig.dev ];
+ shellHook = ''
+ unset name
+ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${lib.makeSearchPath "/lib/pkgconfig" [
+ pkgs.pixman
+ pkgs.cairo.dev
+ pkgs.libpng.dev
+ pkgs.gnome2.pango.dev
+ pkgs.glib.dev
+ pkgs.harfbuzz.dev
+ pkgs.freetype.dev
+ ]}
+ '';
+ };
+ }) // {
+ packages.x86_64-linux =
+ let
+ pkgs = nixpkgs.legacyPackages.x86_64-linux;
+ nodejs = pkgs.nodejs_20;
+ nodePackages = pkgs.nodePackages_latest;
+ lib = pkgs.lib;
+ in
+ rec {
+ node_modules = lib.pipe
+ {
+ src = ./.;
+ linkDevDependencies = true;
+ overrides = pnpm2nix.defaultPnpmOverrides.x86_64-linux // {
+ canvas = (drv: drv.overrideAttrs (oldAttrs: {
+ nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ pkgs.pkg-config ];
+ buildInputs = oldAttrs.buildInputs ++ [
+ pkgs.pixman
+ pkgs.cairo.dev
+ pkgs.libpng.dev
+ pkgs.gnome2.pango.dev
+ pkgs.glib.dev
+ pkgs.harfbuzz.dev
+ pkgs.freetype.dev
+ ];
+ }));
- packages.env = lib.pipe {
- src = ./.;
- } [
- (pnpm2nix.mkPnpmPackage.${system})
- (pnpm2nix.mkPnpmEnv.${system})
- ];
+ "@tensorflow/tfjs-node" = (drv: drv.overrideAttrs (oldAttrs: {
+ buildInputs = oldAttrs.buildInputs ++ [
+ pkgs.libtensorflow
+ ];
- packages.default = let
- packageJSON = (builtins.fromJSON (builtins.readFile ./package.json));
- in pkgs.stdenv.mkDerivation {
- pname = "nucleus";
- version = packageJSON.version;
+ preBuild = ''
+ mkdir -p node_modules/@tensorflow/tfjs-node/deps/lib
+ ln -s ${pkgs.libtensorflow}/lib/libtensorflow.so.2 node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow.so.2.9.1
+ '';
+ }));
+ };
+ } [
+ (pnpm2nix.mkPnpmPackage.x86_64-linux)
+ (drv: builtins.readFile "${drv}/nix-support/propagated-build-inputs")
+ (path: "${path}/node_modules")
+ ];
- src = ./.;
+ nucleus =
+ let
+ packageJSON = (builtins.fromJSON (builtins.readFile ./package.json));
+ in
+ pkgs.stdenv.mkDerivation {
+ pname = "nucleus";
+ version = packageJSON.version;
- buildInputs = [ packages.env nodejs nodePackages.pnpm ];
- nativeBuildInputs = [ packages.env nodePackages.pnpm ];
+ src = ./.;
- buildPhase = ''
- pnpm run build
- '';
+ buildInputs = [ nodejs nodePackages.pnpm ];
+ nativeBuildInputs = [ nodePackages.pnpm nodePackages.typescript pkgs.python3 ];
- installPhase = ''
- cp dist $out
- mkdir -p $out/bin
- echo "#!/usr/bin/env bash\ncd $out\n${packageJSON.scripts.start}" > $out/bin/nucleus
- '';
- };
+ buildPhase = ''
+ ${pkgs.python3}/bin/python3 ${./scripts/fix-pnpm-bin.py} ${node_modules} ./bin
+ export PATH=$PATH:./bin
+ ln -s ${node_modules} node_modules
+ pnpm run build
+ '';
- dockerImage = let
- nucleus = packages.default;
- in pkgs.dockerTools.streamLayeredImage {
- name = "nucleus";
- tag = "latest";
- contents = [ nucleus ];
- config.Cmd = [ "${nucleus}/bin/nucleus" ];
- };
- });
+ installPhase = ''
+ mkdir -p $out
+
+ cp dist $out -r
+ cp node_modules $out -r
+ cp bin $out/.bin -r
+ cp package.json $out
+ cp LICENSE $out
+
+ mkdir -p $out/bin
+ echo "#!/usr/bin/env bash" > $out/bin/nucleus
+ echo "cd $out" >> $out/bin/nucleus
+ echo "export PATH=$PATH:$out/node_modules/.bin" >> $out/bin/nucleus
+ echo "${packageJSON.scripts.start}" >> $out/bin/nucleus
+ chmod +x $out/bin/nucleus
+ '';
+ };
+
+ dockerImage = pkgs.dockerTools.streamLayeredImage {
+ name = "nucleus";
+ tag = "latest";
+ contents = [ nucleus ];
+ config.Cmd = [ "${nucleus}/bin/nucleus" ];
+ };
+
+ default = nucleus;
+ };
+ };
}
diff --git a/package.json b/package.json
index 4f9bec9..c994fde 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"dependencies": {
- "@clicks/nsfwjs": "^3.0.2",
+ "@clicks/nsfwjs": "^3.0.3",
"@hokify/agenda": "^6.3.0",
"@octokit/graphql": "^5.0.6",
"@tensorflow/tfjs": "^4.7.0",
@@ -29,6 +29,11 @@
"structured-clone": "^0.2.2",
"systeminformation": "^5.18.2"
},
+ "pnpm": {
+ "overrides": {
+ "@hokify/agenda>mongodb": "$mongodb"
+ }
+ },
"name": "nucleus",
"version": "1.1.0",
"description": "Nucleus: The core of your server",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 18b1954..103698b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1,9 +1,12 @@
lockfileVersion: '6.0'
+overrides:
+ '@hokify/agenda>mongodb': ^5.6.0
+
dependencies:
'@clicks/nsfwjs':
- specifier: ^3.0.2
- version: 3.0.2(@tensorflow/tfjs@4.7.0)
+ specifier: ^3.0.3
+ version: 3.0.3(@tensorflow/tfjs@4.7.0)
'@hokify/agenda':
specifier: ^6.3.0
version: 6.3.0
@@ -987,8 +990,8 @@
multi-integer-range: 3.0.0
dev: false
- /@clicks/nsfwjs@3.0.2(@tensorflow/tfjs@4.7.0):
- resolution: {integrity: sha512-noih81vGmar/HJ89fHfKbcFSLchfiXuASCUlNp+fidzLtoxCBRbcTNoYe3JpNPnpn9dl6ktD0m16P8DcAnWWsg==}
+ /@clicks/nsfwjs@3.0.3(@tensorflow/tfjs@4.7.0):
+ resolution: {integrity: sha512-sQicaEck0PfxgDTukGCAiL0naS5XpxMbFFhQwOaLiGQSfzcLia720GIYc3NK3KlVoctsJ/2t+QeRDveAc0Ukmw==}
peerDependencies:
'@tensorflow/tfjs': ^4.6.0
dependencies:
@@ -1100,9 +1103,11 @@
debug: 4.3.4
human-interval: 2.0.1
luxon: 3.3.0
- mongodb: 4.16.0
+ mongodb: 5.6.0
transitivePeerDependencies:
- - aws-crt
+ - '@aws-sdk/credential-providers'
+ - mongodb-client-encryption
+ - snappy
- supports-color
dev: false
diff --git a/result b/result
new file mode 120000
index 0000000..0025238
--- /dev/null
+++ b/result
@@ -0,0 +1 @@
+/nix/store/fmvzckvxnqrfbgv0mvzghgi87602pgcm-nucleus-1.1.0
\ No newline at end of file
diff --git a/scripts/fix-pnpm-bin.py b/scripts/fix-pnpm-bin.py
new file mode 100644
index 0000000..e4453ad
--- /dev/null
+++ b/scripts/fix-pnpm-bin.py
@@ -0,0 +1,50 @@
+import sys
+import os
+import json
+
+node_modules = sys.argv[1]
+bin_dir = sys.argv[2]
+
+def collect_packages_in(_node_modules, packages: set[str] | None = None):
+ _packages: set[str] = packages or set()
+ for path in os.listdir(_node_modules):
+ if not os.path.isdir(os.path.join(_node_modules, path)) or os.path.join(_node_modules, path) in _packages:
+ continue
+
+ _packages.add(os.path.join(_node_modules, path))
+ if os.path.exists(os.path.join(_node_modules, path, "node_modules")):
+ collect_packages_in(os.path.join(_node_modules, path, "node_modules"), _packages)
+ return _packages
+
+def get_binaries_in(package):
+ package_json = os.path.join(package, "package.json")
+ if not os.path.exists(package_json):
+ return []
+
+ with open(package_json) as f:
+ package_json_contents = json.load(f)
+
+ if "bin" not in package_json_contents:
+ return []
+
+ if type(package_json_contents["bin"]) == str:
+ return [[os.path.basename(package_json_contents["name"]), os.path.join(package, package_json_contents["bin"])]]
+
+ return [[name, os.path.join(package, bin)] for name, bin in package_json_contents["bin"].items()]
+
+def main():
+ packages = collect_packages_in(node_modules)
+ binaries = []
+ for package in packages:
+ binaries += get_binaries_in(package)
+
+ os.makedirs(bin_dir, exist_ok=True)
+
+ for binary in binaries:
+ if os.path.exists(os.path.join(bin_dir, binary[0])):
+ os.remove(os.path.join(bin_dir, binary[0]))
+
+ os.symlink(os.path.realpath(binary[1]), os.path.join(bin_dir, binary[0]))
+
+if __name__ == "__main__":
+ main()
diff --git a/src/reflex/nsfwjs b/src/reflex/nsfwjs
new file mode 160000
index 0000000..9b0e45c
--- /dev/null
+++ b/src/reflex/nsfwjs
@@ -0,0 +1 @@
+Subproject commit 9b0e45c13996b1b6bc96a3af3d3c4b67ad4e971f
diff --git a/src/reflex/scanners.ts b/src/reflex/scanners.ts
index 963aebb..2b68a34 100644
--- a/src/reflex/scanners.ts
+++ b/src/reflex/scanners.ts
@@ -5,7 +5,7 @@
import type Discord from "discord.js";
import client from "../utils/client.js";
import { createHash } from "crypto";
-import * as nsfwjs from "nsfwjs";
+import * as nsfwjs from "@clicks/nsfwjs";
import ClamScan from "clamscan";
import * as tf from "@tensorflow/tfjs-node";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";