Skip to content

Commit

Permalink
Add labeledPackages option for computing UI metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Sep 19, 2024
1 parent f3c2795 commit db6206d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
23 changes: 23 additions & 0 deletions modules/base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@ with lib;
The set of packages that are symlinked into the environment.
'';
};

labeledPackages = lib.mkOption {
type = lib.types.listOf (types.submodule {
options = {
channel = mkOption rec {
type = types.str;
description = "Channel name";
};
attr = mkOption rec {
type = types.str;
description = "Attr name";
};
contents = mkOption rec {
type = types.package;
description = "Package";
};
};
});
default = [];
description = ''
Packages that are labeled with channels and attributes. Used to generate UI metadata.
'';
};
};

config = {
Expand Down
11 changes: 6 additions & 5 deletions nix/makeEnvironment.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ symlinkJoin {
++ lib.optionals (builtins.length repls > 0) [(writeTextDir "lib/codedown/repls.yaml" (lib.generators.toYAML {} repls))]
++ lib.optionals (builtins.length exporters > 0) [(writeTextDir "lib/codedown/exporters.yaml" (lib.generators.toYAML {} exporters))]
++ evaluated.config.packages
++ map (x: x.contents) evaluated.config.labeledPackages
;

passthru = rec {
Expand All @@ -71,11 +72,11 @@ symlinkJoin {

kernels = map uiMetadata.mkKernelUiMetadata (attrValues builtKernels);

other_packages = map (package: {
channel = "foo";
attr = "bar";
meta = if package ? "meta" then uiMetadata.chooseInterestingMeta package else {};
}) evaluated.config.packages;
other_packages = map (p: {
channel = p.channel;
attr = p.attr;
meta = if p.contents ? "meta" then uiMetadata.chooseInterestingMeta p.contents else {};
}) evaluated.config.labeledPackages;
};

ui_metadata_yaml = writeText "ui-metadata.yaml" (lib.generators.toYAML {} ui_metadata);
Expand Down
8 changes: 3 additions & 5 deletions sample_environments/mega.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ codedown.makeEnvironment {
exporters.nbconvert-exporters.enable = true;
exporters.nbconvert-exporters.texliveScheme = "scheme-full";

# otherPackages = [
# { channel = "codedown"; attr = "spellchecker"; contents = codedown.spellchecker; }

# { channel = "nixpkgs"; attr = "htop"; contents = pkgsStable.htop; }
# ];
labeledPackages = [
{ channel = "nixpkgs"; attr = "htop"; contents = channels.nixpkgs.htop; }
];
}

0 comments on commit db6206d

Please sign in to comment.