nixpkgs/pkgs/tools/misc/lektor/default.nix
adisbladis e0816431a2 treewide: Pass self when overriding Python
Otherwise references to the Python interpreter inside the set are wrong, as demonstrated by:
``` nix
with import <nixpkgs> { };
let
  python' = python3.override {
    packageOverrides = final: prev: { requests = prev.requests.overridePythonAttrs(old: { version = "1337";  }); };
  };
in python'.pkgs.python.pkgs.requests
```
which returns the _non_ overriden requests.

And the same with `self`:
```
with import <nixpkgs> { };
let
  python' = python3.override {
    self = python';
    packageOverrides = final: prev: { requests = prev.requests.overridePythonAttrs(old: { version = "1337";  }); };
  };
in python'.pkgs.python.pkgs.requests
```
which returns the overriden requests.

This can manifest itself as file collisions when constructing environments or as subtly incorrect dependency graphs.
2024-08-03 12:18:56 +12:00

106 lines
2.1 KiB
Nix

{ lib
, fetchFromGitHub
, fetchNpmDeps
, fetchPypi
, nodejs
, npmHooks
, python3
}:
let
python = python3.override {
self = python;
packageOverrides = self: super: {
mistune = super.mistune.overridePythonAttrs (old: rec {
version = "2.0.5";
src = fetchPypi {
inherit (old) pname;
inherit version;
hash = "sha256-AkYRPLJJLbh1xr5Wl0p8iTMzvybNkokchfYxUc7gnTQ=";
};
});
};
};
in
python.pkgs.buildPythonApplication rec {
pname = "lektor";
version = "3.4.0b12";
format = "pyproject";
src = fetchFromGitHub {
owner = "lektor";
repo = pname;
rev = "refs/tags/v${version}";
# fix for case-insensitive filesystems
postFetch = ''
rm -f $out/tests/demo-project/content/icc-profile-test/{LICENSE,license}.txt
'';
hash = "sha256-y0/fYuiIB/O5tsYKjzOPnCafOIZCn4Z5OITPMcnHd/M=";
};
npmDeps = fetchNpmDeps {
src = "${src}/${npmRoot}";
hash = "sha256-LXe5/u4nAGig8RSu6r8Qsr3p3Od8eoMxukW8Z4HkJ44=";
};
npmRoot = "frontend";
nativeBuildInputs = [
python.pkgs.hatch-vcs
python.pkgs.hatchling
nodejs
npmHooks.npmConfigHook
];
propagatedBuildInputs = with python.pkgs; [
babel
click
flask
inifile
jinja2
markupsafe
marshmallow
marshmallow-dataclass
mistune
pillow
pip
python-slugify
requests
watchfiles
werkzeug
];
nativeCheckInputs = with python.pkgs; [
pytest-click
pytest-mock
pytestCheckHook
];
postInstall = ''
cp -r lektor/translations "$out/${python.sitePackages}/lektor/"
'';
pythonImportsCheck = [
"lektor"
];
disabledTests = [
# Tests require network access
"test_path_installed_plugin_is_none"
"test_VirtualEnv_run_pip_install"
];
postCheck = ''
make test-js
'';
meta = {
description = "Static content management system";
homepage = "https://www.getlektor.com/";
changelog = "https://github.com/lektor/lektor/blob/v${version}/CHANGES.md";
license = lib.licenses.bsd3;
mainProgram = "lektor";
maintainers = [ ];
};
}