From 5f0b8d90a866222f2d2ee5090756fb36ed4adc08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Sun, 28 Dec 2025 22:12:51 +0100 Subject: [PATCH] pun-sort: package api --- flake.lock | 23 ++++++++++++++++++----- flake.nix | 3 ++- pun-sort/default.nix | 19 +++++++++++++++++++ pun-sort/sort_api.py | 3 +-- 4 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 pun-sort/default.nix diff --git a/flake.lock b/flake.lock index 33bc7cd..d01d329 100644 --- a/flake.lock +++ b/flake.lock @@ -16,6 +16,22 @@ } }, "nixpkgs": { + "locked": { + "lastModified": 1766870016, + "narHash": "sha256-fHmxAesa6XNqnIkcS6+nIHuEmgd/iZSP/VXxweiEuQw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5c2bc52fb9f8c264ed6c93bd20afa2ff5e763dce", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1665296151, "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", @@ -33,17 +49,14 @@ }, "root": { "inputs": { - "nixpkgs": [ - "rust-overlay", - "nixpkgs" - ], + "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay" } }, "rust-overlay": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs_2" }, "locked": { "lastModified": 1677119371, diff --git a/flake.nix b/flake.nix index dc0088d..2e66b72 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,8 @@ description = "All kinds of stuff"; inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; rust-overlay.url = "github:oxalica/rust-overlay"; - nixpkgs.follows = "rust-overlay/nixpkgs"; }; outputs = @@ -52,6 +52,7 @@ }; onomap = pkgs.haskellPackages.callCabal2nix "onomap" ./onomastics-ng { }; hesychius = hesychius/hesychius.txt; + pun-sort-api = pkgs.callPackage ./pun-sort {}; alarm = pkgs.writers.writeDashBin "alarm" '' set -efu export PATH=${ diff --git a/pun-sort/default.nix b/pun-sort/default.nix new file mode 100644 index 0000000..14ba217 --- /dev/null +++ b/pun-sort/default.nix @@ -0,0 +1,19 @@ +{ writers, python3Packages }: +writers.writePython3Bin "pun_sort_api.py" { + flakeIgnore = [ + "E203" + "E203" + "E226" + "E302" + "E305" + "E501" + "F841" + "W503" + ]; + libraries = [ + python3Packages.fastapi + python3Packages.uvicorn + python3Packages.pydantic + python3Packages.pydantic-core + ]; +} ./sort_api.py diff --git a/pun-sort/sort_api.py b/pun-sort/sort_api.py index 82979a5..739634d 100755 --- a/pun-sort/sort_api.py +++ b/pun-sort/sort_api.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 """ FastAPI backend for phonetic word sorting Sorts words by their phonetic similarity using espeak-ng IPA transcription @@ -6,7 +5,7 @@ Sorts words by their phonetic similarity using espeak-ng IPA transcription from fastapi import FastAPI, HTTPException from fastapi.middleware.cors import CORSMiddleware from pydantic import BaseModel, Field -from typing import List, Optional +from typing import List import string import subprocess from functools import lru_cache