Building Python package fortls fails

Hello everyone,

I am trying to build the Fortran language server fortls, and I have come up with this simple shell.nix:

with import <nixpkgs> {};

(let 
my_fortls = pkgs.python3Packages.buildPythonPackage rec {
  format = "pyproject";
  version = "2.12.0";
  pname = "fortls";

  src = python3.pkgs.fetchPypi {
    inherit pname version;
    sha256 = "4c2755a0ada0fcc18519458fbac4f4bd7dacfd4edc70f785e95a3c7d93f59ab1";
  };

  doCheck = false;
  buildInputs = [
    pkgs.python3Packages.json5
  ];

  meta = with lib; {
    homepage = "https://gnikit.github.io/fortls";
    description = "Improved Fortran language server";
  };
};

in pkgs.python3.buildEnv.override rec {
  extraLibs = [ my_fortls ];
}
).env

The problem is that when I nix-shell the former, it fails to build the derivation because it somehow does not get the right version of fortls, i.e. it is looking for fortls-0.0.0 instead of fortls-2.12.0. Here is the full output:

these 4 derivations will be built:
these 4 derivations will be built:
  /nix/store/9lzi2g5j1aw5yfhj4ad02p9fk38ljzz5-builder.pl.drv
  /nix/store/j3ivfgcpl3rmw4kx5r8j9pz6sixrlaxd-fortls-2.12.0.tar.gz.drv
  /nix/store/nngpzdklhasjjg4lxnwgjb5sgl4s3vjf-python3.10-fortls-2.12.0.drv
  /nix/store/9lzi2g5j1aw5yfhj4ad02p9fk38ljzz5-builder.pl.drv
  /nix/store/j3ivfgcpl3rmw4kx5r8j9pz6sixrlaxd-fortls-2.12.0.tar.gz.drv
  /nix/store/nngpzdklhasjjg4lxnwgjb5sgl4s3vjf-python3.10-fortls-2.12.0.drv
  /nix/store/5v15y26cvqnyamy1k3n5l6warqikwnsj-python3-3.10.5-env.drv
  /nix/store/5v15y26cvqnyamy1k3n5l6warqikwnsj-python3-3.10.5-env.drv
these 34 paths will be fetched (5.96 MiB download, 31.43 MiB unpacked):
  /nix/store/17wr3nh4yzr36lj4wwlnh5wip54g7ykf-libssh2-1.10.0
  /nix/store/1hb1k600qhl39z7xp3nlflwir3jqnsz4-stdenv-linux
these 34 paths will be fetched (5.96 MiB download, 31.43 MiB unpacked):
  /nix/store/17wr3nh4yzr36lj4wwlnh5wip54g7ykf-libssh2-1.10.0
  /nix/store/1hb1k600qhl39z7xp3nlflwir3jqnsz4-stdenv-linux
  /nix/store/1nk92384zahrfsyijm17p722djbr0z1l-openssl-1.1.1p-dev
  /nix/store/22hy6682q7spsryn26vgg69s7cy4l9sj-python3.10-wheel-0.37.1
  /nix/store/2gp901g3bwjqmxcpd3lpcd2rbkcafk6n-curl-7.83.1-man
  /nix/store/1nk92384zahrfsyijm17p722djbr0z1l-openssl-1.1.1p-dev
  /nix/store/22hy6682q7spsryn26vgg69s7cy4l9sj-python3.10-wheel-0.37.1
  /nix/store/2gp901g3bwjqmxcpd3lpcd2rbkcafk6n-curl-7.83.1-man
  /nix/store/2pfc5hxqa10aydi8w4bjq4r9r21fkpxm-curl-7.83.1-bin
  /nix/store/4f6fm122zp0nwjc74pnvy6s2y8z4nkwm-curl-7.83.1-dev
  /nix/store/2pfc5hxqa10aydi8w4bjq4r9r21fkpxm-curl-7.83.1-bin
  /nix/store/4f6fm122zp0nwjc74pnvy6s2y8z4nkwm-curl-7.83.1-dev
  /nix/store/6dpldw6wq7dh8zgp7x4q20xpiqlsp6aj-stdenv-linux
  /nix/store/6dpldw6wq7dh8zgp7x4q20xpiqlsp6aj-stdenv-linux
  /nix/store/7s4lad3h36fry9iblbxmqdwiv7zlky4l-mirrors-list
  /nix/store/7s4lad3h36fry9iblbxmqdwiv7zlky4l-mirrors-list
  /nix/store/9s1rhpni9qh0gmvxpj88qvgpmlnmh186-hook
  /nix/store/fiy05bq7rgq30n7isbp82q21jglbrmkm-nghttp2-1.47.0
  /nix/store/9s1rhpni9qh0gmvxpj88qvgpmlnmh186-hook
  /nix/store/fiy05bq7rgq30n7isbp82q21jglbrmkm-nghttp2-1.47.0
  /nix/store/frmgx9r8417md8mxssp735rxglb6vhpk-python-namespaces-hook.sh
  /nix/store/frmgx9r8417md8mxssp735rxglb6vhpk-python-namespaces-hook.sh
  /nix/store/gkl267i0j1ym63paw43xglq7z1x7zrvs-nghttp2-1.47.0-bin
  /nix/store/gn53c6fbgbjlhgv0jj569x9k1nd0wa0c-libkrb5-1.19.3-dev
  /nix/store/gkl267i0j1ym63paw43xglq7z1x7zrvs-nghttp2-1.47.0-bin
  /nix/store/gn53c6fbgbjlhgv0jj569x9k1nd0wa0c-libkrb5-1.19.3-dev
  /nix/store/hpspd8ninfgbh02z4zcvr1paa12f2haw-pip-install-hook
  /nix/store/hpspd8ninfgbh02z4zcvr1paa12f2haw-pip-install-hook
  /nix/store/i3xgfhd88jm6drfsk2izkmlhvmh594sk-curl-7.83.1
  /nix/store/jrqdi11ax7ifp2qpp6zh8iypbi4gfvi9-python3.10-json5-0.9.6
  /nix/store/i3xgfhd88jm6drfsk2izkmlhvmh594sk-curl-7.83.1
  /nix/store/jrqdi11ax7ifp2qpp6zh8iypbi4gfvi9-python3.10-json5-0.9.6
  /nix/store/jwpdql77krh27m6xsciffyk0w4p3rx5f-libssh2-1.10.0-dev
  /nix/store/jwpdql77krh27m6xsciffyk0w4p3rx5f-libssh2-1.10.0-dev
  /nix/store/jzc07ppqb9q8j9prdyz4w0ivrszpgy94-hook
  /nix/store/m8bgi3w5lw5q66xjrrlrpz8xng6b2ai1-openssl-1.1.1p-bin
  /nix/store/jzc07ppqb9q8j9prdyz4w0ivrszpgy94-hook
  /nix/store/m8bgi3w5lw5q66xjrrlrpz8xng6b2ai1-openssl-1.1.1p-bin
  /nix/store/msl8zwwc4wcbcw5ib9dgi0abhb5h9nir-hook
  /nix/store/msl8zwwc4wcbcw5ib9dgi0abhb5h9nir-hook
  /nix/store/mzir2f50dnc0s47c3njh3y4b7aa79n14-openssl-1.1.1p
  /nix/store/nz8zicma6v0xrw223sl5c7q8j2a27g3w-libkrb5-1.19.3
  /nix/store/mzir2f50dnc0s47c3njh3y4b7aa79n14-openssl-1.1.1p
  /nix/store/nz8zicma6v0xrw223sl5c7q8j2a27g3w-libkrb5-1.19.3
  /nix/store/pwy7xjr2xx2aa83rrsdb5gi86r1624lx-hook
  /nix/store/pwy7xjr2xx2aa83rrsdb5gi86r1624lx-hook
  /nix/store/qc7fwjxpzjz76xhia6927hzig0zh1vs7-pip-build-hook.sh
  /nix/store/rbkg6ncg5rzldrhcq2nf1ljq7xp3hyfq-python3.10-pip-22.1.2
  /nix/store/qc7fwjxpzjz76xhia6927hzig0zh1vs7-pip-build-hook.sh
  /nix/store/rbkg6ncg5rzldrhcq2nf1ljq7xp3hyfq-python3.10-pip-22.1.2
  /nix/store/rpvx7gqcgjjkxp95qcxgahrgx821c2xs-file-5.42
  /nix/store/rpvx7gqcgjjkxp95qcxgahrgx821c2xs-file-5.42
  /nix/store/s5jn5qcxggxkafgz1jdzs6vhdh7yk2jq-hook
  /nix/store/sw7jydw6dqz6y9bx8jf4fd27rqr47z6y-python-remove-tests-dir-hook
  /nix/store/s5jn5qcxggxkafgz1jdzs6vhdh7yk2jq-hook
  /nix/store/sw7jydw6dqz6y9bx8jf4fd27rqr47z6y-python-remove-tests-dir-hook
  /nix/store/vlsi90kxx1z9phqd836xykwnclwyz5ls-python-imports-check-hook.sh
  /nix/store/vxgsvch6jk3pw0lj1xh5ph33gk8fmkgs-python-catch-conflicts-hook
  /nix/store/x0hnfxb40a4n1agzs6cvkvx440n4i68x-nghttp2-1.47.0-lib
  /nix/store/yraidw77c2xk36agp7q6z30wl1myvjfg-nghttp2-1.47.0-dev
  /nix/store/zvypl4ydd46wl3k1imf2nz78in8fx8ih-python-remove-bin-bytecode-hook
  /nix/store/vlsi90kxx1z9phqd836xykwnclwyz5ls-python-imports-check-hook.sh
  /nix/store/vxgsvch6jk3pw0lj1xh5ph33gk8fmkgs-python-catch-conflicts-hook
  /nix/store/x0hnfxb40a4n1agzs6cvkvx440n4i68x-nghttp2-1.47.0-lib
  /nix/store/yraidw77c2xk36agp7q6z30wl1myvjfg-nghttp2-1.47.0-dev
  /nix/store/zvypl4ydd46wl3k1imf2nz78in8fx8ih-python-remove-bin-bytecode-hook
copying path '/nix/store/s5jn5qcxggxkafgz1jdzs6vhdh7yk2jq-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/s5jn5qcxggxkafgz1jdzs6vhdh7yk2jq-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/rpvx7gqcgjjkxp95qcxgahrgx821c2xs-file-5.42' from 'https://cache.nixos.org'...
copying path '/nix/store/rpvx7gqcgjjkxp95qcxgahrgx821c2xs-file-5.42' from 'https://cache.nixos.org'...
copying path '/nix/store/zvypl4ydd46wl3k1imf2nz78in8fx8ih-python-remove-bin-bytecode-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/zvypl4ydd46wl3k1imf2nz78in8fx8ih-python-remove-bin-bytecode-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/sw7jydw6dqz6y9bx8jf4fd27rqr47z6y-python-remove-tests-dir-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/sw7jydw6dqz6y9bx8jf4fd27rqr47z6y-python-remove-tests-dir-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/jzc07ppqb9q8j9prdyz4w0ivrszpgy94-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/jzc07ppqb9q8j9prdyz4w0ivrszpgy94-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/vxgsvch6jk3pw0lj1xh5ph33gk8fmkgs-python-catch-conflicts-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/vxgsvch6jk3pw0lj1xh5ph33gk8fmkgs-python-catch-conflicts-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/vlsi90kxx1z9phqd836xykwnclwyz5ls-python-imports-check-hook.sh' from 'https://cache.nixos.org'...
copying path '/nix/store/vlsi90kxx1z9phqd836xykwnclwyz5ls-python-imports-check-hook.sh' from 'https://cache.nixos.org'...
copying path '/nix/store/frmgx9r8417md8mxssp735rxglb6vhpk-python-namespaces-hook.sh' from 'https://cache.nixos.org'...
copying path '/nix/store/frmgx9r8417md8mxssp735rxglb6vhpk-python-namespaces-hook.sh' from 'https://cache.nixos.org'...
copying path '/nix/store/jrqdi11ax7ifp2qpp6zh8iypbi4gfvi9-python3.10-json5-0.9.6' from 'https://cache.nixos.org'...
copying path '/nix/store/jrqdi11ax7ifp2qpp6zh8iypbi4gfvi9-python3.10-json5-0.9.6' from 'https://cache.nixos.org'...
copying path '/nix/store/7s4lad3h36fry9iblbxmqdwiv7zlky4l-mirrors-list' from 'https://cache.nixos.org'...
copying path '/nix/store/7s4lad3h36fry9iblbxmqdwiv7zlky4l-mirrors-list' from 'https://cache.nixos.org'...
copying path '/nix/store/rbkg6ncg5rzldrhcq2nf1ljq7xp3hyfq-python3.10-pip-22.1.2' from 'https://cache.nixos.org'...
copying path '/nix/store/rbkg6ncg5rzldrhcq2nf1ljq7xp3hyfq-python3.10-pip-22.1.2' from 'https://cache.nixos.org'...
copying path '/nix/store/22hy6682q7spsryn26vgg69s7cy4l9sj-python3.10-wheel-0.37.1' from 'https://cache.nixos.org'...
copying path '/nix/store/22hy6682q7spsryn26vgg69s7cy4l9sj-python3.10-wheel-0.37.1' from 'https://cache.nixos.org'...
copying path '/nix/store/2gp901g3bwjqmxcpd3lpcd2rbkcafk6n-curl-7.83.1-man' from 'https://cache.nixos.org'...
copying path '/nix/store/2gp901g3bwjqmxcpd3lpcd2rbkcafk6n-curl-7.83.1-man' from 'https://cache.nixos.org'...
copying path '/nix/store/fiy05bq7rgq30n7isbp82q21jglbrmkm-nghttp2-1.47.0' from 'https://cache.nixos.org'...
copying path '/nix/store/fiy05bq7rgq30n7isbp82q21jglbrmkm-nghttp2-1.47.0' from 'https://cache.nixos.org'...
copying path '/nix/store/gkl267i0j1ym63paw43xglq7z1x7zrvs-nghttp2-1.47.0-bin' from 'https://cache.nixos.org'...
copying path '/nix/store/gkl267i0j1ym63paw43xglq7z1x7zrvs-nghttp2-1.47.0-bin' from 'https://cache.nixos.org'...
copying path '/nix/store/nz8zicma6v0xrw223sl5c7q8j2a27g3w-libkrb5-1.19.3' from 'https://cache.nixos.org'...
copying path '/nix/store/nz8zicma6v0xrw223sl5c7q8j2a27g3w-libkrb5-1.19.3' from 'https://cache.nixos.org'...
copying path '/nix/store/x0hnfxb40a4n1agzs6cvkvx440n4i68x-nghttp2-1.47.0-lib' from 'https://cache.nixos.org'...
copying path '/nix/store/x0hnfxb40a4n1agzs6cvkvx440n4i68x-nghttp2-1.47.0-lib' from 'https://cache.nixos.org'...
copying path '/nix/store/mzir2f50dnc0s47c3njh3y4b7aa79n14-openssl-1.1.1p' from 'https://cache.nixos.org'...
copying path '/nix/store/mzir2f50dnc0s47c3njh3y4b7aa79n14-openssl-1.1.1p' from 'https://cache.nixos.org'...
copying path '/nix/store/msl8zwwc4wcbcw5ib9dgi0abhb5h9nir-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/msl8zwwc4wcbcw5ib9dgi0abhb5h9nir-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/pwy7xjr2xx2aa83rrsdb5gi86r1624lx-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/pwy7xjr2xx2aa83rrsdb5gi86r1624lx-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/yraidw77c2xk36agp7q6z30wl1myvjfg-nghttp2-1.47.0-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/yraidw77c2xk36agp7q6z30wl1myvjfg-nghttp2-1.47.0-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/9s1rhpni9qh0gmvxpj88qvgpmlnmh186-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/9s1rhpni9qh0gmvxpj88qvgpmlnmh186-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/6dpldw6wq7dh8zgp7x4q20xpiqlsp6aj-stdenv-linux' from 'https://cache.nixos.org'...
copying path '/nix/store/1hb1k600qhl39z7xp3nlflwir3jqnsz4-stdenv-linux' from 'https://cache.nixos.org'...
copying path '/nix/store/6dpldw6wq7dh8zgp7x4q20xpiqlsp6aj-stdenv-linux' from 'https://cache.nixos.org'...
copying path '/nix/store/1hb1k600qhl39z7xp3nlflwir3jqnsz4-stdenv-linux' from 'https://cache.nixos.org'...
copying path '/nix/store/gn53c6fbgbjlhgv0jj569x9k1nd0wa0c-libkrb5-1.19.3-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/gn53c6fbgbjlhgv0jj569x9k1nd0wa0c-libkrb5-1.19.3-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/17wr3nh4yzr36lj4wwlnh5wip54g7ykf-libssh2-1.10.0' from 'https://cache.nixos.org'...
copying path '/nix/store/17wr3nh4yzr36lj4wwlnh5wip54g7ykf-libssh2-1.10.0' from 'https://cache.nixos.org'...
copying path '/nix/store/m8bgi3w5lw5q66xjrrlrpz8xng6b2ai1-openssl-1.1.1p-bin' from 'https://cache.nixos.org'...
copying path '/nix/store/m8bgi3w5lw5q66xjrrlrpz8xng6b2ai1-openssl-1.1.1p-bin' from 'https://cache.nixos.org'...
building '/nix/store/9lzi2g5j1aw5yfhj4ad02p9fk38ljzz5-builder.pl.drv'...
building '/nix/store/9lzi2g5j1aw5yfhj4ad02p9fk38ljzz5-builder.pl.drv'...
copying path '/nix/store/qc7fwjxpzjz76xhia6927hzig0zh1vs7-pip-build-hook.sh' from 'https://cache.nixos.org'...
copying path '/nix/store/qc7fwjxpzjz76xhia6927hzig0zh1vs7-pip-build-hook.sh' from 'https://cache.nixos.org'...
copying path '/nix/store/hpspd8ninfgbh02z4zcvr1paa12f2haw-pip-install-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/hpspd8ninfgbh02z4zcvr1paa12f2haw-pip-install-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/i3xgfhd88jm6drfsk2izkmlhvmh594sk-curl-7.83.1' from 'https://cache.nixos.org'...
copying path '/nix/store/jwpdql77krh27m6xsciffyk0w4p3rx5f-libssh2-1.10.0-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/i3xgfhd88jm6drfsk2izkmlhvmh594sk-curl-7.83.1' from 'https://cache.nixos.org'...
copying path '/nix/store/jwpdql77krh27m6xsciffyk0w4p3rx5f-libssh2-1.10.0-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/1nk92384zahrfsyijm17p722djbr0z1l-openssl-1.1.1p-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/1nk92384zahrfsyijm17p722djbr0z1l-openssl-1.1.1p-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/2pfc5hxqa10aydi8w4bjq4r9r21fkpxm-curl-7.83.1-bin' from 'https://cache.nixos.org'...
copying path '/nix/store/2pfc5hxqa10aydi8w4bjq4r9r21fkpxm-curl-7.83.1-bin' from 'https://cache.nixos.org'...
copying path '/nix/store/4f6fm122zp0nwjc74pnvy6s2y8z4nkwm-curl-7.83.1-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/4f6fm122zp0nwjc74pnvy6s2y8z4nkwm-curl-7.83.1-dev' from 'https://cache.nixos.org'...
building '/nix/store/j3ivfgcpl3rmw4kx5r8j9pz6sixrlaxd-fortls-2.12.0.tar.gz.drv'...
building '/nix/store/j3ivfgcpl3rmw4kx5r8j9pz6sixrlaxd-fortls-2.12.0.tar.gz.drv'...

trying https://files.pythonhosted.org/packages/source/f/fortls/fortls-2.12.0.tar.gz

trying https://files.pythonhosted.org/packages/source/f/fortls/fortls-2.12.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 6728k  100 6728k    0     0  8636k      0 --:--:-- --:--:-- --:--:-- 12.0M
100 6728k  100 6728k    0     0  8636k      0 --:--:-- --:--:-- --:--:-- 12.0M
building '/nix/store/nngpzdklhasjjg4lxnwgjb5sgl4s3vjf-python3.10-fortls-2.12.0.drv'...
building '/nix/store/nngpzdklhasjjg4lxnwgjb5sgl4s3vjf-python3.10-fortls-2.12.0.drv'...
Sourcing python-remove-tests-dir-hook
Sourcing python-remove-tests-dir-hook
Sourcing python-catch-conflicts-hook.sh
Sourcing python-catch-conflicts-hook.sh
Sourcing python-remove-bin-bytecode-hook.sh
Sourcing python-remove-bin-bytecode-hook.sh
Sourcing pip-build-hook
Sourcing pip-build-hook
Using pipBuildPhase
Using pipBuildPhase
Using pipShellHook
Using pipShellHook
Sourcing pip-install-hook
Sourcing pip-install-hook
Using pipInstallPhase
Using pipInstallPhase
Sourcing python-imports-check-hook.sh
Using pythonImportsCheckPhase
Sourcing python-imports-check-hook.sh
Using pythonImportsCheckPhase
Sourcing python-namespaces-hook
Sourcing python-namespaces-hook
unpacking sources
unpacking sources
unpacking source archive /nix/store/7zwws5ipanvmslnmikgksq40yrbvw19l-fortls-2.12.0.tar.gz
unpacking source archive /nix/store/7zwws5ipanvmslnmikgksq40yrbvw19l-fortls-2.12.0.tar.gz
source root is fortls-2.12.0
source root is fortls-2.12.0
setting SOURCE_DATE_EPOCH to timestamp 1657014736 of file fortls-2.12.0/setup.cfg
setting SOURCE_DATE_EPOCH to timestamp 1657014736 of file fortls-2.12.0/setup.cfg
patching sources
patching sources
configuring
configuring
no configure script, doing nothing
no configure script, doing nothing
building
building
Executing pipBuildPhase
Executing pipBuildPhase
Creating a wheel...
Creating a wheel...
WARNING: The directory '/homeless-shelter/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
WARNING: The directory '/homeless-shelter/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
Processing /build/fortls-2.12.0
Processing /build/fortls-2.12.0
  Running command Preparing metadata (pyproject.toml)
  Running command Preparing metadata (pyproject.toml)
  running dist_info
  running dist_info
  creating /build/pip-modern-metadata-giht10ta/fortls.egg-info
  creating /build/pip-modern-metadata-giht10ta/fortls.egg-info
  writing /build/pip-modern-metadata-giht10ta/fortls.egg-info/PKG-INFO
  writing /build/pip-modern-metadata-giht10ta/fortls.egg-info/PKG-INFO
  writing dependency_links to /build/pip-modern-metadata-giht10ta/fortls.egg-info/dependency_links.txt
  writing dependency_links to /build/pip-modern-metadata-giht10ta/fortls.egg-info/dependency_links.txt
  writing entry points to /build/pip-modern-metadata-giht10ta/fortls.egg-info/entry_points.txt
  writing entry points to /build/pip-modern-metadata-giht10ta/fortls.egg-info/entry_points.txt
  writing requirements to /build/pip-modern-metadata-giht10ta/fortls.egg-info/requires.txt
  writing requirements to /build/pip-modern-metadata-giht10ta/fortls.egg-info/requires.txt
  writing top-level names to /build/pip-modern-metadata-giht10ta/fortls.egg-info/top_level.txt
  writing top-level names to /build/pip-modern-metadata-giht10ta/fortls.egg-info/top_level.txt
  writing manifest file '/build/pip-modern-metadata-giht10ta/fortls.egg-info/SOURCES.txt'
  writing manifest file '/build/pip-modern-metadata-giht10ta/fortls.egg-info/SOURCES.txt'
  reading manifest file '/build/pip-modern-metadata-giht10ta/fortls.egg-info/SOURCES.txt'
  reading manifest file '/build/pip-modern-metadata-giht10ta/fortls.egg-info/SOURCES.txt'
  adding license file 'LICENSE'
  adding license file 'LICENSE'
  writing manifest file '/build/pip-modern-metadata-giht10ta/fortls.egg-info/SOURCES.txt'
  writing manifest file '/build/pip-modern-metadata-giht10ta/fortls.egg-info/SOURCES.txt'
  creating '/build/pip-modern-metadata-giht10ta/fortls.dist-info'
  creating '/build/pip-modern-metadata-giht10ta/fortls.dist-info'
  adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
  adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
  Preparing metadata (pyproject.toml) ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: fortls
Building wheels for collected packages: fortls
  Running command Building wheel for fortls (pyproject.toml)
  Running command Building wheel for fortls (pyproject.toml)
  running bdist_wheel
  running bdist_wheel
  running build
  running build
  running build_py
  running build_py
  creating build
  creating build
  creating build/lib
  creating build/lib
  creating build/lib/fortls
  creating build/lib/fortls
  copying fortls/constants.py -> build/lib/fortls
  copying fortls/constants.py -> build/lib/fortls
  copying fortls/parse_fortran.py -> build/lib/fortls
  copying fortls/parse_fortran.py -> build/lib/fortls
  copying fortls/__init__.py -> build/lib/fortls
  copying fortls/__init__.py -> build/lib/fortls
  copying fortls/objects.py -> build/lib/fortls
  copying fortls/objects.py -> build/lib/fortls
  copying fortls/intrinsics.py -> build/lib/fortls
  copying fortls/intrinsics.py -> build/lib/fortls
  copying fortls/langserver.py -> build/lib/fortls
  copying fortls/langserver.py -> build/lib/fortls
  copying fortls/version.py -> build/lib/fortls
  copying fortls/version.py -> build/lib/fortls
  copying fortls/regex_patterns.py -> build/lib/fortls
  copying fortls/regex_patterns.py -> build/lib/fortls
  copying fortls/helper_functions.py -> build/lib/fortls
  copying fortls/helper_functions.py -> build/lib/fortls
  copying fortls/_version.py -> build/lib/fortls
  copying fortls/_version.py -> build/lib/fortls
  copying fortls/json_templates.py -> build/lib/fortls
  copying fortls/json_templates.py -> build/lib/fortls
  copying fortls/ftypes.py -> build/lib/fortls
  copying fortls/ftypes.py -> build/lib/fortls
  copying fortls/interface.py -> build/lib/fortls
  copying fortls/interface.py -> build/lib/fortls
  copying fortls/jsonrpc.py -> build/lib/fortls
  copying fortls/jsonrpc.py -> build/lib/fortls
  copying fortls/statements.json -> build/lib/fortls
  copying fortls/statements.json -> build/lib/fortls
  copying fortls/keywords.json -> build/lib/fortls
  copying fortls/keywords.json -> build/lib/fortls
  copying fortls/intrinsic_funs.json -> build/lib/fortls
  copying fortls/intrinsic_funs.json -> build/lib/fortls
  copying fortls/intrinsic_mods.json -> build/lib/fortls
  copying fortls/intrinsic_mods.json -> build/lib/fortls
  installing to build/bdist.linux-x86_64/wheel
  installing to build/bdist.linux-x86_64/wheel
  running install
  running install
  running install_lib
  running install_lib
  creating build/bdist.linux-x86_64
  creating build/bdist.linux-x86_64
  creating build/bdist.linux-x86_64/wheel
  creating build/bdist.linux-x86_64/wheel
  creating build/bdist.linux-x86_64/wheel/fortls
  creating build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/constants.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/constants.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/parse_fortran.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/parse_fortran.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/__init__.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/__init__.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/statements.json -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/statements.json -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/objects.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/objects.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/intrinsics.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/intrinsics.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/langserver.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/langserver.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/version.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/version.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/keywords.json -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/keywords.json -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/regex_patterns.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/regex_patterns.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/helper_functions.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/helper_functions.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/_version.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/_version.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/intrinsic_funs.json -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/intrinsic_funs.json -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/json_templates.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/json_templates.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/intrinsic_mods.json -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/intrinsic_mods.json -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/ftypes.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/ftypes.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/interface.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/interface.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/jsonrpc.py -> build/bdist.linux-x86_64/wheel/fortls
  copying build/lib/fortls/jsonrpc.py -> build/bdist.linux-x86_64/wheel/fortls
  running install_egg_info
  running install_egg_info
  running egg_info
  running egg_info
  writing fortls.egg-info/PKG-INFO
  writing fortls.egg-info/PKG-INFO
  writing dependency_links to fortls.egg-info/dependency_links.txt
  writing dependency_links to fortls.egg-info/dependency_links.txt
  writing entry points to fortls.egg-info/entry_points.txt
  writing entry points to fortls.egg-info/entry_points.txt
  writing requirements to fortls.egg-info/requires.txt
  writing requirements to fortls.egg-info/requires.txt
  writing top-level names to fortls.egg-info/top_level.txt
  writing top-level names to fortls.egg-info/top_level.txt
  reading manifest file 'fortls.egg-info/SOURCES.txt'
  reading manifest file 'fortls.egg-info/SOURCES.txt'
  adding license file 'LICENSE'
  adding license file 'LICENSE'
  writing manifest file 'fortls.egg-info/SOURCES.txt'
  writing manifest file 'fortls.egg-info/SOURCES.txt'
  Copying fortls.egg-info to build/bdist.linux-x86_64/wheel/fortls-0.0.0-py3.10.egg-info
  Copying fortls.egg-info to build/bdist.linux-x86_64/wheel/fortls-0.0.0-py3.10.egg-info
  running install_scripts
  running install_scripts
  adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
  adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
  creating build/bdist.linux-x86_64/wheel/fortls-0.0.0.dist-info/WHEEL
  creating build/bdist.linux-x86_64/wheel/fortls-0.0.0.dist-info/WHEEL
  creating '/build/pip-wheel-klam397x/tmpt_g4jvj_/fortls-0.0.0-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
  creating '/build/pip-wheel-klam397x/tmpt_g4jvj_/fortls-0.0.0-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
  adding 'fortls/__init__.py'
  adding 'fortls/__init__.py'
  adding 'fortls/_version.py'
  adding 'fortls/_version.py'
  adding 'fortls/constants.py'
  adding 'fortls/constants.py'
  adding 'fortls/ftypes.py'
  adding 'fortls/ftypes.py'
  adding 'fortls/helper_functions.py'
  adding 'fortls/helper_functions.py'
  adding 'fortls/interface.py'
  adding 'fortls/interface.py'
  adding 'fortls/intrinsic_funs.json'
  adding 'fortls/intrinsic_funs.json'
  adding 'fortls/intrinsic_mods.json'
  adding 'fortls/intrinsic_mods.json'
  adding 'fortls/intrinsics.py'
  adding 'fortls/intrinsics.py'
  adding 'fortls/json_templates.py'
  adding 'fortls/json_templates.py'
  adding 'fortls/jsonrpc.py'
  adding 'fortls/jsonrpc.py'
  adding 'fortls/keywords.json'
  adding 'fortls/keywords.json'
  adding 'fortls/langserver.py'
  adding 'fortls/langserver.py'
  adding 'fortls/objects.py'
  adding 'fortls/objects.py'
  adding 'fortls/parse_fortran.py'
  adding 'fortls/parse_fortran.py'
  adding 'fortls/regex_patterns.py'
  adding 'fortls/regex_patterns.py'
  adding 'fortls/statements.json'
  adding 'fortls/statements.json'
  adding 'fortls/version.py'
  adding 'fortls/version.py'
  adding 'fortls-0.0.0.dist-info/LICENSE'
  adding 'fortls-0.0.0.dist-info/LICENSE'
  adding 'fortls-0.0.0.dist-info/METADATA'
  adding 'fortls-0.0.0.dist-info/METADATA'
  adding 'fortls-0.0.0.dist-info/WHEEL'
  adding 'fortls-0.0.0.dist-info/WHEEL'
  adding 'fortls-0.0.0.dist-info/entry_points.txt'
  adding 'fortls-0.0.0.dist-info/entry_points.txt'
  adding 'fortls-0.0.0.dist-info/top_level.txt'
  adding 'fortls-0.0.0.dist-info/top_level.txt'
  adding 'fortls-0.0.0.dist-info/RECORD'
  adding 'fortls-0.0.0.dist-info/RECORD'
  removing build/bdist.linux-x86_64/wheel
  removing build/bdist.linux-x86_64/wheel
  Building wheel for fortls (pyproject.toml) ... done
  Building wheel for fortls (pyproject.toml) ... done
  Created wheel for fortls: filename=fortls-0.0.0-py3-none-any.whl size=92269 sha256=4993faf07fb4327dbf469edcc03f2947b9f1d9d17301f33adaafee51e9ba098b
  Created wheel for fortls: filename=fortls-0.0.0-py3-none-any.whl size=92269 sha256=4993faf07fb4327dbf469edcc03f2947b9f1d9d17301f33adaafee51e9ba098b
  Stored in directory: /build/pip-ephem-wheel-cache-oph9rv1a/wheels/89/73/17/3c0a8a756045ed0b0b50b008febe7d3de575512b0594747d00
  Stored in directory: /build/pip-ephem-wheel-cache-oph9rv1a/wheels/89/73/17/3c0a8a756045ed0b0b50b008febe7d3de575512b0594747d00
Successfully built fortls
Successfully built fortls
Finished creating a wheel...
Finished creating a wheel...
Finished executing pipBuildPhase
Finished executing pipBuildPhase
installing
installing
Executing pipInstallPhase
Executing pipInstallPhase
/build/fortls-2.12.0/dist /build/fortls-2.12.0
/build/fortls-2.12.0/dist /build/fortls-2.12.0
Processing ./fortls-0.0.0-py3-none-any.whl
Processing ./fortls-0.0.0-py3-none-any.whl
Requirement already satisfied: json5 in /nix/store/jrqdi11ax7ifp2qpp6zh8iypbi4gfvi9-python3.10-json5-0.9.6/lib/python3.10/site-packages (from fortls==0.0.0) (0.9.6)
Requirement already satisfied: json5 in /nix/store/jrqdi11ax7ifp2qpp6zh8iypbi4gfvi9-python3.10-json5-0.9.6/lib/python3.10/site-packages (from fortls==0.0.0) (0.9.6)
ERROR: Could not find a version that satisfies the requirement packaging (from fortls) (from versions: none)
ERROR: Could not find a version that satisfies the requirement packaging (from fortls) (from versions: none)
ERROR: No matching distribution found for packaging
ERROR: No matching distribution found for packaging


error: builder for '/nix/store/nngpzdklhasjjg4lxnwgjb5sgl4s3vjf-python3.10-fortls-2.12.0.drv' failed with exit code 1;
       last 10 log lines:
       > Finished creating a wheel...
       > Finished executing pipBuildPhase
       > installing
       > Executing pipInstallPhase
       > /build/fortls-2.12.0/dist /build/fortls-2.12.0
       > Processing ./fortls-0.0.0-py3-none-any.whl
       > Requirement already satisfied: json5 in /nix/store/jrqdi11ax7ifp2qpp6zh8iypbi4gfvi9-python3.10-json5-0.9.6/lib/python3.10/site-packages (from fortls==0.0.0) (0.9.6)
       > ERROR: Could not find a version that satisfies the requirement packaging (from fortls) (from versions: none)
       > ERROR: No matching distribution found for packaging
       >
       For full logs, run 'nix log /nix/store/nngpzdklhasjjg4lxnwgjb5sgl4s3vjf-python3.10-fortls-2.12.0.drv'.
error: builder for '/nix/store/nngpzdklhasjjg4lxnwgjb5sgl4s3vjf-python3.10-fortls-2.12.0.drv' failed with exit code 1;
       last 10 log lines:
       > Finished creating a wheel...
       > Finished executing pipBuildPhase
       > installing
       > Executing pipInstallPhase
       > /build/fortls-2.12.0/dist /build/fortls-2.12.0
       > Processing ./fortls-0.0.0-py3-none-any.whl
       > Requirement already satisfied: json5 in /nix/store/jrqdi11ax7ifp2qpp6zh8iypbi4gfvi9-python3.10-json5-0.9.6/lib/python3.10/site-packages (from fortls==0.0.0) (0.9.6)
       > ERROR: Could not find a version that satisfies the requirement packaging (from fortls) (from versions: none)
       > ERROR: No matching distribution found for packaging
       >
       For full logs, run 'nix log /nix/store/nngpzdklhasjjg4lxnwgjb5sgl4s3vjf-python3.10-fortls-2.12.0.drv'.
error: 1 dependencies of derivation '/nix/store/5v15y26cvqnyamy1k3n5l6warqikwnsj-python3-3.10.5-env.drv' failed to build
error: 1 dependencies of derivation '/nix/store/5v15y26cvqnyamy1k3n5l6warqikwnsj-python3-3.10.5-env.drv' failed to build

Any ideas on how to fix this problem? Thanks in advance.

packaging is part of the setuptools python package. Also, I would recommend looking at Nixpkgs - Python packaging, and development workflow. - YouTube

Thanks a lot for your suggestion and the video. After reading a bit more carefully the source of fortls, I came up with a shell.nix that works as intended:

with import <nixpkgs> {};

(let 
my_fortls = pkgs.python3Packages.buildPythonPackage rec {
  version = "2.12.0";
  pname = "fortls";

  src = python3.pkgs.fetchPypi {
    inherit pname version;
    sha256 = "4c2755a0ada0fcc18519458fbac4f4bd7dacfd4edc70f785e95a3c7d93f59ab1";
  };

  doCheck = false;
  buildInputs = [
    pkgs.python3Packages.json5
    pkgs.python3Packages.packaging
    pkgs.python3Packages.importlib-metadata
    pkgs.python3Packages.typing-extensions
  ];
  propagatedBuildInputs = [
    pkgs.python3Packages.json5
    pkgs.python3Packages.packaging
  ];

  meta = with lib; {
    homepage = "https://gnikit.github.io/fortls";
    description = "Improved Fortran language server";
  };
};

in pkgs.python3.buildEnv.override rec {
  extraLibs = [ my_fortls ];
}
).env