Unverified Commit 3406dd96 authored by K900's avatar K900 Committed by GitHub
Browse files

Merge pull request #263308 from K900/rip-poetry2nix

treewide: drop poetry2nix
parents fa9ab563 b6958acd
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -116,7 +116,6 @@
/maintainers/scripts/update-python-libraries	              @FRidh
/pkgs/development/interpreters/python                       @FRidh
/doc/languages-frameworks/python.section.md                 @FRidh @mweinelt
/pkgs/development/tools/poetry2nix                          @adisbladis
/pkgs/development/interpreters/python/hooks                 @FRidh @jonringer

# Haskell
+53 −105
Original line number Diff line number Diff line
{ nixosTests
, pkgs
, poetry2nix
, lib
, overrides ? (self: super: {})
}:
{ python3 }:

let

  interpreter = (
    poetry2nix.mkPoetryPackages {
      projectDir = ./.;
      python = pkgs.python310;
      overrides = [
        poetry2nix.defaultPoetryOverrides
        (import ./poetry-git-overlay.nix { inherit pkgs; })
        (
          self: super: {

            nixops = super.nixops.overridePythonAttrs (
              old: {
                version = "${old.version}-pre-${lib.substring 0 7 super.nixops.src.rev or "dirty"}";

                postPatch = ''
                  substituteInPlace nixops/args.py --subst-var version
                '';

                meta = old.meta // {
                  homepage = "https://github.com/NixOS/nixops";
                  description = "NixOS cloud provisioning and deployment tool";
                  maintainers = with lib.maintainers; [ adisbladis aminechikhaoui roberth ];
                  platforms = lib.platforms.unix;
                  license = lib.licenses.lgpl3;
                  mainProgram = "nixops";
  python = python3.override {
    packageOverrides = self: super: {
      nixops = self.callPackage ./unwrapped.nix { };
    } // (plugins self);
  };

              }
            );
          }
        )

        # User provided overrides
        overrides

        # Make nixops pluginable
        (self: super: let
          # Create a fake sphinx directory that doesn't pull the entire setup hook and incorrect python machinery
          sphinx = pkgs.runCommand "sphinx" {} ''
            mkdir -p $out/bin
            for f in ${pkgs.python3.pkgs.sphinx}/bin/*; do
              ln -s $f $out/bin/$(basename $f)
            done
          '';

        in {
          nixops = super.__toPluginAble {
            drv = super.nixops;
            finalDrv = self.nixops;

            nativeBuildInputs = [ sphinx ];

            postInstall = ''
              doc_cache=$(mktemp -d)
              sphinx-build -b man -d $doc_cache doc/ $out/share/man/man1
  plugins = ps: with ps; rec {
    nixops-aws = callPackage ./plugins/nixops-aws.nix { };
    nixops-digitalocean = callPackage ./plugins/nixops-digitalocean.nix { };
    nixops-encrypted-links = callPackage ./plugins/nixops-encrypted-links.nix { };
    nixops-gce = callPackage ./plugins/nixops-gce.nix { };
    nixops-hercules-ci = callPackage ./plugins/nixops-hercules-ci.nix { };
    nixops-hetzner = callPackage ./plugins/nixops-hetzner.nix { };
    nixops-hetznercloud = callPackage ./plugins/nixops-hetznercloud.nix { };
    nixops-libvirtd = callPackage ./plugins/nixops-libvirtd.nix { };
    nixops-vbox = callPackage ./plugins/nixops-vbox.nix { };
    nixos-modules-contrib = callPackage ./plugins/nixos-modules-contrib.nix { };

    # aliases for backwards compatibility
    nixops-gcp = nixops-gce;
    nixops-virtd = nixops-libvirtd;
    nixopsvbox = nixops-vbox;
  };

              html=$(mktemp -d)
              sphinx-build -b html -d $doc_cache doc/ $out/share/nixops/doc
  # selector is a function mapping pythonPackages to a list of plugins
  # e.g. nixops_unstable.withPlugins (ps: with ps; [ nixops-aws ])
  withPlugins = selector: let
    selected = selector (plugins python.pkgs);
  in python.pkgs.toPythonApplication (python.pkgs.nixops.overridePythonAttrs (old: {
    propagatedBuildInputs = old.propagatedBuildInputs ++ selected;

    # Propagating dependencies leaks them through $PYTHONPATH which causes issues
    # when used in nix-shell.
    postFixup = ''
      rm $out/nix-support/propagated-build-inputs
    '';

    passthru = old.passthru // {
      plugins = plugins python.pkgs;
      inherit withPlugins python;
    };
        })

        (self: super: {
          cryptography = super.cryptography.overridePythonAttrs (old: {
            meta = old.meta // {
              knownVulnerabilities = old.meta.knownVulnerabilities or [ ]
                ++ lib.optionals (lib.versionOlder old.version "41.0.0") [
                  "CVE-2023-2650"
                  "CVE-2023-2975"
                  "CVE-2023-3446"
                  "CVE-2023-3817"
                  "CVE-2023-38325"
                ];
            };
          });
        })

      ];
    }
  ).python;

  pkg = (interpreter.pkgs.nixops.withPlugins(ps: [
  }));
in withPlugins (ps: [
  ps.nixops-aws
  ps.nixops-digitalocean
  ps.nixops-encrypted-links
    ps.nixops-gcp
  ps.nixops-gce
  ps.nixops-hercules-ci
  ps.nixops-hetzner
    ps.nixopsvbox
    ps.nixops-virtd
  ps.nixops-hetznercloud
  ])).overrideAttrs (finalAttrs: prevAttrs: {
    passthru = prevAttrs.passthru or {} // {
      tests = prevAttrs.passthru.tests or {} //
        nixosTests.nixops.unstable.passthru.override { nixopsPkg = pkg; };
    };
  });
in pkg
  ps.nixops-libvirtd
  ps.nixops-vbox
])
+56 −0
Original line number Diff line number Diff line
{ lib
, buildPythonPackage
, fetchFromGitHub
, unstableGitUpdater
, poetry-core
, boto
, boto3
, nixops
, nixos-modules-contrib
, typing-extensions
}:

buildPythonPackage {
  pname = "nixops-aws";
  version = "unstable-2023-08-09";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "NixOS";
    repo = "nixops-aws";
    rev = "8802d1cda9004ec1362815292c2a8ab95e6d64e8";
    hash = "sha256-i0KjFrwpDHRch9jorccdVwnjAQiORClDUqm2R2xvwuU=";
  };

  postPatch = ''
    substituteInPlace pyproject.toml \
    --replace poetry.masonry.api poetry.core.masonry.api \
    --replace "poetry>=" "poetry-core>="
  '';

  nativeBuildInputs = [
    poetry-core
  ];

  buildInputs = [
    nixops
  ];

  propagatedBuildInputs = [
    boto
    boto3
    nixos-modules-contrib
    typing-extensions
  ];

  pythonImportsCheck = [ "nixops_aws" ];

  passthru.updateScript = unstableGitUpdater {};

  meta = with lib; {
    description = "AWS plugin for NixOps";
    homepage = "https://github.com/NixOS/nixops-aws";
    license = licenses.lgpl3Only;
    maintainers = nixops.meta.maintainers;
  };
}
+50 −0
Original line number Diff line number Diff line
{ lib
, buildPythonPackage
, fetchFromGitHub
, unstableGitUpdater
, poetry-core
, nixops
, digital-ocean
}:

buildPythonPackage {
  pname = "nixops-digitalocean";
  version = "unstable-2022-08-14";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "nix-community";
    repo = "nixops-digitalocean";
    rev = "e977b7f11e264a6a2bff2dcbc7b94c6a97b92fff";
    hash = "sha256-aJtShvdqjAiCK5oZL0GR5cleDb4s1pJkO6UPKGd4Dgg=";
  };

  postPatch = ''
    substituteInPlace pyproject.toml \
    --replace poetry.masonry.api poetry.core.masonry.api \
    --replace "poetry>=" "poetry-core>="
  '';

  nativeBuildInputs = [
    poetry-core
  ];

  buildInputs = [
    nixops
  ];

  propagatedBuildInputs = [
    digital-ocean
  ];

  pythonImportsCheck = [ "nixops_digitalocean" ];

  passthru.updateScript = unstableGitUpdater {};

  meta = with lib; {
    description = "NixOps Digitalocean plugin";
    homepage = "https://github.com/nix-community/nixops-digitalocean";
    license = licenses.lgpl3Only;
    maintainers = with maintainers; [ kiwi ];
  };
}
+45 −0
Original line number Diff line number Diff line
{ lib
, buildPythonPackage
, fetchFromGitHub
, unstableGitUpdater
, poetry-core
, nixops
}:

buildPythonPackage {
  pname = "nixops-encrypted-links";
  version = "unstable-2021-02-16";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "nix-community";
    repo = "nixops-encrypted-links";
    rev = "e2f196fce15fcfb00d18c055e1ac53aec33b8fb1";
    hash = "sha256-1TTbARyCfrLxF6SVNkmIKNNcLS9FVW22d9w0VRrH1os=";
  };

  postPatch = ''
    substituteInPlace pyproject.toml \
    --replace poetry.masonry.api poetry.core.masonry.api \
    --replace "poetry>=" "poetry-core>="
  '';

  nativeBuildInputs = [
    poetry-core
  ];

  buildInputs = [
    nixops
  ];

  pythonImportsCheck = [ "nixops_encrypted_links" ];

  passthru.updateScript = unstableGitUpdater {};

  meta = with lib; {
    description = "EncryptedLinksTo from Nixops 1 module port";
    homepage = "https://github.com/nix-community/nixops-encrypted-links";
    license = licenses.mit;
    maintainers = with maintainers; [ adisbladis ];
  };
}
Loading