From 11825d46be9875bb88b86f2f50c649ca32a6cda0 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Tue, 19 Dec 2023 23:03:38 -0600 Subject: [PATCH] Update pipenv, add ITG options, py311 from nixos23_05 --- flake.lock | 34 ++++++------- flake.nix | 7 +-- home/home.nix | 1 - home/hosts/ivr/default.nix | 17 +++++-- home/modules/default.nix | 1 + home/modules/python.nix | 10 ++++ overlays/default.nix | 3 ++ overlays/graypy.nix | 35 ++++++++++++++ overlays/itg-django-utils.nix | 35 ++++++++++++++ overlays/pipenv.nix | 90 +++++++++++++++++++++++++++++++++++ 10 files changed, 209 insertions(+), 24 deletions(-) create mode 100644 home/modules/python.nix create mode 100644 overlays/graypy.nix create mode 100644 overlays/itg-django-utils.nix create mode 100644 overlays/pipenv.nix diff --git a/flake.lock b/flake.lock index 7170cee..aaccb3f 100644 --- a/flake.lock +++ b/flake.lock @@ -274,6 +274,22 @@ "type": "github" } }, + "nix23_05": { + "locked": { + "lastModified": 1702759837, + "narHash": "sha256-u3XeJVRe/Q975nwFE+6ALEwypMKJEELMJKDAhSKyq3M=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b2566f4f897ac6224e094b167d9488d03e157f28", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, "nixneovim": { "inputs": { "flake-utils": "flake-utils_2", @@ -372,22 +388,6 @@ "type": "github" } }, - "nixpy311": { - "locked": { - "lastModified": 1698696950, - "narHash": "sha256-FHFL58t6lMumvWqwundC8fDDDLOIvc+JJBNIAlPjrDY=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "017ef2132a5bda50bd713aeabce8f918502d4ec1", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-23.05", - "repo": "nixpkgs", - "type": "github" - } - }, "nixstable": { "locked": { "lastModified": 1702233072, @@ -502,8 +502,8 @@ "flake-utils": "flake-utils", "hm": "hm", "hmunstable": "hmunstable", + "nix23_05": "nix23_05", "nixneovim": "nixneovim", - "nixpy311": "nixpy311", "nixstable": "nixstable", "nixunstable": "nixunstable", "nurpkgs": "nurpkgs", diff --git a/flake.nix b/flake.nix index e309825..15533ae 100644 --- a/flake.nix +++ b/flake.nix @@ -20,7 +20,7 @@ inputs.nixpkgs.follows = "nixstable"; }; nixneovim.url = "github:NixNeovim/NixNeovim"; - nixpy311.url = "github:NixOS/nixpkgs/nixos-23.05"; + nix23_05.url = "github:NixOS/nixpkgs/nixos-23.05"; nixstable.url = "github:nixos/nixpkgs/nixos-23.11"; nixunstable.url = "github:nixos/nixpkgs/nixos-unstable"; nurpkgs.url = "github:nix-community/NUR"; @@ -37,7 +37,7 @@ hm, hmunstable, nixneovim, - nixpy311, + nix23_05, nixstable, nixunstable, nurpkgs, @@ -48,7 +48,8 @@ let pkg-sets = ( final: prev: { - unstable = import inputs.nixunstable { system = final.system; }; + unstable = import inputs.nixunstable { system = final.system; inherit overlays; }; + nix23_05 = import inputs.nix23_05 { system = final.system; inherit overlays; }; } ); local_overlay = import ./overlays; diff --git a/home/home.nix b/home/home.nix index 25e6912..2bb02f5 100644 --- a/home/home.nix +++ b/home/home.nix @@ -41,7 +41,6 @@ gh git gnupatch - gregpy hms htop inetutils diff --git a/home/hosts/ivr/default.nix b/home/hosts/ivr/default.nix index e2713dc..1300fc9 100644 --- a/home/hosts/ivr/default.nix +++ b/home/hosts/ivr/default.nix @@ -1,10 +1,21 @@ { pkgs, lib, inputs, ...}: - -{ +let + py = pkgs.nix23_05.python311.withPackages ( p: with p; [ + django + djangorestframework + django-rapyd-modernauth + environs + #itg-django-utils + mysqlclient + ruamel-yaml + tox + ]); +in { imports = [ ../../vscodium.nix ]; + greg.pypackage = py; home = { packages = with pkgs; [ aacs @@ -13,7 +24,7 @@ direnv home-manager insomnia - pipenv + pipenv-ivr ]; file.".pip/pip.conf".text = (lib.strings.concatStringsSep "\n" [ "[global]" diff --git a/home/modules/default.nix b/home/modules/default.nix index a6344c7..81d29d5 100644 --- a/home/modules/default.nix +++ b/home/modules/default.nix @@ -3,6 +3,7 @@ { imports = [ ./gnome.nix + ./python.nix ./xonsh.nix ]; } diff --git a/home/modules/python.nix b/home/modules/python.nix new file mode 100644 index 0000000..d7ed997 --- /dev/null +++ b/home/modules/python.nix @@ -0,0 +1,10 @@ +{ config, pkgs, lib, ... }: +{ + options.greg.pypackage = lib.mkOption { + description = "Enable Gnome support and settings"; + type = lib.types.package; + default = pkgs.gregpy; + }; + + config.home.packages = [ config.greg.pypackage ]; +} diff --git a/overlays/default.nix b/overlays/default.nix index ec7a7a0..7f58711 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -33,6 +33,8 @@ in rec { pythonPackagesExtensions = (prev.pythonPackagesExtensions or []) ++ [ (python-final: python-prev: let cp = python-final.callPackage; in { django-rapyd-modernauth = cp ./django-rapyd-modernauth.nix {}; + graypy = cp ./graypy.nix {}; + itg-django-utils = cp ./itg-django-utils.nix {}; xonsh-apipenv = cp ./xonsh-apipenv.nix {}; xonsh-direnv = cp ./xonsh-direnv.nix {}; xontrib-vox = cp ./xonsh-vox.nix {}; @@ -63,6 +65,7 @@ in rec { handbrake = prev.handbrake.override { libbluray = libbluray-custom; }; + pipenv-ivr = prev.callPackage ./pipenv.nix { }; xonsh = prev.xonsh.overridePythonAttrs (old: rec{ python3 = final.gregpy; diff --git a/overlays/graypy.nix b/overlays/graypy.nix new file mode 100644 index 0000000..2cce63e --- /dev/null +++ b/overlays/graypy.nix @@ -0,0 +1,35 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + + amqplib, + mock, + pytestCheckHook, + requests, +}: + +buildPythonPackage rec { + pname = "graypy"; + version = "2.1.0"; + + src = fetchFromGitHub { + owner = "severb"; + repo = "graypy"; + rev = "2.1.0"; + hash = "sha256-y1HbJEpqnAgOeB+zXKy3iUT6Lpv0bufjL7+jWUSAjFs="; + }; + + nativeCheckInputs = [ + amqplib + mock + pytestCheckHook + requests + ]; + + meta = with lib; { + description = "Python logging handlers that send messages in the Graylog Extended Log Format (GELF)."; + homepage = "https://github.com/severb/graypy"; + license = licenses.bsd3; + }; +} diff --git a/overlays/itg-django-utils.nix b/overlays/itg-django-utils.nix new file mode 100644 index 0000000..0a4f712 --- /dev/null +++ b/overlays/itg-django-utils.nix @@ -0,0 +1,35 @@ +{ + lib, + buildPythonPackage, + fetchurl, + + django, + djangorestframework, + graypy, + setuptools, +}: + +buildPythonPackage rec { + pname = "itg-django-utils"; + version = "0.1.11"; + + src = fetchurl { + url = "https://pypi.ivrtechnology.com/packages/itg-django-utils-0.1.12.tar.gz"; + hash = "sha256-LbOl4L4UZbRTlLuBL4L3ser6+WDuP3R5a03EIh1xSK8="; + }; + + propagatedBuildInputs = [ + django + djangorestframework + graypy + setuptools + ]; + + meta = with lib; { + description = "ITG specific stuff"; + homepage = "http://www.ivrtechnology.com"; + maintainers = []; + }; + + doCheck = false; +} diff --git a/overlays/pipenv.nix b/overlays/pipenv.nix new file mode 100644 index 0000000..6f129ab --- /dev/null +++ b/overlays/pipenv.nix @@ -0,0 +1,90 @@ +{ lib +, stdenv +, python3 +, fetchFromGitHub +, installShellFiles +}: + +with python3.pkgs; + +let + + runtimeDeps = ps: with ps; [ + certifi + setuptools + pip + virtualenv + virtualenv-clone + ] + ++ lib.optionals stdenv.hostPlatform.isAndroid [ + pyjnius + ]; + + pythonEnv = python3.withPackages runtimeDeps; + +in buildPythonApplication rec { + pname = "pipenv"; + version = "2023.11.15"; + format = "pyproject"; + + src = fetchFromGitHub { + owner = "pypa"; + repo = "pipenv"; + rev = "refs/tags/v${version}"; + hash = "sha256-kxwyws22xJkqBy/hXXcAPHZR2NgZHbmwZr9vYqce434="; + }; + + env.LC_ALL = "en_US.UTF-8"; + + nativeBuildInputs = [ + installShellFiles + setuptools + wheel + ]; + + postPatch = '' + # pipenv invokes python in a subprocess to create a virtualenv + # and to call setup.py. + # It would use sys.executable, which in our case points to a python that + # does not have the required dependencies. + substituteInPlace pipenv/utils/virtualenv.py \ + --replace "sys.executable" "'${pythonEnv.interpreter}'" + ''; + + propagatedBuildInputs = runtimeDeps python3.pkgs; + + preCheck = '' + export HOME="$TMPDIR" + ''; + + nativeCheckInputs = [ + mock + pytestCheckHook + pytest-xdist + pytz + requests + ]; + + disabledTests = [ + "test_convert_deps_to_pip" + "test_download_file" + ]; + + disabledTestPaths = [ + "tests/integration" + ]; + + postInstall = '' + installShellCompletion --cmd pipenv \ + --bash <(_PIPENV_COMPLETE=bash_source $out/bin/pipenv) \ + --zsh <(_PIPENV_COMPLETE=zsh_source $out/bin/pipenv) \ + --fish <(_PIPENV_COMPLETE=fish_source $out/bin/pipenv) + ''; + + meta = with lib; { + description = "Python Development Workflow for Humans"; + license = licenses.mit; + platforms = platforms.all; + maintainers = with maintainers; [ berdario ]; + }; +}