From bb5c6ba4cadd3395ec1c73bdb48db949c4eb3c0f Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Thu, 24 Aug 2023 16:30:00 +0200 Subject: [PATCH 1/3] treewide: Remove IFDs Relates to: - https://github.com/ngi-nix/ngipkgs/issues/24 - https://github.com/ngi-nix/ngipkgs/issues/39 - https://github.com/ngi-nix/ngipkgs/issues/40 --- .github/workflows/ci.yaml | 2 +- all-packages.nix | 8 ++- configs/all-configurations.nix | 5 +- modules/all-modules.nix | 4 +- pkgs/kikit/README.md | 10 ++++ pkgs/kikit/default.nix | 16 +----- pkgs/kikit/shapely/default.nix | 67 ++++++++++++++++++++++++ pkgs/kikit/shapely/library-paths.patch | 31 +++++++++++ pkgs/kikit/solidpython/default.nix | 28 +++------- pkgs/kikit/solidpython/prettytable.patch | 12 +++++ 10 files changed, 141 insertions(+), 42 deletions(-) create mode 100644 pkgs/kikit/README.md create mode 100644 pkgs/kikit/shapely/default.nix create mode 100644 pkgs/kikit/shapely/library-paths.patch create mode 100644 pkgs/kikit/solidpython/prettytable.patch diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 80936b2a..045a3219 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,4 +11,4 @@ jobs: - uses: actions/checkout@v3 - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - - run: nix flake check --allow-import-from-derivation + - run: nix flake check diff --git a/all-packages.nix b/all-packages.nix index bfc60df1..4ed2ae7e 100644 --- a/all-packages.nix +++ b/all-packages.nix @@ -5,8 +5,12 @@ kikit = callPackage ./pkgs/kikit {}; lcrq = callPackage ./pkgs/lcrq {}; lcsync = callPackage ./pkgs/lcsync {inherit lcrq librecast;}; - liberaforms = callPackage ./pkgs/liberaforms {}; - liberaforms-env = callPackage ./pkgs/liberaforms/env.nix {}; + + # LiberaForms is intentionally disabled. + # Refer to . + #liberaforms = callPackage ./pkgs/liberaforms {}; + #liberaforms-env = callPackage ./pkgs/liberaforms/env.nix {}; + libgnunetchat = callPackage ./pkgs/libgnunetchat {}; librecast = callPackage ./pkgs/librecast {inherit lcrq;}; pretalx-mysql = callPackage ./pkgs/pretalx { diff --git a/configs/all-configurations.nix b/configs/all-configurations.nix index dd9f4d30..a6566344 100644 --- a/configs/all-configurations.nix +++ b/configs/all-configurations.nix @@ -1,5 +1,8 @@ { - liberaforms-container = import ./liberaforms/container.nix; + # LiberaForms is intentionally disabled. + # Refer to . + #liberaforms-container = import ./liberaforms/container.nix; + pretalx-postgresql = { imports = [ ./pretalx/pretalx.nix diff --git a/modules/all-modules.nix b/modules/all-modules.nix index 663ac964..7847be27 100644 --- a/modules/all-modules.nix +++ b/modules/all-modules.nix @@ -1,4 +1,6 @@ { - liberaforms = import ./liberaforms.nix; + # LiberaForms is intentionally disabled. + # Refer to . + #liberaforms = import ./liberaforms.nix; pretalx = import ./pretalx.nix; } diff --git a/pkgs/kikit/README.md b/pkgs/kikit/README.md new file mode 100644 index 00000000..1dde6dfe --- /dev/null +++ b/pkgs/kikit/README.md @@ -0,0 +1,10 @@ +# KiKit + +## Dependencies + +### Shapely + +KiKit depends on an outdated version of Shapely, see +. + +The files in `/pkgs/kikit/shapely` were copied from [nixpkgs at revision `8d8e62e`](https://github.com/NixOS/nixpkgs/tree/8d8e62e74f511160a599471549a98bc9e4f4818d) and slightly adapted and reformatted. diff --git a/pkgs/kikit/default.nix b/pkgs/kikit/default.nix index 8134154b..3977b434 100644 --- a/pkgs/kikit/default.nix +++ b/pkgs/kikit/default.nix @@ -9,22 +9,8 @@ }: let properCaseName = "KiKit"; + shapely = callPackage ./shapely {}; solidpython = callPackage ./solidpython {}; - - # https://github.com/yaqwsx/KiKit/issues/574 - shapelyPkgsRoot = fetchFromGitHub { - owner = "NixOS"; - repo = "nixpkgs"; - rev = "8d8e62e74f511160a599471549a98bc9e4f4818d"; - sha256 = "sha256-2vm6IAnaCo5KAA5/rWSb6dzJsS/raEqR93xbM2/jgng="; - }; - - shapelyFile = "${shapelyPkgsRoot}/pkgs/development/python-modules/shapely"; - - shapely = - python3.pkgs.callPackage - shapelyFile - {}; in python3.pkgs.buildPythonPackage rec { pname = lib.toLower properCaseName; diff --git a/pkgs/kikit/shapely/default.nix b/pkgs/kikit/shapely/default.nix new file mode 100644 index 00000000..40305c3b --- /dev/null +++ b/pkgs/kikit/shapely/default.nix @@ -0,0 +1,67 @@ +{ + pkgs, + lib, + stdenv, + fetchPypi, + substituteAll, + python3, +}: +python3.pkgs.buildPythonPackage rec { + pname = "Shapely"; + version = "1.8.4"; + disabled = python3.pkgs.pythonOlder "3.6"; + + src = fetchPypi { + inherit pname version; + sha256 = "sha256-oZXlHKr6IYKR8suqP+9p/TNTyT7EtlsqRyLEz0DDGYw="; + }; + + nativeBuildInputs = with pkgs; [ + pkgs.geos # for geos-config + python3.pkgs.cython + ]; + + propagatedBuildInputs = with python3.pkgs; [ + numpy + ]; + + checkInputs = with python3.pkgs; [ + pytestCheckHook + ]; + + # Environment variable used in shapely/_buildcfg.py + GEOS_LIBRARY_PATH = "${pkgs.geos}/lib/libgeos_c${stdenv.hostPlatform.extensions.sharedLibrary}"; + + patches = [ + # Patch to search form GOES .so/.dylib files in a Nix-aware way + (substituteAll { + src = ./library-paths.patch; + libgeos_c = GEOS_LIBRARY_PATH; + libc = lib.optionalString (!stdenv.isDarwin) "${stdenv.cc.libc}/lib/libc${stdenv.hostPlatform.extensions.sharedLibrary}.6"; + }) + ]; + + preCheck = '' + rm -r shapely # prevent import of local shapely + ''; + + disabledTests = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ + # FIXME(lf-): these logging tests are broken, which is definitely our + # fault. I've tried figuring out the cause and failed. + # + # It is apparently some sandbox or no-sandbox related thing on macOS only + # though. + "test_error_handler_exception" + "test_error_handler" + "test_info_handler" + ]; + + pythonImportsCheck = ["shapely"]; + + meta = with lib; { + description = "Geometric objects, predicates, and operations"; + homepage = "https://pypi.python.org/pypi/Shapely/"; + license = with licenses; [bsd3]; + maintainers = with maintainers; [knedlsepp]; + }; +} diff --git a/pkgs/kikit/shapely/library-paths.patch b/pkgs/kikit/shapely/library-paths.patch new file mode 100644 index 00000000..d095eada --- /dev/null +++ b/pkgs/kikit/shapely/library-paths.patch @@ -0,0 +1,31 @@ +diff --git a/shapely/geos.py b/shapely/geos.py +index 88c5f53..1ccd6e4 100644 +--- a/shapely/geos.py ++++ b/shapely/geos.py +@@ -96,6 +96,7 @@ if sys.platform.startswith('linux'): + alt_paths = [ + 'libgeos_c.so.1', + 'libgeos_c.so', ++ '@libgeos_c@', + ] + _lgeos = load_dll('geos_c', fallbacks=alt_paths) + +@@ -160,6 +161,7 @@ elif sys.platform == 'darwin': + "/usr/local/lib/libgeos_c.dylib", + # homebrew Apple Silicon + "/opt/homebrew/lib/libgeos_c.dylib", ++ "@libgeos_c@", + ] + _lgeos = load_dll('geos_c', fallbacks=alt_paths) + +diff --git a/tests/test_dlls.py b/tests/test_dlls.py +index c71da8e..c36262c 100644 +--- a/tests/test_dlls.py ++++ b/tests/test_dlls.py +@@ -18,4 +18,5 @@ class LoadingTestCase(unittest.TestCase): + '/opt/homebrew/lib/libgeos_c.dylib', # homebrew (macOS) + os.path.join(sys.prefix, "lib", "libgeos_c.so"), # anaconda (Linux) + 'libgeos_c.so.1', +- 'libgeos_c.so']) ++ 'libgeos_c.so', ++ '@libgeos_c@']) diff --git a/pkgs/kikit/solidpython/default.nix b/pkgs/kikit/solidpython/default.nix index 5c6c0a4b..17bd48c5 100644 --- a/pkgs/kikit/solidpython/default.nix +++ b/pkgs/kikit/solidpython/default.nix @@ -9,27 +9,6 @@ }: let inherit (python3.pkgs) buildPythonPackage; - # https://github.com/SolidCode/SolidPython/issues/207 - prettytablePkgsRoot = fetchFromGitHub { - owner = "NixOS"; - repo = "nixpkgs"; - rev = "6dda65e8da23cc123060e3f24723471a15b3f0cd"; - sha256 = "sha256-1zdXZIs5C81slD+nLeIk5j+O/aAujejbiW4g07JHU5s="; - }; - - prettytableFile = "${prettytablePkgsRoot}/pkgs/development/python-modules/prettytable"; - - prettytable = - python3.pkgs.callPackage - prettytableFile - { - # stdenv seems to have moved since then. Shim something that'll make this - # old version of prettytable happy. - stdenv = { - inherit lib; - }; - }; - pypng = python3.pkgs.pypng.overrideAttrs (old: rec { version = "0.0.19"; src = fetchFromGitLab { @@ -62,13 +41,18 @@ in hash = "sha256-3fJta2a5c8hV9FPwKn5pj01aBtsCGSRCz3vvxR/5n0Q="; }; + patches = [ + # Unpin PrettyTable, see . + ./prettytable.patch + ]; + propagatedBuildInputs = with python3.pkgs; [ ply + prettytable setuptools ] ++ [ - prettytable euclid3 pypng ]; diff --git a/pkgs/kikit/solidpython/prettytable.patch b/pkgs/kikit/solidpython/prettytable.patch new file mode 100644 index 00000000..d19bb137 --- /dev/null +++ b/pkgs/kikit/solidpython/prettytable.patch @@ -0,0 +1,12 @@ +diff --git a/pyproject.toml b/pyproject.toml +index 8b31bb7..0e2d0e0 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -36,7 +36,7 @@ packages=[ + python = ">=3.7" + euclid3 = "^0.1.0" + pypng = "^0.0.19" +-PrettyTable = "=0.7.2" ++PrettyTable = "*" + ply = "^3.11" + setuptools = ">=65.6.3" \ No newline at end of file From 35b6a220ae41671f190ec28b6271b72de4565bdc Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Fri, 25 Aug 2023 14:41:25 +0200 Subject: [PATCH 2/3] kikit: Use pythonRelaxDeps instead of patch --- pkgs/kikit/solidpython/default.nix | 9 ++++++--- pkgs/kikit/solidpython/prettytable.patch | 12 ------------ 2 files changed, 6 insertions(+), 15 deletions(-) delete mode 100644 pkgs/kikit/solidpython/prettytable.patch diff --git a/pkgs/kikit/solidpython/default.nix b/pkgs/kikit/solidpython/default.nix index 17bd48c5..a04dc336 100644 --- a/pkgs/kikit/solidpython/default.nix +++ b/pkgs/kikit/solidpython/default.nix @@ -41,9 +41,12 @@ in hash = "sha256-3fJta2a5c8hV9FPwKn5pj01aBtsCGSRCz3vvxR/5n0Q="; }; - patches = [ - # Unpin PrettyTable, see . - ./prettytable.patch + nativeBuildInputs = [ + python3.pkgs.pythonRelaxDepsHook + ]; + + pythonRelaxDeps = [ + "PrettyTable" ]; propagatedBuildInputs = with python3.pkgs; diff --git a/pkgs/kikit/solidpython/prettytable.patch b/pkgs/kikit/solidpython/prettytable.patch deleted file mode 100644 index d19bb137..00000000 --- a/pkgs/kikit/solidpython/prettytable.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/pyproject.toml b/pyproject.toml -index 8b31bb7..0e2d0e0 100644 ---- a/pyproject.toml -+++ b/pyproject.toml -@@ -36,7 +36,7 @@ packages=[ - python = ">=3.7" - euclid3 = "^0.1.0" - pypng = "^0.0.19" --PrettyTable = "=0.7.2" -+PrettyTable = "*" - ply = "^3.11" - setuptools = ">=65.6.3" \ No newline at end of file From 53a9fd667092cc0ddb8348e6e7b0a45b09c6b19d Mon Sep 17 00:00:00 2001 From: Cleeyv Date: Fri, 25 Aug 2023 17:43:37 -0400 Subject: [PATCH 3/3] docs: update README to replace liberaforms with pretalx --- README.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ab1ac11e..49fcb395 100644 --- a/README.md +++ b/README.md @@ -36,18 +36,29 @@ This package can then be built using the following command: nix build .#libgnunetchat ``` -## Add and deploy a service +## Add and test a service For each service there is a module file in the `modules` directory which is where most of the work is done to define the configuration for a service. Whereas the default.nix for a package usually somewhat corresponds to the upstream instructions for building and installing from source, the module for a service will correspond to the instructions for configuring and running the software persistently, including integration with other system components such as a systemd service or a web server config. Each module must also be imported into Ngipkgs by adding a line to the file `modules/all-modules.nix`. -A service has its NixOS configuration options defined in its module. To actually be used, this module file must be imported into a NixOS system configuration so that the options can be used and the service deployed. There is a directory in `configs` for each service that contains NixOS configuration template files for practical deployment of the service to different kinds of target systems, such as a container or a cloud VM. Each configuration must also be imported into Ngipkgs by adding a line to the file `configs/all-configurations.nix`. For clarity, the name given to the configuration in this file should include both the name of the service, and its target system. For example, this is the import line for deployment of liberaforms to a container: +A service has its NixOS configuration options defined in its module. To actually be used, this module file must be imported into a NixOS system configuration so that the options can be used and the service deployed or tested. There is a directory in `configs` for each service that contains NixOS configuration template files for practical use of the service to different contexts. Each configuration must also be imported into Ngipkgs by adding a line to the file `configs/all-configurations.nix`. For example, these are the import lines for deployment of pretalx with postgresql: ``` - liberaforms-container = import ./liberaforms/container.nix; + pretalx-postgresql = { + imports = [ + ./pretalx/pretalx.nix + ./pretalx/postgresql.nix + ]; ``` -This service can then be deployed on NixOS to a local container using the following comamand: +This service can then be deployed on NixOS to a local VM running integration tests using the following comamands: +```sh +nix build -L .#nixosTests.x86_64-linux.pretalx.driverInteractive +./result/bin/nixos-test-driver # Start a shell ``` -sudo nixos-container create libera0 --flake .#liberaforms-container + +Once in the spawned shell, you can start a VM that will execute the tests using the following command: +```python +start_all() # Run the VM ``` +More details on running pretalx in a test VM are available in the [README](https://github.com/ngi-nix/ngipkgs/edit/main/pkgs/pretalx/README.md) for this service. [TODO: Add details about how to do more production-like deployments that require non-default config options.]