Skip to content

Commit

Permalink
More on UI metadata noci
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Jan 31, 2024
1 parent 2249a03 commit ab6b696
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
44 changes: 24 additions & 20 deletions codedown/mkCodeDownEnvironment.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,36 @@ let
};
})) kernels;

shellToReplInfo = shell: {
name = shell.contents.name;
display_name = shell.contents.displayName;
attr = shell.contents.attr;
args = ["${shell.contents}/lib/codedown/shell"];
icon = shell.contents.icon;
};

shells = filter (x: lib.hasPrefix "shells." x.attr) otherPackages;

exporters = filter (x: lib.hasPrefix "exporters." x.attr) otherPackages;
exporterInfos = concatMap (exporter: exporter.contents.meta.exporterInfos) exporters;

repls =
repls = let
shellToReplInfo = shell: {
name = shell.contents.name;
display_name = shell.contents.displayName;
attr = shell.contents.attr;
args = ["${shell.contents}/lib/codedown/shell"];
icon = shell.contents.icon;
};
in
map shellToReplInfo shells
++ concatMap (kernel: lib.mapAttrsToList (name: value: value // { inherit name; }) (if kernel.passthru ? "repls" then kernel.passthru.repls else {})) builtKernels
;

chooseInterestingMeta = lib.filterAttrs (n: v:
n == "description"
|| n == "homepage"
|| n == "changelog"
|| (n == "available" && !v)
|| (n == "broken" && v)
|| (n == "unfree" && v)
|| (n == "unsupported" && v)
|| (n == "insecure" && v)
# || (n == "license.spdxId") # TODO
);

mkChannelUiMetadata = name: channel: {
foo = "bar";
};
Expand All @@ -70,25 +82,17 @@ let
};

mkOtherPackageUiMetadata = package: {
package = package;
channel = package.channel;
attr = package.attr;
meta = if package.contents ? "meta" then chooseInterestingMeta package.contents.meta else {};
};

icons = let
uniquePaths = map (v: languagesCommon.safeEval (lib.attrByPath ["meta" "icon"] "" v)) builtKernels;
in
linkFarm "all-environment-icons" (map (path: {
name = builtins.hashString "md5" (toString path);
path = path;
}) uniquePaths);

ui_metadata = {
channels = lib.mapAttrsToList mkChannelUiMetadata channels;

kernels = map mkKernelUiMetadata builtKernels;

other_packages = map mkOtherPackageUiMetadata otherPackages;

inherit icons;
};

ui_metadata_yaml = writeText "ui-metadata.yaml" (lib.generators.toYAML {} ui_metadata);
Expand Down
7 changes: 6 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@
--set PATH ${lib.makeBinPath packages}
'';

sample_environments = import ./sample_environments.nix { inherit codedown; };
sample_environments = import ./sample_environments.nix {
inherit codedown pkgsStable;
channels = {
# nixpkgs = pkgsStable;
};
};
sample_environments_farm = pkgsStable.linkFarm "sample_environments_farm" (
pkgsStable.lib.mapAttrsToList (name: path: { inherit name path; })
sample_environments
Expand Down
3 changes: 2 additions & 1 deletion sample_environments/mega.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ codedown
, pkgsStable
, channels ? {}
, ...
}:
Expand Down Expand Up @@ -251,6 +252,6 @@ codedown.mkCodeDownEnvironment {
{ channel = "codedown"; attr = "exporters.nbconvert-small"; contents = codedown.exporters.nbconvert-small; }
{ channel = "codedown"; attr = "exporters.nbconvert-large"; contents = codedown.exporters.nbconvert-large; }

# { channel = "nixpkgs"; attr = "htop"; contents = nixpkgs.htop; }
{ channel = "nixpkgs"; attr = "htop"; contents = pkgsStable.htop; }
];
}
5 changes: 4 additions & 1 deletion sample_environments/python3.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ codedown
, channels ? {}
, pkgsStable
, ...
}:

Expand Down Expand Up @@ -27,5 +28,7 @@ codedown.mkCodeDownEnvironment {
})
];

otherPackages = [];
otherPackages = [
{ channel = "nixpkgs"; attr = "htop"; contents = pkgsStable.htop; }
];
}

0 comments on commit ab6b696

Please sign in to comment.