tweag / nix-hour

Questions for the weekly Nix Hour
MIT License
78 stars 3 forks source link

Nix Hour How to: Package multiple Shell scripts and handle "command not found" #24

Closed MatXron closed 1 year ago

MatXron commented 1 year ago

Dear Tweag team and Silvan @infinisil

Could you please discuss on Nix Hour how to package a single Bash script (using writeScript) or multiple (probably using mkDerivation) into a single package?

I would be specifically interested to know how to package multiple scripts into a single package and how to deal with commands in those Bash scripts that work fine on other Linux distros but that return command not found on Nix.

Let's say the script runs fdisk so I assume I need to specify pkgs.fdisk as buildInput and then somehow change fdisk inside the Bash script to /nix/store/rfil5rhr8dw5rdqk4cyndcm2jc4fr695-fdisk/bin/fdisk... But I don't know ;-)

Thank you.

infinisil commented 1 year ago

Good question! Usually we'd look at questions with the most :+1:'s, but since I don't always know the answer to those, I opted to just look at your question in todays Nix Hour!

Unfortunately the live streaming failed, but I did upload the recording afterwards: Nix Hour #28 (high definition still takes like an hour to finish processing)

And here are the resulting files: https://github.com/tweag/nix-hour/tree/master/28

Hope that helps :smiley:

MatXron commented 1 year ago

I've just watched it. Thank you @infinisil very much.