depot/nix/pkgs/authentik/pythonapp/default.nix

75 lines
2.8 KiB
Nix
Raw Normal View History

{ depot, src, ... }:
2022-05-12 22:55:10 +00:00
let
pkgs = depot.third_party.nixpkgsOld;
inherit (pkgs) poetry2nix;
2022-08-14 20:01:26 +00:00
pyproject = pkgs.runCommand "authentik-pyproject" { src = "${src}/pyproject.toml"; } ''
sed 's/extras = \["standard"\],//' $src > $out
'';
poetrylock = pkgs.runCommand "authentik-poetrylock" { src = "${src}/poetry.lock"; } ''
sed -e 's/, markers = "extra == \\\"standard\\\""//' \
-e 's/and extra == \\\"standard\\\"//' \
$src > $out
'';
fixedSrc = pkgs.runCommand "authentik-src" { inherit src; } ''
cp -R $src $out
chmod -R u+w $out
cp ${pyproject} $out/pyproject.toml
cp ${poetrylock} $out/poetry.lock
'';
app = poetry2nix.mkPoetryApplication rec {
2022-08-14 20:01:26 +00:00
projectDir = fixedSrc;
2022-05-12 22:55:10 +00:00
python = pkgs.python310;
overrides = poetry2nix.overrides.withDefaults (self: super: {
2022-05-12 22:55:10 +00:00
click-didyoumean = super.click-didyoumean.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ self.poetry ];
});
xmlsec = super.xmlsec.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ self.pkgconfig ];
2022-05-12 22:55:10 +00:00
buildInputs = (old.buildInputs or []) ++ [ pkgs.xmlsec pkgs.libxslt pkgs.libxml2 pkgs.libtool ];
});
mistune = super.mistune.overridePythonAttrs (old: rec {
version = "0.8.4";
src = self.fetchPypi {
inherit (old) pname;
inherit version;
sha256 = "59a3429db53c50b5c6bcc8a07f8848cb00d7dc8bdb431a4ab41920d201d4756e";
};
});
2022-05-20 21:59:00 +00:00
hatch-vcs = (super.hatch-vcs or (self.buildPythonPackage rec {
pname = "hatch-vcs";
version = "0.2.0";
format = "pyproject";
nativeBuildInputs = with self; [ hatchling ];
propagatedBuildInputs = with self; [ hatchling setuptools-scm ];
checkInputs = with self; [ pkgs.git pytestCheckHook ];
src = self.fetchPypi {
pname = "hatch_vcs";
inherit version;
sha256 = "1zxb12lrrl1n7ijcxl8mvv94lnhn6b52c1jx6jq9pv2fncrxf4wr";
};
}));
2022-08-14 20:01:26 +00:00
watchfiles = self.callPackage "${pkgs.path}/pkgs/development/python-modules/watchfiles/default.nix" {};
uvicorn = (self.callPackage "${pkgs.path}/pkgs/development/python-modules/uvicorn/default.nix" {}).overridePythonAttrs (old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ old.passthru.optional-dependencies.standard;
});
inherit (pkgs.python310.pkgs) ua-parser;
2022-05-12 22:55:10 +00:00
});
buildInputs = [ pkgs.bash ];
postInstall = ''
mkdir -p $out/share/authentik
touch $out/share/authentik/__init__.py
cp -r ${src}/xml $out/share/authentik/xml
cp -r ${src}/lifecycle $out/share/authentik/lifecycle
wrapProgram $out/bin/ak \
--prefix PYTHONPATH ':' "$out/share/authentik"
'';
};
in
app.dependencyEnv