Skip to content

Commit

Permalink
Add extraBinDirs setting
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Dec 22, 2024
1 parent 8f4caf1 commit 370fce7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ with lib;
type = types.attrsOf types.package;
default = {};
};

extraBinDirs = mkOption {
type = types.attrsOf (types.listOf types.package);
default = {};
};
};

config = {
Expand Down
12 changes: 12 additions & 0 deletions nix/makeEnvironment.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, lib
, fetchgit
, fetchFromGitHub
, runCommand
, symlinkJoin
, system
, writeTextDir
Expand Down Expand Up @@ -65,6 +66,16 @@ let
meta = chooseMeta pkg;
};

linkBinaries = newBin: inputs: runCommand "${name}-${newBin}" {} ''
mkdir -p "$out/${newBin}"
for input in ${builtins.toString inputs}; do
find "$input/bin" -type f -executable | while read -r executable; do
ln -s "$executable" "$out/${newBin}/$(basename "$executable")"
done
done
'';

in

symlinkJoin {
Expand All @@ -74,6 +85,7 @@ symlinkJoin {
++ attrValues evaluated.config.builtLanguageServers
++ lib.optionals (builtins.length exporters > 0) [(writeTextDir "lib/codedown/exporters.yaml" (lib.generators.toYAML {} exporters))]
++ attrValues evaluated.config.packages
++ lib.mapAttrsToList linkBinaries evaluated.config.extraBinDirs
;

passthru = rec {
Expand Down
7 changes: 7 additions & 0 deletions sample_environments/bash.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{ codedown
, pkgsStable
, ...
}:

codedown.makeEnvironment {
kernels.bash.enable = true;

extraBinDirs = {
"runner_bin" = [
pkgsStable.tmux
];
};
}

0 comments on commit 370fce7

Please sign in to comment.