[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 builtins;
with lib; with lib;
let let
@ -101,27 +101,17 @@ in
}); });
}) })
(final: prev: { (final: prev: let
jetbrains = prev.jetbrains // { pycharm-common = pkg:
pycharm-professional-fhs = (
let let
myIsDerivation = x: myIsDerivation = x:
let let
tryX = tryEval x; r = !(myLib.derivations.isBroken x);
in 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); interpreters = pkgs: filter (x: myIsDerivation x) (attrValues pkgs.pythonInterpreters);
unwrapped = final.jetbrains.pycharm-professional;
in prev.buildFHSUserEnv rec { in prev.buildFHSUserEnv rec {
name = "pycharm-professional"; name = pkg.name;
targetPkgs = pkgs: (with pkgs; targetPkgs = pkgs: (with pkgs;
[ [
glibc glibc
@ -129,19 +119,22 @@ in
python3Full python3Full
jetbrains.pycharm-professional pkg
] ]
++ trace "Using the following interpreters: ${toString (pkgNames (interpreters pkgs))}" (interpreters pkgs) ++ trace "Using the following interpreters: ${toString (pkgNames (interpreters pkgs))}" (interpreters pkgs)
); );
# symlink shared assets, including icons and desktop entries # symlink shared assets, including icons and desktop entries
extraInstallCommands = '' 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 clion-fhs = let
compilers = pkgs: with pkgs; with llvmPackages_17; [ compilers = pkgs: with pkgs; with llvmPackages_17; [