Skip to content

Commit

Permalink
Merge pull request #263308 from K900/rip-poetry2nix
Browse files Browse the repository at this point in the history
treewide: drop poetry2nix
  • Loading branch information
K900 authored Oct 28, 2023
2 parents fa9ab56 + b6958ac commit 3406dd9
Show file tree
Hide file tree
Showing 60 changed files with 614 additions and 29,509 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
158 changes: 53 additions & 105 deletions pkgs/applications/networking/cluster/nixops/default.nix
Original file line number Diff line number Diff line change
@@ -1,108 +1,56 @@
{ 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";
};

}
);
}
)

# 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
html=$(mktemp -d)
sphinx-build -b html -d $doc_cache doc/ $out/share/nixops/doc
'';

};
})

(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: [
ps.nixops-aws
ps.nixops-digitalocean
ps.nixops-encrypted-links
ps.nixops-gcp
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; };
python = python3.override {
packageOverrides = self: super: {
nixops = self.callPackage ./unwrapped.nix { };
} // (plugins self);
};

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;
};

# 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;
};
});
in pkg
}));
in withPlugins (ps: [
ps.nixops-aws
ps.nixops-digitalocean
ps.nixops-encrypted-links
ps.nixops-gce
ps.nixops-hercules-ci
ps.nixops-hetzner
ps.nixops-hetznercloud
ps.nixops-libvirtd
ps.nixops-vbox
])
56 changes: 56 additions & 0 deletions pkgs/applications/networking/cluster/nixops/plugins/nixops-aws.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{ 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;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{ 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 ];
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{ 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 ];
};
}
54 changes: 54 additions & 0 deletions pkgs/applications/networking/cluster/nixops/plugins/nixops-gce.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, unstableGitUpdater
, poetry-core
, cryptography
, libcloud
, nixops
, nixos-modules-contrib
}:

buildPythonPackage {
pname = "nixops-gce";
version = "unstable-2023-05-26";
pyproject = true;

src = fetchFromGitHub {
owner = "nix-community";
repo = "nixops-gce";
rev = "d13cb794aef763338f544010ceb1816fe31d7f42";
hash = "sha256-UkYf6CoUrr8yuQoe/ik6vu+UCi3ByJd0BdkS9SLEp0Q=";
};

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

nativeBuildInputs = [
poetry-core
];

buildInputs = [
nixops
];

propagatedBuildInputs = [
cryptography
libcloud
nixos-modules-contrib
];

pythonImportsCheck = [ "nixops_gcp" ];

passthru.updateScript = unstableGitUpdater {};

meta = with lib; {
description = "NixOps Google Cloud Backend";
homepage = "https://github.com/nix-community/nixops-gce";
license = licenses.mit;
maintainers = nixops.meta.maintainers;
};
}
Loading

0 comments on commit 3406dd9

Please sign in to comment.