Skip to content
Snippets Groups Projects
default.nix 5.08 KiB
Newer Older
  • Learn to ignore specific revisions
  • Tom Prince's avatar
    Tom Prince committed
    let
      sources = import nix/sources.nix;
    in
    
    { pkgs ? import sources.release2111 { }
    
    Tom Prince's avatar
    Tom Prince committed
    , pypiData ? sources.pypi-deps-db
    
    , mach-nix ? import sources.mach-nix { inherit pkgs pypiData python; }
    
    , tahoe-lafs-source ? "tahoe-lafs"
    
    Tom Prince's avatar
    Tom Prince committed
    , tahoe-lafs-repo ? sources.${tahoe-lafs-source}
    
    Tom Prince's avatar
    Tom Prince committed
    }:
    
    Tom Prince's avatar
    Tom Prince committed
      let
    
    Tom Prince's avatar
    Tom Prince committed
        lib = pkgs.lib;
    
    Tom Prince's avatar
    Tom Prince committed
        providers = {
          _default = "sdist,nixpkgs,wheel";
    
    Tom Prince's avatar
    Tom Prince committed
          # mach-nix doesn't provide a good way to depend on mach-nix packages,
          # so we get it as a nixpkgs dependency from an overlay. See below for
          # details.
    
    Tom Prince's avatar
    Tom Prince committed
          tahoe-lafs = "nixpkgs";
    
    Tom Prince's avatar
    Tom Prince committed
          # not packaged in nixpkgs at all, we can use the binary wheel from
          # pypi though.
          python-challenge-bypass-ristretto = "wheel";
          # Pure python packages that don't build correctly from sdists
          # - patches in nixpkgs that don't apply
          boltons = "wheel";
          chardet = "wheel";
          urllib3 = "wheel";
    
    Tom Prince's avatar
    Tom Prince committed
          # - incorrectly detected dependencies due to pbr
          fixtures = "wheel";
          testtools = "wheel";
          traceback2 = "wheel";
    
    Tom Prince's avatar
    Tom Prince committed
          # - Incorrectly merged extras - https://github.com/DavHau/mach-nix/pull/334
          tqdm = "wheel";
    
    
          # The version of Klein we get doesn't need / can't have the patch that
          # comes from the nixpkgs derivation mach-nix picks up from 21.05.
          klein = "wheel";
    
    
          # - has an undetected poetry dependency and when trying to work around
          #   this another way, dependencies have undetected dependencies, easier
          #   to just use the wheel.
          collections-extended = "wheel";
    
          # same as collections-extended
          isort = "wheel";
    
    
          # From nixpkgs or sdist, fails with
          # cp: cannot stat 'benchmark/': No such file or directory
          # cp: cannot stat 'tests/': No such file or directory
          tomli = "wheel";
    
    
          # repo re-org or something?
          # find: ‘hypothesis-6.32.1/hypothesis-python’: No such file or directory
          hypothesis = "wheel";
    
    Tom Prince's avatar
    Tom Prince committed
        };
    
    Tom Prince's avatar
    Tom Prince committed
      in
        rec {
    
    Jean-Paul Calderone's avatar
    Jean-Paul Calderone committed
          inherit pkgs mach-nix;
    
    
    Tom Prince's avatar
    Tom Prince committed
          tahoe-lafs = mach-nix.buildPythonPackage rec {
            inherit python providers;
            name = "tahoe-lafs";
    
            # We add `.post999` here so that we don't accidentally *exactly* match
            # the upstream Tahoe-LAFS version.  This avoids the misleading
            # circumstance where the version in the Nix packaging *looks* like a
            # real upstream Tahoe-LAFS revision but we have forgotten to update it
            # so it is the *wrong* real upstream Tahoe-LAFS revision.  Hopefully
            # the `.post999` looks weird enough that if someone really cares about
            # the version in use they will notice it and go searching for what's
            # going on and discover the real version specified by `src` below.
            version = "1.17.0.post999";
    
    Tom Prince's avatar
    Tom Prince committed
            # See https://github.com/DavHau/mach-nix/issues/190
    
              # See https://github.com/DavHau/mach-nix/issues/190
    
    Tom Prince's avatar
    Tom Prince committed
              pyrsistent < 0.17
              configparser
              eliot
    
              # undetected cryptography build dependency
              # https://github.com/DavHau/mach-nix/issues/305
              setuptools_rust
              # undetected tomli build dependency
              # probably same underlying cause as cryptography issue
              flit_core
    
    Tom Prince's avatar
    Tom Prince committed
            postPatch = ''
              cat > src/allmydata/_version.py <<EOF
              # This _version.py is generated by nix.
    
    Tom Prince's avatar
    Tom Prince committed
    
    
    Tom Prince's avatar
    Tom Prince committed
              verstr = "${version}+git-${tahoe-lafs-repo.rev}"
              __version__ = verstr
              EOF
            '';
            src = tahoe-lafs-repo;
          };
          zkapauthorizer = mach-nix.buildPythonApplication rec {
            inherit python providers;
    
    Tom Prince's avatar
    Tom Prince committed
            src = lib.cleanSource ./.;
    
    Tom Prince's avatar
    Tom Prince committed
            # mach-nix does not provide a way to specify dependencies on other
            # mach-nix packages, that incorporates the requirements and overlays
            # of that package.
            # See https://github.com/DavHau/mach-nix/issues/123
            # In particular, we explicitly include the requirements of tahoe-lafs
            # here, and include it in a python package overlay.
            requirementsExtra = tahoe-lafs.requirements;
            overridesPre = [
              (
                self: super: {
                  inherit tahoe-lafs;
                }
              )
            ];
            # Record some settings here, so downstream nix files can consume them.
            meta.mach-nix = { inherit python providers; };
          };
    
          privatestorage = let
            python-env = mach-nix.mkPython {
              inherit python providers;
              packagesExtra = [ zkapauthorizer tahoe-lafs ];
            };
          in
    
    Tom Prince's avatar
    Tom Prince committed
            # Since we use this derivation in `environment.systemPackages`,
            # we create a derivation that has just the executables we use,
            # to avoid polluting the system PATH with all the executables
            # from our dependencies.
    
    Tom Prince's avatar
    Tom Prince committed
            pkgs.runCommandNoCC "privatestorage" {}
              ''
                mkdir -p $out/bin
                ln -s ${python-env}/bin/tahoe $out/bin
    
    Tom Prince's avatar
    Tom Prince committed
                # Include some tools that are useful for debugging.
                ln -s ${python-env}/bin/flogtool $out/bin
                ln -s ${python-env}/bin/eliot-prettyprint $out/bin
    
    Tom Prince's avatar
    Tom Prince committed
              '';
    
    Tom Prince's avatar
    Tom Prince committed
        }