Add pretix package

This commit is contained in:
Jakob Lechner 2023-02-21 21:54:42 +00:00
parent 52f2fd30b8
commit 337c2598b6
No known key found for this signature in database
GPG key ID: 996082EFB5906C10
12 changed files with 4411 additions and 1 deletions

2
.gitignore vendored
View file

@ -1,4 +1,4 @@
result*
.pre-commit-config.yaml
/.direnv
.direnv
__pycache__

View file

@ -3,6 +3,8 @@ let
inherit (prev) callPackage;
in
{
pretix = callPackage ./pretix/pretix.nix { };
pretix-static = callPackage ./pretix/pretix-static.nix { };
fpvout = callPackage ./fpvout { };
mute-indicator = callPackage ./mute-indicator { };
tabbed-box-maker = callPackage ./tabbed-box-maker { };

1
pkgs/pretix/.envrc Normal file
View file

@ -0,0 +1 @@
use nix

2749
pkgs/pretix/poetry.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,48 @@
{ stdenvNoCC
, pretix
, buildNpmPackage
, makeWrapper
}:
let
nodeEnv = buildNpmPackage rec {
name = "pretix-nodejs";
src = "${pretix.passthru.pythonModule.pkgs.pretix}/lib/python3.10/site-packages/pretix/static/npm_dir";
npmDepsHash = "sha256-bRy3Elof7daxv0dD93SnPcJ0fT19Mkq81gZPJduMCC4=";
dontNpmBuild = true;
installPhase = ''
mkdir -p $out
cp -r node_modules $out/
mkdir -p $out/bin
ln -s $out/node_modules/rollup/dist/bin/rollup $out/bin/rollup
'';
postFixup = ''
wrapProgram $out/bin/rollup --prefix NODE_PATH : $out
'';
nativeBuildInputs = [
makeWrapper
];
};
in
stdenvNoCC.mkDerivation {
name = "pretix-static";
src = ./.;
buildPhase = ''
mkdir $out
export PRETIX_STATIC_ROOT=$out
export DJANGO_SETTINGS_MODULE=pretix_wrapper.settings
${pretix}/bin/pretix collectstatic --noinput
mkdir -p $PRETIX_STATIC_ROOT/node_prefix
ln -s ${nodeEnv}/node_modules $PRETIX_STATIC_ROOT/node_prefix/node_modules
echo ${nodeEnv}/bin/rollup
${pretix}/bin/pretix compress
'';
installPhase = ''
runHook preInstall
runHook postInstall
'';
nativeBuildInputs = [
nodeEnv
];
}

52
pkgs/pretix/pretix.nix Normal file
View file

@ -0,0 +1,52 @@
{ lib
, poetry2nix
, pkgs
, tlds-alpha-by-domain ? ./tlds-alpha-by-domain.txt
}:
let
tlds = pkgs.fetchurl {
url = "https://data.iana.org/TLD/tlds-alpha-by-domain.txt";
sha256 = "0153py77ll759jacq41dp2z2ksr08pdcfic0rwjd6pr84dk89y9v";
};
pkgsRequiringSetuptools = [
"dj-static"
"django-jquery-js"
"paypal-checkout-serversdk"
"python-u2flib-server"
"slimit"
"static3"
];
in
poetry2nix.mkPoetryApplication rec {
projectDir = ./.;
#python = pkgs.python310;
preferWheels = true;
overrides = poetry2nix.defaultPoetryOverrides.extend
(
self: super: lib.attrsets.genAttrs pkgsRequiringSetuptools
(
pythonPackage:
super."${pythonPackage}".overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
}
)
) // {
tlds = super.tlds.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
patches = [
./tlds-read-domains-from-file.patch
];
# https://data.iana.org/TLD/tlds-alpha-by-domain.txt
preBuild = "cp ${tlds-alpha-by-domain} ./tlds-alpha-by-domain.txt";
}
);
}
);
}
# .overrideAttrs(old: {
# inherit (old.passthru.pythonPackages.pretix) pname name version;
# })

View file

@ -0,0 +1,9 @@
import sys
import os
module_name = "pretix"
def main():
os.environ["PYTHONPATH"] = ":".join(sys.path)
os.execv(sys.executable, [sys.executable, "-m", module_name, *sys.argv[1:]])

View file

@ -0,0 +1,4 @@
import os
from pretix.settings import *
STATIC_ROOT = os.getenv("PRETIX_STATIC_ROOT")

View file

@ -0,0 +1,19 @@
[tool.poetry]
name = "pretix_wrapper"
version = "1.0.0"
description = ""
authors = ["Jakob Lechner <mail@jalr.de>"]
license = "MIT"
[tool.poetry.dependencies]
python = "^3.10"
pretix = "^4.16"
[tool.poetry.dev-dependencies]
[tool.poetry.scripts]
pretix = "pretix_wrapper.__main__:main"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

8
pkgs/pretix/shell.nix Normal file
View file

@ -0,0 +1,8 @@
with import <nixpkgs> { };
mkShell {
buildInputs = [
poetry
];
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,36 @@
From 40544e83b5920c84a4565c2bf8dc29fc381d5796 Mon Sep 17 00:00:00 2001
From: Jakob Lechner <mail@jalr.de>
Date: Tue, 21 Feb 2023 21:25:06 +0000
Subject: [PATCH] read static file
---
setup.py | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/setup.py b/setup.py
index 6b4653c..13b6ad4 100644
--- a/setup.py
+++ b/setup.py
@@ -8,16 +8,9 @@ from setuptools import setup, find_packages
if sys.version_info.major >= 3:
import urllib.request
- r = urllib.request.urlopen('https://data.iana.org/TLD/tlds-alpha-by-domain.txt')
- assert r.status == 200
- data = r.read().decode('utf-8').split('\n')
-else:
- import urllib
-
- r = urllib.urlopen('https://data.iana.org/TLD/tlds-alpha-by-domain.txt')
- assert r.getcode() == 200
- data = r.read().split('\n')
-
+ with open("tlds-alpha-by-domain.txt", 'r') as f:
+ data = f.read().split('\n')
+
version = re.match('^# Version (?P<version>[0-9]+).*$', data[0]).group('version')
tlds = [i.lower() for i in data[1:] if i and not i.startswith('#')]
--
2.38.3