From b1fe687cf47bf947a81cfac2fd7a3b4c086d22d4 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Wed, 3 Jul 2024 16:11:44 +0200 Subject: [PATCH] feat(nix): Switch to nix-pkgs instead of local expressions --- default.nix | 31 ++++++++++--- nix/django-browser-reload/default.nix | 42 ------------------ nix/django-bulma-forms/default.nix | 36 --------------- nix/django-cas-server/01-pytest.patch | 20 --------- nix/django-cas-server/default.nix | 64 --------------------------- nix/loadcredential/default.nix | 34 -------------- npins/sources.json | 11 +++++ requirements.txt | 27 ----------- 8 files changed, 35 insertions(+), 230 deletions(-) delete mode 100644 nix/django-browser-reload/default.nix delete mode 100644 nix/django-bulma-forms/default.nix delete mode 100644 nix/django-cas-server/01-pytest.patch delete mode 100644 nix/django-cas-server/default.nix delete mode 100644 nix/loadcredential/default.nix delete mode 100644 requirements.txt diff --git a/default.nix b/default.nix index 1b05316..fa4b14a 100644 --- a/default.nix +++ b/default.nix @@ -3,22 +3,39 @@ pkgs ? import sources.nixpkgs { }, }: +let + nix-pkgs = import sources.nix-pkgs { + inherit pkgs; + # Python 3.12 is required to have the correct SSL options for connecting with the legacy server + python3Pkgs = pkgs.python312.pkgs; + }; + + python3 = pkgs.python312.override { + packageOverrides = _: _: { + inherit (nix-pkgs) + django-browser-reload + django-bulma-forms + django-cas-server + loadcredential + ; + }; + }; +in + { devShell = pkgs.mkShell { name = "cas-eleves.dev"; packages = [ - # Python 3.12 is required to have the correct SSL options for connecting with the legacy server - (pkgs.python312.withPackages (ps: [ + (python3.withPackages (ps: [ ps.django ps.ipython ps.ldap3 - # Local packages - (ps.callPackage ./nix/django-browser-reload { }) - (ps.callPackage ./nix/django-bulma-forms { }) - (ps.callPackage ./nix/django-cas-server { }) - (ps.callPackage ./nix/loadcredential { }) + ps.django-browser-reload + ps.django-bulma-forms + ps.django-cas-server + ps.loadcredential ])) pkgs.gettext diff --git a/nix/django-browser-reload/default.nix b/nix/django-browser-reload/default.nix deleted file mode 100644 index 96d243f..0000000 --- a/nix/django-browser-reload/default.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ - lib, - buildPythonPackage, - fetchFromGitHub, - setuptools, - wheel, - asgiref, - django, -}: - -buildPythonPackage rec { - pname = "django-browser-reload"; - version = "1.12.1"; - pyproject = true; - - src = fetchFromGitHub { - owner = "adamchainz"; - repo = "django-browser-reload"; - rev = version; - hash = "sha256-IDIkAl6YYI3isDvpzCtAu4fLSr2gbjEvVW+K1WBDPbo="; - }; - - nativeBuildInputs = [ - setuptools - wheel - ]; - - propagatedBuildInputs = [ - asgiref - django - ]; - - pythonImportsCheck = [ "django_browser_reload" ]; - - meta = with lib; { - description = "Automatically reload your browser in development"; - homepage = "https://github.com/adamchainz/django-browser-reload"; - changelog = "https://github.com/adamchainz/django-browser-reload/blob/${src.rev}/CHANGELOG.rst"; - license = licenses.mit; - maintainers = [ ]; # with maintainers; [ thubrecht ]; - }; -} diff --git a/nix/django-bulma-forms/default.nix b/nix/django-bulma-forms/default.nix deleted file mode 100644 index 58403f3..0000000 --- a/nix/django-bulma-forms/default.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ - lib, - buildPythonPackage, - fetchgit, - setuptools, - setuptools-scm, - wheel, - django, -}: - -buildPythonPackage rec { - pname = "django-bulma-forms"; - version = "0.1.4"; - pyproject = true; - - src = fetchgit { - url = "https://git.hubrecht.ovh/hubrecht/django-bulma-forms"; - rev = "v${version}"; - hash = "sha256-4KTMXx3YxDxB4/YH14pJnNYtpOGXeDmD+gcbrUHwD/w="; - }; - - nativeBuildInputs = [ - setuptools - setuptools-scm - wheel - ]; - - propagatedBuildInputs = [ django ]; - - meta = with lib; { - description = ""; - homepage = "https://git.hubrecht.ovh/hubrecht/django-bulma-forms"; - license = licenses.eupl12; - maintainers = [ ]; # with maintainers; [ thubrecht ]; - }; -} diff --git a/nix/django-cas-server/01-pytest.patch b/nix/django-cas-server/01-pytest.patch deleted file mode 100644 index 7a31d2b..0000000 --- a/nix/django-cas-server/01-pytest.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/cas_server/tests/test_utils.py b/cas_server/tests/test_utils.py -index d690724..73ee761 100644 ---- a/cas_server/tests/test_utils.py -+++ b/cas_server/tests/test_utils.py -@@ -17,6 +17,7 @@ from django.db import connection - import six - import warnings - import datetime -+import pytest - - from cas_server import utils - -@@ -61,6 +62,7 @@ class CheckPasswordCase(TestCase): - ) - ) - -+ @pytest.mark.skip(reason="crypt is broken somehow") - def test_crypt(self): - """test the crypt auth method""" - salts = ["$6$UVVAQvrMyXMF3FF3", "aa"] diff --git a/nix/django-cas-server/default.nix b/nix/django-cas-server/default.nix deleted file mode 100644 index 3b9bbd4..0000000 --- a/nix/django-cas-server/default.nix +++ /dev/null @@ -1,64 +0,0 @@ -{ - lib, - buildPythonPackage, - pytestCheckHook, - fetchFromGitHub, - setuptools, - wheel, - django, - lxml, - requests, - requests-futures, - six, - pytest-django, - pytest-env, - pytest-runner, - mock, -}: - -buildPythonPackage rec { - pname = "django-cas-server"; - version = "unstable-2024-04-13"; - format = "pyproject"; - - src = fetchFromGitHub { - owner = "nitmir"; - repo = "django-cas-server"; - rev = "a04477d34eedba4fcc91f00a22689defd3f22a7f"; - hash = "sha256-K6SKnYBiA1TrSdDSodYJoz1Bk20PsNo2g0dvs4XdmY0="; - }; - - patches = [ ./01-pytest.patch ]; - - nativeBuildInputs = [ - setuptools - wheel - ]; - - propagatedBuildInputs = [ - django - lxml - requests - requests-futures - setuptools - six - ]; - - nativeCheckInputs = [ - mock - pytestCheckHook - pytest-django - pytest-env - pytest-runner - ]; - - pythonImportsCheck = [ "cas_server" ]; - - meta = with lib; { - description = "A Django Central Authentication Service server implementing the CAS Protocol 3.0 Specification"; - homepage = "https://github.com/nitmir/django-cas-server"; - changelog = "https://github.com/nitmir/django-cas-server/blob/${src.rev}/CHANGELOG.rst"; - license = licenses.gpl3Only; - maintainers = [ ]; - }; -} diff --git a/nix/loadcredential/default.nix b/nix/loadcredential/default.nix deleted file mode 100644 index e05efaf..0000000 --- a/nix/loadcredential/default.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ - lib, - buildPythonPackage, - fetchFromGitHub, - setuptools, - wheel, -}: - -buildPythonPackage rec { - pname = "loadcredential"; - version = "1.2"; - pyproject = true; - - src = fetchFromGitHub { - owner = "Tom-Hubrecht"; - repo = "loadcredential"; - rev = "v${version}"; - hash = "sha256-rNWFD89h1p1jYWLcfzsa/w8nK3bR4aVJsUPx0UtZnIw="; - }; - - build-system = [ - setuptools - wheel - ]; - - pythonImportsCheck = [ "loadcredential" ]; - - meta = { - description = "A simple python package to read credentials passed through systemd's LoadCredential, with a fallback on env variables "; - homepage = "https://github.com/Tom-Hubrecht/loadcredential"; - license = lib.licenses.mit; - maintainers = []; # with lib.maintainers; [ thubrecht ]; - }; -} diff --git a/npins/sources.json b/npins/sources.json index d9b96e6..d313f03 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -1,5 +1,16 @@ { "pins": { + "nix-pkgs": { + "type": "Git", + "repository": { + "type": "Git", + "url": "https://git.hubrecht.ovh/hubrecht/nix-pkgs.git" + }, + "branch": "main", + "revision": "aa1ecb224ff9c4d200c4d5b9d229d1315c0184f0", + "url": null, + "hash": "sha256-csAikAaQcr4RdOtOf7DMkOpBBB8w1vD+MPVZGBStMVM=" + }, "nixpkgs": { "type": "Channel", "name": "nixpkgs-unstable", diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 2ed4726..0000000 --- a/requirements.txt +++ /dev/null @@ -1,27 +0,0 @@ -backcall==0.1.0 -certifi==2019.11.28 -chardet==3.0.4 -decorator==4.4.2 -Django==2.1.15 -idna==2.9 -ipython==7.13.0 -ipython-genutils==0.2.0 -jedi==0.16.0 -ldap3==2.7 -lxml==4.5.0 -parso==0.6.2 -pexpect==4.8.0 -pickleshare==0.7.5 -prompt-toolkit==3.0.4 -ptyprocess==0.6.0 -pyasn1==0.4.8 -Pygments==2.6.1 -pytz==2019.3 -requests==2.23.0 -requests-futures==1.0.0 -six==1.14.0 -traitlets==4.3.3 -urllib3==1.25.8 -wcwidth==0.1.9 -#django-cas-server==1.1.0 -git+https://github.com/tobast/django-cas-server@fix_crypt_des