85 lines
2.8 KiB
Nix
85 lines
2.8 KiB
Nix
# [[file:arcology-poetry.org::*=poetry2nix= will package the Arcology application up based on Poetry =TOML= in =default.nix=][=poetry2nix= will package the Arcology application up based on Poetry =TOML= in =default.nix=:1]]
|
|
{ pkgs ? import <nixpkgs> {},
|
|
poetry2nix ? import ((import <arroyo/versions.nix> {}).poetry2nix {}) {},
|
|
stdenv ? pkgs.stdenv,
|
|
python ? pkgs.python3 }:
|
|
|
|
let
|
|
mkPoetryApplication' =
|
|
{ projectDir,
|
|
editablePackageSources,
|
|
overrides ? poetry2nix.defaultPoetryOverrides,
|
|
... }@args:
|
|
let
|
|
# pass all args which are not specific to mkPoetryEnv
|
|
app = poetry2nix.mkPoetryApplication (builtins.removeAttrs args [ "editablePackageSources" ]);
|
|
|
|
# pass args specific to mkPoetryEnv and all remaining arguments to mkDerivation
|
|
editableEnv = stdenv.mkDerivation (
|
|
{
|
|
name = "editable-env";
|
|
src = poetry2nix.mkPoetryEnv {
|
|
inherit projectDir editablePackageSources overrides;
|
|
};
|
|
|
|
# copy all the output of mkPoetryEnv so that patching and wrapping of outputs works
|
|
installPhase = ''
|
|
mkdir -p $out
|
|
cp -a * $out
|
|
'';
|
|
} // builtins.removeAttrs args [ "projectDir" "editablePackageSources" "overrides" ]
|
|
);
|
|
in
|
|
app.overrideAttrs (super: {
|
|
passthru = super.passthru // { inherit editableEnv; };
|
|
})
|
|
;
|
|
in
|
|
mkPoetryApplication' {
|
|
inherit python;
|
|
projectDir = ./.;
|
|
propagatedBuildInputs = [
|
|
pkgs.coreutils
|
|
pkgs.pandoc
|
|
];
|
|
overrides = [
|
|
(poetry2nix.defaultPoetryOverrides.overrideOverlay (
|
|
self: super: {
|
|
sqlmodel = super.sqlmodel.overridePythonAttrs (
|
|
old: {
|
|
buildInputs = (old.buildInputs or [ ]) ++ [self.poetry-core];
|
|
patchPhase = (old.patchPhase or "") + ''
|
|
# fix pyproject.toml version?
|
|
substituteInPlace pyproject.toml --replace 'version = "0"' 'version = "${old.version}"'
|
|
'';
|
|
}
|
|
);
|
|
traitlets = super.traitlets.overridePythonAttrs (
|
|
old: {
|
|
buildInputs = (old.buildInputs or [ ]) ++ [self.hatchling];
|
|
}
|
|
);
|
|
pypandoc = super.pypandoc.overridePythonAttrs (
|
|
old: {
|
|
buildInputs = (old.buildInputs or [ ]) ++ [self.poetry-core];
|
|
}
|
|
);
|
|
asyncinotify = super.asyncinotify.overridePythonAttrs (
|
|
old: {
|
|
buildInputs = (old.buildInputs or [ ]) ++ [self.setuptools];
|
|
}
|
|
);
|
|
sqlalchemy2-stubs = super.sqlalchemy2-stubs.overridePythonAttrs (
|
|
old: {
|
|
buildInputs = (old.buildInputs or [ ]) ++ [self.setuptools];
|
|
}
|
|
);
|
|
}
|
|
))
|
|
];
|
|
editablePackageSources = {
|
|
arcology = ./.;
|
|
};
|
|
}
|
|
# =poetry2nix= will package the Arcology application up based on Poetry =TOML= in =default.nix=:1 ends here
|