27 Jul 2024 |
Aleksandr Lebedev | Do you have any suggestions on what I need to do? I merely want to run JupyterLab with interactive Matplotlib. | 07:22:10 |
K900 | Try adding preBuild = "export HOME=$(mktemp -d)" | 07:26:20 |
Aleksandr Lebedev | In reply to @k900:0upti.me Try adding preBuild = "export HOME=$(mktemp -d)" It seems that ipympl was installed successfully. Thank you!
But it was really complicated
| 07:43:52 |
| dave joined the room. | 23:24:33 |
28 Jul 2024 |
| matthewcroughan changed their display name from matthewcroughan to matthewcroughan - going to nix.camp. | 16:16:37 |
29 Jul 2024 |
Aleksandr Lebedev | Hey! I tried to override cargoDeps of rpds-py package to support 0.19.1 version. I have the following code:
myapp = mkPoetryApplication {
projectDir = self;
overrides = p2nix.overrides.withDefaults (final: prev: {
rpds-py = prev.rpds-py.overridePythonAttrs (old:
lib.optionalAttrs (old.version == "0.19.1") ( lib.warn "version == 0.19.1" {
cargoDeps = lib.warn "override cargoDeps" (pkgs.rustPlatform.fetchCargoTarball {
inherit (old) src;
name = "${old.pname}-${old.version}";
hash = lib.warn "new hash was used in cargoDeps" "sha256-qIXdoCEVGCGUnTicZp4bUTJyGpFy9dwWY03lXUbxiHg=";
});
cargoFakeDeps = lib.warn "override cargoFakeDeps" (pkgs.rustPlatform.fetchCargoTarball {
inherit (old) src;
name = "${old.pname}-${old.version}";
hash = lib.warn "new hash was used in cargoFakeDeps" "sha256-qIXdoCEVGCGUnTicZp4bUTJyGpFy9dwWY03lXUbxiHg=";
});
})
);
});
};
I see that cargoFakeDeps was evaluated but cargoDeps wasn't. This is the log output I received:
[user@daily:~/tmp/jupyter-test]$ nix develop
warning: Git tree '/home/user/tmp/jupyter-test' is dirty
trace: warning: version == 0.19.1
trace: warning: Unknown rpds-py version: '0.19.1'. Please update getCargoHash.
trace: warning: override cargoFakeDeps
trace: warning: new hash was used in cargoFakeDeps
error: hash mismatch in fixed-output derivation '/nix/store/3m2xsv79lvb6pv4f3sd5nyfv8sl0byrb-rpds-py-0.19.1-vendor.tar.gz.drv':
specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
got: sha256-qIXdoCEVGCGUnTicZp4bUTJyGpFy9dwWY03lXUbxiHg=
error: 1 dependencies of derivation '/nix/store/8frwibaaxwga13d1vsv4b3m17ynhlrrr-python3.11-rpds-py-0.19.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/bjlcbjsy5cs57pm2qmaw2b7whgd0lrxj-python3.11-jsonschema-4.23.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/45j5816fkpznmby4jjaz8w8f1vb28ar9-python3.11-referencing-0.35.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qwf87z1fjbf1rm4ml2rffrp7q9gkbbz6-python3.11-jupyter-events-0.10.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/y8m4si7ikw0s5zdzwml1cwvf6pvif181-python3.11-jupyterlab-server-2.27.3.drv' failed to build
error: 1 dependencies of derivation '/nix/store/a7sh6l94yql8g89x81ndsc7rnpw1l3qh-python3.11-nbformat-5.10.4.drv' failed to build
error: 1 dependencies of derivation '/nix/store/rsr6ll0kxdlgm09356y8hamlpzyzqx2b-python3.11-nbconvert-7.16.4.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qzljggjx929jv9pj73jdy5x5wybsm0ic-python3.11-jupyter-1.0.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/76h3qhf1ijj1zyvmz0753a8qrznm06v9-nix-shell-env.drv' failed to build
What did I do wrong?
| 12:47:47 |
Aleksandr Lebedev | In reply to @lebastr:matrix.org
Hey! I tried to override cargoDeps of rpds-py package to support 0.19.1 version. I have the following code:
myapp = mkPoetryApplication {
projectDir = self;
overrides = p2nix.overrides.withDefaults (final: prev: {
rpds-py = prev.rpds-py.overridePythonAttrs (old:
lib.optionalAttrs (old.version == "0.19.1") ( lib.warn "version == 0.19.1" {
cargoDeps = lib.warn "override cargoDeps" (pkgs.rustPlatform.fetchCargoTarball {
inherit (old) src;
name = "${old.pname}-${old.version}";
hash = lib.warn "new hash was used in cargoDeps" "sha256-qIXdoCEVGCGUnTicZp4bUTJyGpFy9dwWY03lXUbxiHg=";
});
cargoFakeDeps = lib.warn "override cargoFakeDeps" (pkgs.rustPlatform.fetchCargoTarball {
inherit (old) src;
name = "${old.pname}-${old.version}";
hash = lib.warn "new hash was used in cargoFakeDeps" "sha256-qIXdoCEVGCGUnTicZp4bUTJyGpFy9dwWY03lXUbxiHg=";
});
})
);
});
};
I see that cargoFakeDeps was evaluated but cargoDeps wasn't. This is the log output I received:
[user@daily:~/tmp/jupyter-test]$ nix develop
warning: Git tree '/home/user/tmp/jupyter-test' is dirty
trace: warning: version == 0.19.1
trace: warning: Unknown rpds-py version: '0.19.1'. Please update getCargoHash.
trace: warning: override cargoFakeDeps
trace: warning: new hash was used in cargoFakeDeps
error: hash mismatch in fixed-output derivation '/nix/store/3m2xsv79lvb6pv4f3sd5nyfv8sl0byrb-rpds-py-0.19.1-vendor.tar.gz.drv':
specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
got: sha256-qIXdoCEVGCGUnTicZp4bUTJyGpFy9dwWY03lXUbxiHg=
error: 1 dependencies of derivation '/nix/store/8frwibaaxwga13d1vsv4b3m17ynhlrrr-python3.11-rpds-py-0.19.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/bjlcbjsy5cs57pm2qmaw2b7whgd0lrxj-python3.11-jsonschema-4.23.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/45j5816fkpznmby4jjaz8w8f1vb28ar9-python3.11-referencing-0.35.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qwf87z1fjbf1rm4ml2rffrp7q9gkbbz6-python3.11-jupyter-events-0.10.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/y8m4si7ikw0s5zdzwml1cwvf6pvif181-python3.11-jupyterlab-server-2.27.3.drv' failed to build
error: 1 dependencies of derivation '/nix/store/a7sh6l94yql8g89x81ndsc7rnpw1l3qh-python3.11-nbformat-5.10.4.drv' failed to build
error: 1 dependencies of derivation '/nix/store/rsr6ll0kxdlgm09356y8hamlpzyzqx2b-python3.11-nbconvert-7.16.4.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qzljggjx929jv9pj73jdy5x5wybsm0ic-python3.11-jupyter-1.0.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/76h3qhf1ijj1zyvmz0753a8qrznm06v9-nix-shell-env.drv' failed to build
What did I do wrong?
I found problem. My overlay was overwritten by default:
withDefaults = overlay: [
overlay
self.defaultPoetryOverrides
];
| 12:59:41 |
31 Jul 2024 |
declension | Hi all. Is there a best practice I'm missing for providing poetry itself in a dev shell? I've been using (slightly customised) versions of pkgs.poetry as a buildInputs / packages entry, but was wondering if poetry2nix exposes its version cleverly maybe.
(Motivation: I find this is needed to do poetry lock --no-update or poetry add foo --lock etc etc, and obviously don't want to use a global poetry version)
| 16:54:41 |
| @gracicot-59e8f173d73408ce4f7ac803:gitter.im joined the room. | 22:01:38 |
oven_spinout988 | Hello,
I am trying to convert a project with poetry2nix. The project has a web server launch via a gunicorn with Popen .
I have errors related to the fact that gunircorn could not import library such as filtetype .
[2024-08-01 01:04:01 +0200] [1248518] [INFO] Starting gunicorn 22.0.0
[2024-08-01 01:04:01 +0200] [1248518] [INFO] Listening at: http://0.0.0.0:5100 (1248518)
[2024-08-01 01:04:01 +0200] [1248518] [INFO] Using worker: sync
[2024-08-01 01:04:01 +0200] [1248521] [INFO] Booting worker with pid: 1248521
[2024-08-01 01:04:01 +0200] [1248521] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
worker.init_process()
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
^^^^^^^^^^^^^^^
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
^^^^^^^^^^^
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
^^^^^^^^^^^^^^^^^^^ File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/util.py", line 371, in import_app
mod = importlib.import_module(module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/jms4z7lzzwnv6gv3y0795365haicmh8m-python3-3.12.4/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/home/user/Repository/lookyloo/website/web/__init__.py", line 17, in <module>
import filetype # type: ignore[import-untyped]
^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'filetype'
[2024-08-01 01:04:01 +0200] [1248521] [INFO] Worker exiting (pid: 1248521)
[2024-08-01 01:04:01 +0200] [1248518] [ERROR] Worker (pid:1248521) exited with code 3
[2024-08-01 01:04:01 +0200] [1248518] [ERROR] Shutting down: Master
[2024-08-01 01:04:01 +0200] [1248518] [ERROR] Reason: Worker failed to boot.
The project is the following one https://github.com/Lookyloo/lookyloo. With the following patch applied :
diff --git a/.gitignore b/.gitignore
index 3b2b988..7ca0859 100644
--- a/.gitignore
+++ b/.gitignore
@@ -151,3 +151,6 @@ sanejs
urlhaus
urlscan
vt_url
+
+# Nix
+result
diff --git a/cache/run_redis.sh b/cache/run_redis.sh
index 8daf6d8..8a70742 100755
--- a/cache/run_redis.sh
+++ b/cache/run_redis.sh
@@ -1,13 +1,13 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
set -x
-if [ -f ../../valkey/src/valkey-server ]; then
- ../../valkey/src/valkey-server ./cache.conf
+if [ -f ../../valkey/src/valkey-server ]; then
+ ../../valkey/src/valkey-server ./cache.conf
elif [ -f ../../redis/src/redis-server ]; then
- ../../redis/src/redis-server ./cache.conf
+ ../../redis/src/redis-server ./cache.conf
else
- echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
- /usr/bin/redis-server ./cache.conf
+ echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
+ redis-server ./cache.conf
fi
diff --git a/indexing/run_redis.sh b/indexing/run_redis.sh
index d6924a0..7107500 100755
--- a/indexing/run_redis.sh
+++ b/indexing/run_redis.sh
@@ -1,13 +1,13 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
set -x
-if [ -f ../../valkey/src/valkey-server ]; then
- ../../valkey/src/valkey-server ./indexing.conf
+if [ -f ../../valkey/src/valkey-server ]; then
+ ../../valkey/src/valkey-server ./indexing.conf
elif [ -f ../../redis/src/redis-server ]; then
- ../../redis/src/redis-server ./indexing.conf
+ ../../redis/src/redis-server ./indexing.conf
else
- echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
- /usr/bin/redis-server ./indexing.conf
+ echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
+ redis-server ./indexing.conf
fi
diff --git a/pyproject.toml b/pyproject.toml
index 7614ce8..2ded159 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -21,6 +21,11 @@ classifiers = [
'Topic :: Internet',
]
+packages = [
+{include = "lookyloo"},
+{include = "bin"},
+]
+
[tool.poetry.scripts]
start = "bin.start:main"
stop = "bin.stop:main"
The flake is :
{
description = "Application packaged using poetry2nix";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
poetry2nix = {
#url = "github:nix-community/poetry2nix";
url = "git+https://gitea.com/oven_spinout988/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system}.extend poetry2nix.overlays.default;
projectDir = ./.;
# NOTE: add non python packages, needed at runtime, here
runtimePackages = with pkgs; [
redis
ffmpeg
python3
];
# NOTE: add non python packages, only needed for development, here
devPackages = with pkgs; [
pkgs.python3
pkgs.poetry
];
patches = [
./nix/cache.patch
./nix/indexing.patch
];
pypkgs-build-requirements = {
fsspec = [ "hatchling" "hatch-vcs" ];
har2tree = [ "poetry-core" ];
pydeep2 = [ "setuptools-scm" "ssdeep" pkgs.ssdeep pkgs.libtool pkgs.automake ];
vt-py = [ "setuptools" "pytest-runner" ];
pyeupi = [ "poetry-core" ];
pyfaup = [ "setuptools" ];
types-cffi = [ "setuptools" ];
pypdns = [ "poetry-core" ];
passivetotal = [ "setuptools" ];
pyhashlookup = [ "poetry-core" ];
pyipasnhistory = [ "poetry-core" ];
pylookyloo = [ "poetry-core" ];
pymisp = [ "poetry-core" ];
pylookyloomonitoring = [ "poetry-core" ];
pypandora = [ "poetry-core" ];
pyphishtanklookup = [ "poetry-core" ];
pysanejs = [ "poetry-core" ];
pysecuritytxt = [ "poetry-core" ];
pytaxonomies = [ "poetry-core" ];
flask = [ "setuptools" ];
ssdeep = [ "setuptools" ];
lxml = [ pkgs.libz ];
filetype = [ "setuptools" ];
};
p2n-overrides = pkgs.poetry2nix.overrides.withDefaults
#p2n-overrides = defaultPoetryOverrides.extend
(final: prev:
builtins.mapAttrs
(package: build-requirements:
(builtins.getAttr package prev).overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ (builtins.map (pkg: if builtins.isString pkg then builtins.getAttr pkg prev else pkg) build-requirements);
})
)
pypkgs-build-requirements
);
propagatedBuildInputs = [
pkgs.ffmpeg
pkgs.redis
# pkgs.python3
];
lookylooApp = pkgs.poetry2nix.mkPoetryApplication
{
inherit projectDir;
inherit propagatedBuildInputs;
overrides = p2n-overrides;
};
in
{
packages = {
default = lookylooApp;
};
apps = {
start = {
type = "app";
program = "${lookylooApp}/bin/start";
};
start_website = {
type = "app";
program = "${lookylooApp}/bin/start_website";
};
stop = {
type = "app";
program = "${lookylooApp}/bin/stop";
};
};
devShells.default =
pkgs.mkShell
{
# inputsFrom = [ self.packages.${system}.lookyloo ];
packages = [
lookylooApp.dependencyEnv
]
++ runtimePackages
++ devPackages;
shellHook = ''
export LOOKYLOO_HOME="$(pwd)";
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
echo "[+] Welcome to this nix shell"
echo "- Python $(python --version)"
'';
};
});
}
It is working with the dev environment, what am I doing wrong ?
| 23:57:44 |
oven_spinout988 | * Hello,
I am trying to convert a project with poetry2nix. The project has a web server launch via a gunicorn with Popen . The webserver configuration is under website/web where scripts are in bin and the main library is under lookyloo .
I have errors related to the fact that gunircorn could not import library such as filtetype .
[2024-08-01 01:04:01 +0200] [1248518] [INFO] Starting gunicorn 22.0.0
[2024-08-01 01:04:01 +0200] [1248518] [INFO] Listening at: http://0.0.0.0:5100 (1248518)
[2024-08-01 01:04:01 +0200] [1248518] [INFO] Using worker: sync
[2024-08-01 01:04:01 +0200] [1248521] [INFO] Booting worker with pid: 1248521
[2024-08-01 01:04:01 +0200] [1248521] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
worker.init_process()
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
^^^^^^^^^^^^^^^
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
^^^^^^^^^^^
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
^^^^^^^^^^^^^^^^^^^ File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/util.py", line 371, in import_app
mod = importlib.import_module(module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/jms4z7lzzwnv6gv3y0795365haicmh8m-python3-3.12.4/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/home/user/Repository/lookyloo/website/web/__init__.py", line 17, in <module>
import filetype # type: ignore[import-untyped]
^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'filetype'
[2024-08-01 01:04:01 +0200] [1248521] [INFO] Worker exiting (pid: 1248521)
[2024-08-01 01:04:01 +0200] [1248518] [ERROR] Worker (pid:1248521) exited with code 3
[2024-08-01 01:04:01 +0200] [1248518] [ERROR] Shutting down: Master
[2024-08-01 01:04:01 +0200] [1248518] [ERROR] Reason: Worker failed to boot.
The project is the following one https://github.com/Lookyloo/lookyloo. With the following patch applied :
diff --git a/.gitignore b/.gitignore
index 3b2b988..7ca0859 100644
--- a/.gitignore
+++ b/.gitignore
@@ -151,3 +151,6 @@ sanejs
urlhaus
urlscan
vt_url
+
+# Nix
+result
diff --git a/cache/run_redis.sh b/cache/run_redis.sh
index 8daf6d8..8a70742 100755
--- a/cache/run_redis.sh
+++ b/cache/run_redis.sh
@@ -1,13 +1,13 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
set -x
-if [ -f ../../valkey/src/valkey-server ]; then
- ../../valkey/src/valkey-server ./cache.conf
+if [ -f ../../valkey/src/valkey-server ]; then
+ ../../valkey/src/valkey-server ./cache.conf
elif [ -f ../../redis/src/redis-server ]; then
- ../../redis/src/redis-server ./cache.conf
+ ../../redis/src/redis-server ./cache.conf
else
- echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
- /usr/bin/redis-server ./cache.conf
+ echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
+ redis-server ./cache.conf
fi
diff --git a/indexing/run_redis.sh b/indexing/run_redis.sh
index d6924a0..7107500 100755
--- a/indexing/run_redis.sh
+++ b/indexing/run_redis.sh
@@ -1,13 +1,13 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
set -x
-if [ -f ../../valkey/src/valkey-server ]; then
- ../../valkey/src/valkey-server ./indexing.conf
+if [ -f ../../valkey/src/valkey-server ]; then
+ ../../valkey/src/valkey-server ./indexing.conf
elif [ -f ../../redis/src/redis-server ]; then
- ../../redis/src/redis-server ./indexing.conf
+ ../../redis/src/redis-server ./indexing.conf
else
- echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
- /usr/bin/redis-server ./indexing.conf
+ echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
+ redis-server ./indexing.conf
fi
diff --git a/pyproject.toml b/pyproject.toml
index 7614ce8..2ded159 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -21,6 +21,11 @@ classifiers = [
'Topic :: Internet',
]
+packages = [
+{include = "lookyloo"},
+{include = "bin"},
+]
+
[tool.poetry.scripts]
start = "bin.start:main"
stop = "bin.stop:main"
The flake is :
{
description = "Application packaged using poetry2nix";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
poetry2nix = {
#url = "github:nix-community/poetry2nix";
url = "git+https://gitea.com/oven_spinout988/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system}.extend poetry2nix.overlays.default;
projectDir = ./.;
# NOTE: add non python packages, needed at runtime, here
runtimePackages = with pkgs; [
redis
ffmpeg
python3
];
# NOTE: add non python packages, only needed for development, here
devPackages = with pkgs; [
pkgs.python3
pkgs.poetry
];
patches = [
./nix/cache.patch
./nix/indexing.patch
];
pypkgs-build-requirements = {
fsspec = [ "hatchling" "hatch-vcs" ];
har2tree = [ "poetry-core" ];
pydeep2 = [ "setuptools-scm" "ssdeep" pkgs.ssdeep pkgs.libtool pkgs.automake ];
vt-py = [ "setuptools" "pytest-runner" ];
pyeupi = [ "poetry-core" ];
pyfaup = [ "setuptools" ];
types-cffi = [ "setuptools" ];
pypdns = [ "poetry-core" ];
passivetotal = [ "setuptools" ];
pyhashlookup = [ "poetry-core" ];
pyipasnhistory = [ "poetry-core" ];
pylookyloo = [ "poetry-core" ];
pymisp = [ "poetry-core" ];
pylookyloomonitoring = [ "poetry-core" ];
pypandora = [ "poetry-core" ];
pyphishtanklookup = [ "poetry-core" ];
pysanejs = [ "poetry-core" ];
pysecuritytxt = [ "poetry-core" ];
pytaxonomies = [ "poetry-core" ];
flask = [ "setuptools" ];
ssdeep = [ "setuptools" ];
lxml = [ pkgs.libz ];
filetype = [ "setuptools" ];
};
p2n-overrides = pkgs.poetry2nix.overrides.withDefaults
#p2n-overrides = defaultPoetryOverrides.extend
(final: prev:
builtins.mapAttrs
(package: build-requirements:
(builtins.getAttr package prev).overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ (builtins.map (pkg: if builtins.isString pkg then builtins.getAttr pkg prev else pkg) build-requirements);
})
)
pypkgs-build-requirements
);
propagatedBuildInputs = [
pkgs.ffmpeg
pkgs.redis
# pkgs.python3
];
lookylooApp = pkgs.poetry2nix.mkPoetryApplication
{
inherit projectDir;
inherit propagatedBuildInputs;
overrides = p2n-overrides;
};
in
{
packages = {
default = lookylooApp;
};
apps = {
start = {
type = "app";
program = "${lookylooApp}/bin/start";
};
start_website = {
type = "app";
program = "${lookylooApp}/bin/start_website";
};
stop = {
type = "app";
program = "${lookylooApp}/bin/stop";
};
};
devShells.default =
pkgs.mkShell
{
# inputsFrom = [ self.packages.${system}.lookyloo ];
packages = [
lookylooApp.dependencyEnv
]
++ runtimePackages
++ devPackages;
shellHook = ''
export LOOKYLOO_HOME="$(pwd)";
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
echo "[+] Welcome to this nix shell"
echo "- Python $(python --version)"
'';
};
});
}
It is working with the dev environment, what am I doing wrong ?
| 23:58:38 |
oven_spinout988 | * Hello,
I am trying to convert a project with poetry2nix. The project has a web server launch via a gunicorn with Popen . The webserver configuration is under website/web where scripts are in bin and the main library is under lookyloo .
I have errors related to the fact that gunircorn could not import library such as filtetype .
[2024-08-01 01:04:01 +0200] [1248518] [INFO] Starting gunicorn 22.0.0
[2024-08-01 01:04:01 +0200] [1248518] [INFO] Listening at: http://0.0.0.0:5100 (1248518)
[2024-08-01 01:04:01 +0200] [1248518] [INFO] Using worker: sync
[2024-08-01 01:04:01 +0200] [1248521] [INFO] Booting worker with pid: 1248521
[2024-08-01 01:04:01 +0200] [1248521] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
worker.init_process()
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
^^^^^^^^^^^^^^^
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
^^^^^^^^^^^
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
^^^^^^^^^^^^^^^^^^^ File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/util.py", line 371, in import_app
mod = importlib.import_module(module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/jms4z7lzzwnv6gv3y0795365haicmh8m-python3-3.12.4/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/home/user/Repository/lookyloo/website/web/__init__.py", line 17, in <module>
import filetype # type: ignore[import-untyped]
^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'filetype'
[2024-08-01 01:04:01 +0200] [1248521] [INFO] Worker exiting (pid: 1248521)
[2024-08-01 01:04:01 +0200] [1248518] [ERROR] Worker (pid:1248521) exited with code 3
[2024-08-01 01:04:01 +0200] [1248518] [ERROR] Shutting down: Master
[2024-08-01 01:04:01 +0200] [1248518] [ERROR] Reason: Worker failed to boot.
The project is the following one https://github.com/Lookyloo/lookyloo. With the following patch applied :
diff --git a/.gitignore b/.gitignore
index 3b2b988..7ca0859 100644
--- a/.gitignore
+++ b/.gitignore
@@ -151,3 +151,6 @@ sanejs
urlhaus
urlscan
vt_url
+
+# Nix
+result
diff --git a/cache/run_redis.sh b/cache/run_redis.sh
index 8daf6d8..8a70742 100755
--- a/cache/run_redis.sh
+++ b/cache/run_redis.sh
@@ -1,13 +1,13 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
set -x
-if [ -f ../../valkey/src/valkey-server ]; then
- ../../valkey/src/valkey-server ./cache.conf
+if [ -f ../../valkey/src/valkey-server ]; then
+ ../../valkey/src/valkey-server ./cache.conf
elif [ -f ../../redis/src/redis-server ]; then
- ../../redis/src/redis-server ./cache.conf
+ ../../redis/src/redis-server ./cache.conf
else
- echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
- /usr/bin/redis-server ./cache.conf
+ echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
+ redis-server ./cache.conf
fi
diff --git a/indexing/run_redis.sh b/indexing/run_redis.sh
index d6924a0..7107500 100755
--- a/indexing/run_redis.sh
+++ b/indexing/run_redis.sh
@@ -1,13 +1,13 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
set -x
-if [ -f ../../valkey/src/valkey-server ]; then
- ../../valkey/src/valkey-server ./indexing.conf
+if [ -f ../../valkey/src/valkey-server ]; then
+ ../../valkey/src/valkey-server ./indexing.conf
elif [ -f ../../redis/src/redis-server ]; then
- ../../redis/src/redis-server ./indexing.conf
+ ../../redis/src/redis-server ./indexing.conf
else
- echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
- /usr/bin/redis-server ./indexing.conf
+ echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
+ redis-server ./indexing.conf
fi
diff --git a/pyproject.toml b/pyproject.toml
index 7614ce8..2ded159 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -21,6 +21,11 @@ classifiers = [
'Topic :: Internet',
]
+packages = [
+{include = "lookyloo"},
+{include = "bin"},
+]
+
[tool.poetry.scripts]
start = "bin.start:main"
stop = "bin.stop:main"
The flake is :
{
description = "Application packaged using poetry2nix";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
poetry2nix = {
#url = "github:nix-community/poetry2nix";
url = "git+https://gitea.com/oven_spinout988/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system}.extend poetry2nix.overlays.default;
projectDir = ./.;
# NOTE: add non python packages, needed at runtime, here
runtimePackages = with pkgs; [
redis
ffmpeg
python3
];
# NOTE: add non python packages, only needed for development, here
devPackages = with pkgs; [
pkgs.python3
pkgs.poetry
];
patches = [
./nix/cache.patch
./nix/indexing.patch
];
pypkgs-build-requirements = {
fsspec = [ "hatchling" "hatch-vcs" ];
har2tree = [ "poetry-core" ];
pydeep2 = [ "setuptools-scm" "ssdeep" pkgs.ssdeep pkgs.libtool pkgs.automake ];
vt-py = [ "setuptools" "pytest-runner" ];
pyeupi = [ "poetry-core" ];
pyfaup = [ "setuptools" ];
types-cffi = [ "setuptools" ];
pypdns = [ "poetry-core" ];
passivetotal = [ "setuptools" ];
pyhashlookup = [ "poetry-core" ];
pyipasnhistory = [ "poetry-core" ];
pylookyloo = [ "poetry-core" ];
pymisp = [ "poetry-core" ];
pylookyloomonitoring = [ "poetry-core" ];
pypandora = [ "poetry-core" ];
pyphishtanklookup = [ "poetry-core" ];
pysanejs = [ "poetry-core" ];
pysecuritytxt = [ "poetry-core" ];
pytaxonomies = [ "poetry-core" ];
flask = [ "setuptools" ];
ssdeep = [ "setuptools" ];
lxml = [ pkgs.libz ];
filetype = [ "setuptools" ];
};
p2n-overrides = pkgs.poetry2nix.overrides.withDefaults
#p2n-overrides = defaultPoetryOverrides.extend
(final: prev:
builtins.mapAttrs
(package: build-requirements:
(builtins.getAttr package prev).overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ (builtins.map (pkg: if builtins.isString pkg then builtins.getAttr pkg prev else pkg) build-requirements);
})
)
pypkgs-build-requirements
);
propagatedBuildInputs = [
pkgs.ffmpeg
pkgs.redis
# pkgs.python3
];
lookylooApp = pkgs.poetry2nix.mkPoetryApplication
{
inherit projectDir;
inherit propagatedBuildInputs;
overrides = p2n-overrides;
};
in
{
packages = {
default = lookylooApp;
};
apps = {
start = {
type = "app";
program = "${lookylooApp}/bin/start";
};
start_website = {
type = "app";
program = "${lookylooApp}/bin/start_website";
};
stop = {
type = "app";
program = "${lookylooApp}/bin/stop";
};
};
devShells.default =
pkgs.mkShell
{
# inputsFrom = [ self.packages.${system}.lookyloo ];
packages = [
lookylooApp.dependencyEnv
]
++ runtimePackages
++ devPackages;
shellHook = ''
export LOOKYLOO_HOME="$(pwd)";
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
echo "[+] Welcome to this nix shell"
echo "- Python $(python --version)"
'';
};
});
}
It is working with the dev environment. Can you help me to find out what I am doing wrong ?
| 23:59:36 |
1 Aug 2024 |
declension | In reply to @oven_spinout988:matrix.org
Hello,
I am trying to convert a project with poetry2nix. The project has a web server launch via a gunicorn with Popen . The webserver configuration is under website/web where scripts are in bin and the main library is under lookyloo .
I have errors related to the fact that gunircorn could not import library such as filtetype .
[2024-08-01 01:04:01 +0200] [1248518] [INFO] Starting gunicorn 22.0.0
[2024-08-01 01:04:01 +0200] [1248518] [INFO] Listening at: http://0.0.0.0:5100 (1248518)
[2024-08-01 01:04:01 +0200] [1248518] [INFO] Using worker: sync
[2024-08-01 01:04:01 +0200] [1248521] [INFO] Booting worker with pid: 1248521
[2024-08-01 01:04:01 +0200] [1248521] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
worker.init_process()
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
^^^^^^^^^^^^^^^
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
^^^^^^^^^^^
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
^^^^^^^^^^^^^^^^^^^ File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/dwp52sk1jzz0lqy499g5hblp00ns97d0-python3.12-gunicorn-22.0.0/lib/python3.12/site-packages/gunicorn/util.py", line 371, in import_app
mod = importlib.import_module(module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/jms4z7lzzwnv6gv3y0795365haicmh8m-python3-3.12.4/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/home/user/Repository/lookyloo/website/web/__init__.py", line 17, in <module>
import filetype # type: ignore[import-untyped]
^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'filetype'
[2024-08-01 01:04:01 +0200] [1248521] [INFO] Worker exiting (pid: 1248521)
[2024-08-01 01:04:01 +0200] [1248518] [ERROR] Worker (pid:1248521) exited with code 3
[2024-08-01 01:04:01 +0200] [1248518] [ERROR] Shutting down: Master
[2024-08-01 01:04:01 +0200] [1248518] [ERROR] Reason: Worker failed to boot.
The project is the following one https://github.com/Lookyloo/lookyloo. With the following patch applied :
diff --git a/.gitignore b/.gitignore
index 3b2b988..7ca0859 100644
--- a/.gitignore
+++ b/.gitignore
@@ -151,3 +151,6 @@ sanejs
urlhaus
urlscan
vt_url
+
+# Nix
+result
diff --git a/cache/run_redis.sh b/cache/run_redis.sh
index 8daf6d8..8a70742 100755
--- a/cache/run_redis.sh
+++ b/cache/run_redis.sh
@@ -1,13 +1,13 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
set -x
-if [ -f ../../valkey/src/valkey-server ]; then
- ../../valkey/src/valkey-server ./cache.conf
+if [ -f ../../valkey/src/valkey-server ]; then
+ ../../valkey/src/valkey-server ./cache.conf
elif [ -f ../../redis/src/redis-server ]; then
- ../../redis/src/redis-server ./cache.conf
+ ../../redis/src/redis-server ./cache.conf
else
- echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
- /usr/bin/redis-server ./cache.conf
+ echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
+ redis-server ./cache.conf
fi
diff --git a/indexing/run_redis.sh b/indexing/run_redis.sh
index d6924a0..7107500 100755
--- a/indexing/run_redis.sh
+++ b/indexing/run_redis.sh
@@ -1,13 +1,13 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
set -x
-if [ -f ../../valkey/src/valkey-server ]; then
- ../../valkey/src/valkey-server ./indexing.conf
+if [ -f ../../valkey/src/valkey-server ]; then
+ ../../valkey/src/valkey-server ./indexing.conf
elif [ -f ../../redis/src/redis-server ]; then
- ../../redis/src/redis-server ./indexing.conf
+ ../../redis/src/redis-server ./indexing.conf
else
- echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
- /usr/bin/redis-server ./indexing.conf
+ echo "Warning: using system redis-server. Valkey-server or redis-server from source is recommended." >&2
+ redis-server ./indexing.conf
fi
diff --git a/pyproject.toml b/pyproject.toml
index 7614ce8..2ded159 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -21,6 +21,11 @@ classifiers = [
'Topic :: Internet',
]
+packages = [
+{include = "lookyloo"},
+{include = "bin"},
+]
+
[tool.poetry.scripts]
start = "bin.start:main"
stop = "bin.stop:main"
The flake is :
{
description = "Application packaged using poetry2nix";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
poetry2nix = {
#url = "github:nix-community/poetry2nix";
url = "git+https://gitea.com/oven_spinout988/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system}.extend poetry2nix.overlays.default;
projectDir = ./.;
# NOTE: add non python packages, needed at runtime, here
runtimePackages = with pkgs; [
redis
ffmpeg
python3
];
# NOTE: add non python packages, only needed for development, here
devPackages = with pkgs; [
pkgs.python3
pkgs.poetry
];
patches = [
./nix/cache.patch
./nix/indexing.patch
];
pypkgs-build-requirements = {
fsspec = [ "hatchling" "hatch-vcs" ];
har2tree = [ "poetry-core" ];
pydeep2 = [ "setuptools-scm" "ssdeep" pkgs.ssdeep pkgs.libtool pkgs.automake ];
vt-py = [ "setuptools" "pytest-runner" ];
pyeupi = [ "poetry-core" ];
pyfaup = [ "setuptools" ];
types-cffi = [ "setuptools" ];
pypdns = [ "poetry-core" ];
passivetotal = [ "setuptools" ];
pyhashlookup = [ "poetry-core" ];
pyipasnhistory = [ "poetry-core" ];
pylookyloo = [ "poetry-core" ];
pymisp = [ "poetry-core" ];
pylookyloomonitoring = [ "poetry-core" ];
pypandora = [ "poetry-core" ];
pyphishtanklookup = [ "poetry-core" ];
pysanejs = [ "poetry-core" ];
pysecuritytxt = [ "poetry-core" ];
pytaxonomies = [ "poetry-core" ];
flask = [ "setuptools" ];
ssdeep = [ "setuptools" ];
lxml = [ pkgs.libz ];
filetype = [ "setuptools" ];
};
p2n-overrides = pkgs.poetry2nix.overrides.withDefaults
#p2n-overrides = defaultPoetryOverrides.extend
(final: prev:
builtins.mapAttrs
(package: build-requirements:
(builtins.getAttr package prev).overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ (builtins.map (pkg: if builtins.isString pkg then builtins.getAttr pkg prev else pkg) build-requirements);
})
)
pypkgs-build-requirements
);
propagatedBuildInputs = [
pkgs.ffmpeg
pkgs.redis
# pkgs.python3
];
lookylooApp = pkgs.poetry2nix.mkPoetryApplication
{
inherit projectDir;
inherit propagatedBuildInputs;
overrides = p2n-overrides;
};
in
{
packages = {
default = lookylooApp;
};
apps = {
start = {
type = "app";
program = "${lookylooApp}/bin/start";
};
start_website = {
type = "app";
program = "${lookylooApp}/bin/start_website";
};
stop = {
type = "app";
program = "${lookylooApp}/bin/stop";
};
};
devShells.default =
pkgs.mkShell
{
# inputsFrom = [ self.packages.${system}.lookyloo ];
packages = [
lookylooApp.dependencyEnv
]
++ runtimePackages
++ devPackages;
shellHook = ''
export LOOKYLOO_HOME="$(pwd)";
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
echo "[+] Welcome to this nix shell"
echo "- Python $(python --version)"
'';
};
});
}
It is working with the dev environment. Can you help me to find out what I am doing wrong ?
Are you using nix run to run or calling the app(s) explicitly? | 08:18:25 |
declension | Also have you seen https://github.com/nix-community/poetry2nix/blob/master/tests/dependency-environment/default.nix ? | 08:22:47 |
declension | Answering my own question a bit, it seems like the example does do exactly that:
https://github.com/nix-community/poetry2nix/blob/0a4d87e50f4eb58e04a4fe48692148196dc04501/templates/app/flake.nix#L41
| 08:58:41 |
declension | (though interestingly keeps it out of the main dev shell 🤔) | 08:59:08 |
oven_spinout988 | To be honest I saw it, but I am not sure hot to leverage it in my case.
Gunicorn is ran through a python script calling Popen .
| 10:25:27 |
| Vika (she/her) changed their profile picture. | 11:51:51 |
oven_spinout988 | * I saw it, but I am not sure hot to leverage it in my case.
Gunicorn is ran through a python script calling Popen .
| 16:06:09 |
Roland Coeurjoly | Hello, we are trying to build pendulum-3.0.0
Without any overrides, we get the following error: ModuleNotFoundError: No module named 'maturin' With this override:
buildInputs = (old.buildInputs or [ ]) ++ [ self.maturin ];
We also get the same error. Searching the code of poetry2nix, we find out some references to maturin, so we did the following override:
pendulum = super.pendulum.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
pkgs.cargo
pkgs.rustc
pkgs.maturin
# pkgs.rustPlatform.cargoSetupHook
pkgs.rustPlatform.maturinBuildHook
];
buildInputs = (old.buildInputs or [ ]) ++ [ self.maturin ];
}
);
Now the error is the following:
Executing maturinBuildHook ++ env CC_X86_64_UNKNOWN_LINUX_GNU=/nix/store/62zpnw69ylcfhcpy1di8152zlzmbls91-gcc-wrapper-13.3.0/bin/cc CXX_X86_64_UNKNOWN_LINUX_GN> error: no matching package named pyo3 found location searched: registry crates-io required by package _pendulum v3.0.0 (/build/pendulum-3.0.0/rust) As a reminder, you're using offline mode (--offline) which can sometimes cause surprising resolution failures, if this error is too > 💥 maturin failed Caused by: Cargo metadata failed. Does your crate compile with cargo build ? Caused by: cargo metadata exited with an error:
We are out of ideas.
Any ideas?
| 17:51:48 |
K900 | You need to provide cargoDeps | 17:53:06 |
K900 | See the overrides for cryptography and others for how to do that | 17:53:14 |
Roland Coeurjoly | thanks! I will look into that | 18:12:30 |
oven_spinout988 | Ok so using this in my flake :
| 22:20:17 |
oven_spinout988 | * Ok so using this in my flake :
in
{
packages = {
default = lookylooApp.dependencyEnv;
};
make gunicorn available at ./result/bin . Running gunicorn manualy (without the Popen but from my shell) is working.
I think the problem might come from the python script with a Popen calling gunicorn but "not the gunicorn from my flake"
How can I force the script to use the "generated" gunicorn ?
Should I replace the exe inside the python script ? Should I update the PATH env, and how ?
| 22:22:52 |
oven_spinout988 | Redacted or Malformed Event | 22:43:40 |
oven_spinout988 | I did found a solution :
{
description = "Application packaged using poetry2nix";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils = {
url = "github:numtide/flake-utils";
};
poetry2nix = {
#url = "github:nix-community/poetry2nix";
url = "git+https://gitea.com/oven_spinout988/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem
(system:
let
[...]
lookylooApp = let
lookylooApp = pkgs.poetry2nix.mkPoetryApplication
{
inherit projectDir;
inherit propagatedBuildInputs;
overrides = p2n-overrides;
};
in lookylooApp.overrideAttrs (old: {
postInstall = (if lookylooApp ? old then old else '''') + ''
substituteInPlace $out/lib/${lookylooApp.python.executable}/site-packages/bin/start_website.py \
--replace "gunicorn" "${lookylooApp.dependencyEnv}/bin/gunicorn"
'';
});
in
{
packages = {
default = lookylooApp;
};
};
}
Please let me know if the code can be improved
| 23:13:49 |
oven_spinout988 | * I did found a solution :
{
description = "Application packaged using poetry2nix";
inputs = {
[...]
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem
(system:
let
[...]
lookylooApp = let
lookylooApp = pkgs.poetry2nix.mkPoetryApplication
{
inherit projectDir;
inherit propagatedBuildInputs;
overrides = p2n-overrides;
};
in lookylooApp.overrideAttrs (old: {
postInstall = (if lookylooApp ? old then old else '''') + ''
substituteInPlace $out/lib/${lookylooApp.python.executable}/site-packages/bin/start_website.py \
--replace "gunicorn" "${lookylooApp.dependencyEnv}/bin/gunicorn"
'';
});
in
{
packages = {
default = lookylooApp;
};
};
}
Please let me know if the code can be improved
| 23:14:12 |
2 Aug 2024 |
truh | I have a subclass of gunicorn.app.base.BaseApplication and call Application(app, options).run() to sttart the webapp | 07:58:18 |
truh | * I have a subclass of gunicorn.app.base.BaseApplication and call SubClass(app, options).run() to sttart the webapp | 07:58:35 |