Skip to content

Commit

Permalink
Slight refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Sep 19, 2024
1 parent db6206d commit f8fd6c6
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions nix/uiMetadata.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,28 @@ rec {
language_server_names = contents.languageServerNames;
});

# This is duplicated from languages/common.nix, which we'd rather not import here
packageName = p: if lib.isString p then p else p.name;
mkKernelUiMetadata = let
# This is duplicated from languages/common.nix, which we'd rather not import here
packageName = p: if lib.isString p then p else p.name;

mkKernelPackageMetadata = kernel: p: {
name = packageName p;
meta = if lib.hasAttrByPath ["packageOptions" (packageName p)] kernel then chooseInterestingMeta (kernel.packageOptions.${packageName p}) else {};
} // (lib.optionalAttrs (lib.isAttrs p && p ? "settings") {
inherit (p) settings;
});

mkKernelUiMetadata = kernel: {
# Dry
channel = kernel.channel;
name = kernel.name;
settings = if kernel ? "settings" then kernel.settings else {};
mkKernelPackageMetadata = kernel: p: {
name = packageName p;
meta = if lib.hasAttrByPath ["packageOptions" (packageName p)] kernel then chooseInterestingMeta (kernel.packageOptions.${packageName p}) else {};
} // (lib.optionalAttrs (lib.isAttrs p && p ? "settings") {
inherit (p) settings;
});
in
kernel: {
# Dry
channel = kernel.channel;
name = kernel.name;
settings = if kernel ? "settings" then kernel.settings else {};

# Different for hydrated
packages = map (p: mkKernelPackageMetadata kernel p) kernel.args.packages;
# Different for hydrated
packages = map (p: mkKernelPackageMetadata kernel p) kernel.args.packages;

# Hydrated
modes = kernel.modes;
meta = chooseInterestingMeta kernel;
};
# Hydrated
modes = kernel.modes;
meta = chooseInterestingMeta kernel;
};
}

0 comments on commit f8fd6c6

Please sign in to comment.