Skip to content

Commit

Permalink
Prefer writeShellApplication for wrapper ruby
Browse files Browse the repository at this point in the history
bundlerEnv/bundlerApp maybe better way?
  • Loading branch information
kachick committed Mar 12, 2024
1 parent 8b5bd6b commit 04c7d94
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,38 @@
'';
runtimeDependencies = [
pkgs.ruby_3_3
pkgs.libyaml
];
};

packages.ruby = pkgs.writeShellScriptBin "ruby-with-ulid" ''
set -euo pipefail
${pkgs.ruby_3_3}/bin/ruby -r"${packages.ruby-ulid}/lib/ulid" "$@"
'';

packages.irb = pkgs.writeShellScriptBin "irb-with-ulid" ''
set -euo pipefail
${pkgs.ruby_3_3}/bin/irb -r"${packages.ruby-ulid}/lib/ulid" "$@"
'';

packages.default = packages.ruby-ulid;

# `nix run`
apps = {
ruby = {
type = "app";
program = "${packages.ruby}/bin/ruby-with-ulid";
program = with pkgs; lib.getExe (writeShellApplication
{
name = "ruby-with-ulid";
runtimeInputs = [
ruby_3_3
];
text = ''
ruby -r"${packages.ruby-ulid}/lib/ulid" "$@"
'';
});
};

irb = {
type = "app";
program = "${packages.irb}/bin/irb-with-ulid";
program = with pkgs; lib.getExe (writeShellApplication
{
name = "irb-with-ulid";
runtimeInputs = [
ruby_3_3
libyaml
];
text = ''
irb -r"${packages.ruby-ulid}/lib/ulid" "$@"
'';
});
};
};
}
Expand Down

0 comments on commit 04c7d94

Please sign in to comment.