nixpkgs/pkgs/by-name/gd/gdtoolkit_4/package.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

75 lines
1.7 KiB
Nix

{ lib
, python3
, fetchFromGitHub
}:
let
python = python3.override {
self = python;
packageOverrides = self: super: {
lark = super.lark.overridePythonAttrs (old: rec {
# gdtoolkit needs exactly this lark version
version = "1.1.9";
src = fetchFromGitHub {
owner = "lark-parser";
repo = "lark";
rev = version;
hash = "sha256-vDu+VPAXONY8J+A6oS7EiMeOMgzGms0nWpE+DKI1MVU=";
fetchSubmodules = true;
};
patches = [ ];
});
};
};
in
python.pkgs.buildPythonApplication rec {
pname = "gdtoolkit";
version = "4.2.2";
src = fetchFromGitHub {
owner = "Scony";
repo = "godot-gdscript-toolkit";
rev = version;
hash = "sha256-SvEKKuDnfxV+5AArg5ssrQzgIwRITdek4KYEs3d0n4Y=";
};
disabled = python.pythonOlder "3.7";
propagatedBuildInputs = with python.pkgs; [
docopt
lark
pyyaml
setuptools
];
doCheck = true;
nativeCheckInputs = with python.pkgs; [
pytestCheckHook
hypothesis
];
preCheck = ''
# The tests want to run the installed executables
export PATH=$out/bin:$PATH
# gdtoolkit tries to write cache variables to $HOME/.cache
export HOME=$TMP
'';
# The tests are not working on NixOS
disabledTestPaths = [
"tests/generated/test_expression_parsing.py"
"tests/gdradon/test_executable.py"
];
pythonImportsCheck = [ "gdtoolkit" "gdtoolkit.formatter" "gdtoolkit.linter" "gdtoolkit.parser" ];
meta = with lib; {
description = "Independent set of tools for working with Godot's GDScript - parser, linter and formatter";
homepage = "https://github.com/Scony/godot-gdscript-toolkit";
license = licenses.mit;
maintainers = with maintainers; [ squarepear ];
};
}