From e482745a0bd4b0cfeb24cd782c99a4e3cfa42f57 Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Thu, 27 Jan 2022 12:19:24 -0500
Subject: [PATCH] drop all of the hand-rolled nix packaging expressions

---
 nix/autobahn.nix             |  34 ----------
 nix/cbor2.nix                |  20 ------
 nix/collections-extended.nix |  19 ------
 nix/default.nix              |   7 --
 nix/eliot.nix                |  31 ---------
 nix/future.nix               |  35 ----------
 nix/overlays.nix             |  36 ----------
 nix/py3.nix                  |   7 --
 nix/pyutil.nix               |  48 -------------
 nix/tahoe-lafs.nix           | 126 -----------------------------------
 nix/twisted.nix              |  63 ------------------
 11 files changed, 426 deletions(-)
 delete mode 100644 nix/autobahn.nix
 delete mode 100644 nix/cbor2.nix
 delete mode 100644 nix/collections-extended.nix
 delete mode 100644 nix/default.nix
 delete mode 100644 nix/eliot.nix
 delete mode 100644 nix/future.nix
 delete mode 100644 nix/overlays.nix
 delete mode 100644 nix/py3.nix
 delete mode 100644 nix/pyutil.nix
 delete mode 100644 nix/tahoe-lafs.nix
 delete mode 100644 nix/twisted.nix

diff --git a/nix/autobahn.nix b/nix/autobahn.nix
deleted file mode 100644
index 83148c4f8..000000000
--- a/nix/autobahn.nix
+++ /dev/null
@@ -1,34 +0,0 @@
-{ lib, buildPythonPackage, fetchPypi, isPy3k,
-  six, txaio, twisted, zope_interface, cffi, futures,
-  mock, pytest, cryptography, pynacl
-}:
-buildPythonPackage rec {
-  pname = "autobahn";
-  version = "19.8.1";
-
-  src = fetchPypi {
-    inherit pname version;
-    sha256 = "294e7381dd54e73834354832604ae85567caf391c39363fed0ea2bfa86aa4304";
-  };
-
-  propagatedBuildInputs = [ six txaio twisted zope_interface cffi cryptography pynacl ] ++
-    (lib.optionals (!isPy3k) [ futures ]);
-
-  checkInputs = [ mock pytest ];
-  checkPhase = ''
-    runHook preCheck
-    USE_TWISTED=true py.test $out
-    runHook postCheck
-  '';
-
-  # Tests do no seem to be compatible yet with pytest 5.1
-  # https://github.com/crossbario/autobahn-python/issues/1235
-  doCheck = false;
-
-  meta = with lib; {
-    description = "WebSocket and WAMP in Python for Twisted and asyncio.";
-    homepage    = "https://crossbar.io/autobahn";
-    license     = licenses.mit;
-    maintainers = with maintainers; [ nand0p ];
-  };
-}
diff --git a/nix/cbor2.nix b/nix/cbor2.nix
deleted file mode 100644
index 16ca8ff63..000000000
--- a/nix/cbor2.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-{ lib, buildPythonPackage, fetchPypi, setuptools_scm }:
-buildPythonPackage rec {
-  pname = "cbor2";
-  version = "5.2.0";
-
-  src = fetchPypi {
-    sha256 = "1gwlgjl70vlv35cgkcw3cg7b5qsmws36hs4mmh0l9msgagjs4fm3";
-    inherit pname version;
-  };
-
-  doCheck = false;
-
-  propagatedBuildInputs = [ setuptools_scm ];
-
-  meta = with lib; {
-    homepage = https://github.com/agronholm/cbor2;
-    description = "CBOR encoder/decoder";
-    license = licenses.mit;
-  };
-}
diff --git a/nix/collections-extended.nix b/nix/collections-extended.nix
deleted file mode 100644
index 3f1ad165a..000000000
--- a/nix/collections-extended.nix
+++ /dev/null
@@ -1,19 +0,0 @@
-{ lib, buildPythonPackage, fetchPypi }:
-buildPythonPackage rec {
-  pname = "collections-extended";
-  version = "1.0.3";
-
-  src = fetchPypi {
-    inherit pname version;
-    sha256 = "0lb69x23asd68n0dgw6lzxfclavrp2764xsnh45jm97njdplznkw";
-  };
-
-  # Tests aren't in tarball, for 1.0.3 at least.
-  doCheck = false;
-
-  meta = with lib; {
-    homepage = https://github.com/mlenzen/collections-extended;
-    description = "Extra Python Collections - bags (multisets), setlists (unique list / indexed set), RangeMap and IndexedDict";
-    license = licenses.asl20;
-  };
-}
diff --git a/nix/default.nix b/nix/default.nix
deleted file mode 100644
index bd7460c2f..000000000
--- a/nix/default.nix
+++ /dev/null
@@ -1,7 +0,0 @@
-# This is the main entrypoint for the Tahoe-LAFS derivation.
-{ pkgs ? import <nixpkgs> { } }:
-# Add our Python packages to nixpkgs to simplify the expression for the
-# Tahoe-LAFS derivation.
-let pkgs' = pkgs.extend (import ./overlays.nix);
-# Evaluate the expression for our Tahoe-LAFS derivation.
-in pkgs'.python2.pkgs.callPackage ./tahoe-lafs.nix { }
diff --git a/nix/eliot.nix b/nix/eliot.nix
deleted file mode 100644
index c5975e990..000000000
--- a/nix/eliot.nix
+++ /dev/null
@@ -1,31 +0,0 @@
-{ lib, buildPythonPackage, fetchPypi, zope_interface, pyrsistent, boltons
-, hypothesis, testtools, pytest }:
-buildPythonPackage rec {
-  pname = "eliot";
-  version = "1.7.0";
-
-  src = fetchPypi {
-    inherit pname version;
-    sha256 = "0ylyycf717s5qsrx8b9n6m38vyj2k8328lfhn8y6r31824991wv8";
-  };
-
-  postPatch = ''
-    substituteInPlace setup.py \
-      --replace "boltons >= 19.0.1" boltons
-  '';
-
-  # A seemingly random subset of the test suite fails intermittently.  After
-  # Tahoe-LAFS is ported to Python 3 we can update to a newer Eliot and, if
-  # the test suite continues to fail, maybe it will be more likely that we can
-  # have upstream fix it for us.
-  doCheck = false;
-
-  checkInputs = [ testtools pytest hypothesis ];
-  propagatedBuildInputs = [ zope_interface pyrsistent boltons ];
-
-  meta = with lib; {
-    homepage = https://github.com/itamarst/eliot/;
-    description = "Logging library that tells you why it happened";
-    license = licenses.asl20;
-  };
-}
diff --git a/nix/future.nix b/nix/future.nix
deleted file mode 100644
index 814b7c1b5..000000000
--- a/nix/future.nix
+++ /dev/null
@@ -1,35 +0,0 @@
-{ lib
-, buildPythonPackage
-, fetchPypi
-}:
-
-buildPythonPackage rec {
-  pname = "future";
-  version = "0.18.2";
-
-  src = fetchPypi {
-    inherit pname version;
-    sha256 = "sha256:0zakvfj87gy6mn1nba06sdha63rn4njm7bhh0wzyrxhcny8avgmi";
-  };
-
-  doCheck = false;
-
-  meta = {
-    description = "Clean single-source support for Python 3 and 2";
-    longDescription = ''
-      python-future is the missing compatibility layer between Python 2 and
-      Python 3. It allows you to use a single, clean Python 3.x-compatible
-      codebase to support both Python 2 and Python 3 with minimal overhead.
-
-      It provides future and past packages with backports and forward ports
-      of features from Python 3 and 2. It also comes with futurize and
-      pasteurize, customized 2to3-based scripts that helps you to convert
-      either Py2 or Py3 code easily to support both Python 2 and 3 in a
-      single clean Py3-style codebase, module by module.
-    '';
-    homepage = https://python-future.org;
-    downloadPage = https://github.com/PythonCharmers/python-future/releases;
-    license = with lib.licenses; [ mit ];
-    maintainers = with lib.maintainers; [ prikhi ];
-  };
-}
diff --git a/nix/overlays.nix b/nix/overlays.nix
deleted file mode 100644
index 92f36e93e..000000000
--- a/nix/overlays.nix
+++ /dev/null
@@ -1,36 +0,0 @@
-self: super: {
-  python27 = super.python27.override {
-    packageOverrides = python-self: python-super: {
-      # eliot is not part of nixpkgs at all at this time.
-      eliot = python-self.pythonPackages.callPackage ./eliot.nix { };
-
-      # NixOS autobahn package has trollius as a dependency, although
-      # it is optional. Trollius is unmaintained and fails on CI.
-      autobahn = python-super.pythonPackages.callPackage ./autobahn.nix { };
-
-      # Porting to Python 3 is greatly aided by the future package.  A
-      # slightly newer version than appears in nixos 19.09 is helpful.
-      future = python-super.pythonPackages.callPackage ./future.nix { };
-
-      # Need version of pyutil that supports Python 3. The version in 19.09
-      # is too old.
-      pyutil = python-super.pythonPackages.callPackage ./pyutil.nix { };
-
-      # Need a newer version of Twisted, too.
-      twisted = python-super.pythonPackages.callPackage ./twisted.nix { };
-
-      # collections-extended is not part of nixpkgs at this time.
-      collections-extended = python-super.pythonPackages.callPackage ./collections-extended.nix { };
-
-      # cbor2 is not part of nixpkgs at this time.
-      cbor2 = python-super.pythonPackages.callPackage ./cbor2.nix { };
-    };
-  };
-
-  python39 = super.python39.override {
-    packageOverrides = python-self: python-super: {
-      # collections-extended is not part of nixpkgs at this time.
-      collections-extended = python-super.pythonPackages.callPackage ./collections-extended.nix { };
-    };
-  };
-}
diff --git a/nix/py3.nix b/nix/py3.nix
deleted file mode 100644
index 34ede49dd..000000000
--- a/nix/py3.nix
+++ /dev/null
@@ -1,7 +0,0 @@
-# This is the main entrypoint for the Tahoe-LAFS derivation.
-{ pkgs ? import <nixpkgs> { } }:
-# Add our Python packages to nixpkgs to simplify the expression for the
-# Tahoe-LAFS derivation.
-let pkgs' = pkgs.extend (import ./overlays.nix);
-# Evaluate the expression for our Tahoe-LAFS derivation.
-in pkgs'.python39.pkgs.callPackage ./tahoe-lafs.nix { }
diff --git a/nix/pyutil.nix b/nix/pyutil.nix
deleted file mode 100644
index 6852c2acc..000000000
--- a/nix/pyutil.nix
+++ /dev/null
@@ -1,48 +0,0 @@
-{ stdenv
-, buildPythonPackage
-, fetchPypi
-, setuptoolsDarcs
-, setuptoolsTrial
-, simplejson
-, twisted
-, isPyPy
-}:
-
-buildPythonPackage rec {
-  pname = "pyutil";
-  version = "3.3.0";
-
-  src = fetchPypi {
-    inherit pname version;
-    sha256 = "8c4d4bf668c559186389bb9bce99e4b1b871c09ba252a756ccaacd2b8f401848";
-  };
-
-  buildInputs = [ setuptoolsDarcs setuptoolsTrial ] ++ (if doCheck then [ simplejson ] else []);
-  propagatedBuildInputs = [ twisted ];
-
-  # Tests fail because they try to write new code into the twisted
-  # package, apparently some kind of plugin.
-  doCheck = false;
-
-  prePatch = stdenv.lib.optionalString isPyPy ''
-    grep -rl 'utf-8-with-signature-unix' ./ | xargs sed -i -e "s|utf-8-with-signature-unix|utf-8|g"
-  '';
-
-  meta = with stdenv.lib; {
-    description = "Pyutil, a collection of mature utilities for Python programmers";
-
-    longDescription = ''
-      These are a few data structures, classes and functions which
-      we've needed over many years of Python programming and which
-      seem to be of general use to other Python programmers. Many of
-      the modules that have existed in pyutil over the years have
-      subsequently been obsoleted by new features added to the
-      Python language or its standard library, thus showing that
-      we're not alone in wanting tools like these.
-    '';
-
-    homepage = "http://allmydata.org/trac/pyutil";
-    license = licenses.gpl2Plus;
-  };
-
-}
\ No newline at end of file
diff --git a/nix/tahoe-lafs.nix b/nix/tahoe-lafs.nix
deleted file mode 100644
index 2b41e676e..000000000
--- a/nix/tahoe-lafs.nix
+++ /dev/null
@@ -1,126 +0,0 @@
-{ fetchFromGitHub, lib
-, git, python
-, twisted, foolscap, zfec
-, setuptools, setuptoolsTrial, pyasn1, zope_interface
-, service-identity, pyyaml, magic-wormhole, treq, appdirs
-, beautifulsoup4, eliot, autobahn, cryptography, netifaces
-, html5lib, pyutil, distro, configparser, klein, cbor2
-}:
-python.pkgs.buildPythonPackage rec {
-  # Most of the time this is not exactly the release version (eg 1.17.1).
-  # Give it a `post` component to make it look newer than the release version
-  # and we'll bump this up at the time of each release.
-  #
-  # It's difficult to read the version from Git the way the Python code does
-  # for two reasons.  First, doing so involves populating the Nix expression
-  # with values from the source.  Nix calls this "import from derivation" or
-  # "IFD" (<https://nixos.wiki/wiki/Import_From_Derivation>).  This is
-  # discouraged in most cases - including this one, I think.  Second, the
-  # Python code reads the contents of `.git` to determine its version.  `.git`
-  # is not a reproducable artifact (in the sense of "reproducable builds") so
-  # it is excluded from the source tree by default.  When it is included, the
-  # package tends to be frequently spuriously rebuilt.
-  version = "1.17.1.post1";
-  name = "tahoe-lafs-${version}";
-  src = lib.cleanSourceWith {
-    src = ../.;
-    filter = name: type:
-      let
-        basename = baseNameOf name;
-
-        split = lib.splitString ".";
-        join = builtins.concatStringsSep ".";
-        ext = join (builtins.tail (split basename));
-
-        # Build up a bunch of knowledge about what kind of file this is.
-        isTox = type == "directory" && basename == ".tox";
-        isTrialTemp = type == "directory" && basename == "_trial_temp";
-        isVersion = basename == "_version.py";
-        isBytecode = ext == "pyc" || ext == "pyo";
-        isBackup = lib.hasSuffix "~" basename;
-        isTemporary = lib.hasPrefix "#" basename && lib.hasSuffix "#" basename;
-        isSymlink = type == "symlink";
-        isGit = type == "directory" && basename == ".git";
-      in
-      # Exclude all these things
-      ! (isTox
-      || isTrialTemp
-      || isVersion
-      || isBytecode
-      || isBackup
-      || isTemporary
-      || isSymlink
-      || isGit
-      );
-  };
-
-  postPatch = ''
-    # Chroots don't have /etc/hosts and /etc/resolv.conf, so work around
-    # that.
-    for i in $(find src/allmydata/test -type f)
-    do
-      sed -i "$i" -e"s/localhost/127.0.0.1/g"
-    done
-
-    # Some tests are flaky or fail to skip when dependencies are missing.
-    # This list is over-zealous because it's more work to disable individual
-    # tests with in a module.
-
-    # Many of these tests don't properly skip when i2p or tor dependencies are
-    # not supplied (and we are not supplying them).
-    rm src/allmydata/test/test_i2p_provider.py
-    rm src/allmydata/test/test_connections.py
-    rm src/allmydata/test/cli/test_create.py
-
-    # Generate _version.py ourselves since we can't rely on the Python code
-    # extracting the information from the .git directory we excluded.
-    cat > src/allmydata/_version.py <<EOF
-
-# This _version.py is generated from metadata by nix/tahoe-lafs.nix.
-
-__pkgname__ = "tahoe-lafs"
-real_version = "${version}"
-full_version = "${version}"
-branch = "master"
-verstr = "${version}"
-__version__ = verstr
-EOF
-'';
-
-
-  nativeBuildInputs = [
-    git
-  ];
-
-  propagatedBuildInputs = with python.pkgs; [
-    twisted foolscap zfec appdirs
-    setuptoolsTrial pyasn1 zope_interface
-    service-identity pyyaml magic-wormhole
-    eliot autobahn cryptography netifaces setuptools
-    future pyutil distro configparser collections-extended
-    klein cbor2 treq
-  ];
-
-  checkInputs = with python.pkgs; [
-    hypothesis
-    testtools
-    fixtures
-    beautifulsoup4
-    html5lib
-    tenacity
-    prometheus_client
-  ];
-
-  checkPhase = ''
-    if ! $out/bin/tahoe --version | grep --fixed-strings "${version}"; then
-      echo "Package version:"
-      $out/bin/tahoe --version
-      echo "Did not contain expected:"
-      echo "${version}"
-      exit 1
-    else
-      echo "Version string contained expected value \"${version}.\""
-    fi
-    ${python}/bin/python -m twisted.trial -j $NIX_BUILD_CORES allmydata
-  '';
-}
diff --git a/nix/twisted.nix b/nix/twisted.nix
deleted file mode 100644
index 3c11e3c71..000000000
--- a/nix/twisted.nix
+++ /dev/null
@@ -1,63 +0,0 @@
-{ stdenv
-, buildPythonPackage
-, fetchPypi
-, python
-, zope_interface
-, incremental
-, automat
-, constantly
-, hyperlink
-, pyhamcrest
-, attrs
-, pyopenssl
-, service-identity
-, setuptools
-, idna
-, bcrypt
-}:
-buildPythonPackage rec {
-  pname = "Twisted";
-  version = "19.10.0";
-
-  src = fetchPypi {
-    inherit pname version;
-    extension = "tar.bz2";
-    sha256 = "7394ba7f272ae722a74f3d969dcf599bc4ef093bc392038748a490f1724a515d";
-  };
-
-  propagatedBuildInputs = [ zope_interface incremental automat constantly hyperlink pyhamcrest attrs setuptools bcrypt ];
-
-  passthru.extras.tls = [ pyopenssl service-identity idna ];
-
-  # Patch t.p._inotify to point to libc. Without this,
-  # twisted.python.runtime.platform.supportsINotify() == False
-  patchPhase = stdenv.lib.optionalString stdenv.isLinux ''
-    substituteInPlace src/twisted/python/_inotify.py --replace \
-      "ctypes.util.find_library('c')" "'${stdenv.glibc.out}/lib/libc.so.6'"
-  '';
-
-  # Generate Twisted's plug-in cache.  Twisted users must do it as well.  See
-  # http://twistedmatrix.com/documents/current/core/howto/plugin.html#auto3
-  # and http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=477103 for
-  # details.
-  postFixup = ''
-    $out/bin/twistd --help > /dev/null
-  '';
-
-  checkPhase = ''
-    ${python.interpreter} -m unittest discover -s twisted/test
-  '';
-  # Tests require network
-  doCheck = false;
-
-  meta = with stdenv.lib; {
-    homepage = https://twistedmatrix.com/;
-    description = "Twisted, an event-driven networking engine written in Python";
-    longDescription = ''
-      Twisted is an event-driven networking engine written in Python
-      and licensed under the MIT license.
-    '';
-    license = licenses.mit;
-    maintainers = [ ];
-  };
-}