Link scripts to bin home-manager

You can use the nixpkgs function writeShellScriptBin. Here’s an example:

home.packages = with pkgs; [
  (writeShellScriptBin "hi" ''
    echo "hi!"
  '')
];

This script will automatically be put in your path with the name hi

Edit:

If you want to read it from a separate .sh file, I think this should work.

home.packages = with pkgs; [
  (writeShellScriptBin "hi" (builtins.readFile ./relpath/to/script.sh)
];
3 Likes