[Overlays/Developer] refactor pycharm FHS envs

Allows having both pycharm-community-fhs and pycharm-professional-fhs
with minimal line count.
This commit is contained in:
Antoine Viallon 2024-05-02 16:27:21 +02:00
parent 8f4c49f955
commit ffe1c7a376
Signed by: aviallon
GPG key ID: 186FC35EDEB25716

View file

@ -1,4 +1,4 @@
{config, pkgs, options, lib, ...}:
{config, pkgs, options, lib, myLib, ...}:
with builtins;
with lib;
let
@ -101,27 +101,17 @@ in
});
})
(final: prev: {
jetbrains = prev.jetbrains // {
pycharm-professional-fhs = (
(final: prev: let
pycharm-common = pkg:
let
myIsDerivation = x:
let
tryX = tryEval x;
r = !(myLib.derivations.isBroken x);
in
if
tryX.success && (isDerivation tryX.value)
then
if !(tryX.value.meta.insecure || tryX.value.meta.broken)
then true
else trace "Excluding interpreter ${getName x} from pycharm FHS" false
else
false
;
;
interpreters = pkgs: filter (x: myIsDerivation x) (attrValues pkgs.pythonInterpreters);
unwrapped = final.jetbrains.pycharm-professional;
in prev.buildFHSUserEnv rec {
name = "pycharm-professional";
name = pkg.name;
targetPkgs = pkgs: (with pkgs;
[
glibc
@ -129,19 +119,22 @@ in
python3Full
jetbrains.pycharm-professional
pkg
]
++ trace "Using the following interpreters: ${toString (pkgNames (interpreters pkgs))}" (interpreters pkgs)
);
# symlink shared assets, including icons and desktop entries
extraInstallCommands = ''
ln -s "${unwrapped}/share" "$out/"
ln -s "${pkg}/share" "$out/"
'';
runScript = "${unwrapped}/bin/pycharm-professional";
});
runScript = "/usr/bin/${name}";
};
in {
jetbrains = prev.jetbrains // {
pycharm-community-fhs = pycharm-common prev.jetbrains.pycharm-community;
pycharm-professional-fhs = pycharm-common prev.jetbrains.pycharm-professional;
clion-fhs = let
compilers = pkgs: with pkgs; with llvmPackages_17; [