# Link scripts to bin home-manager

**URL:** https://discourse.nixos.org/t/link-scripts-to-bin-home-manager/41774
**Category:** Help
**Created:** [March 18, 2024, 7:34pm UTC](https://discourse.nixos.org/t/link-scripts-to-bin-home-manager/41774 "2024-03-18T19:34:58Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![quasigod](https://discourse.nixos.org/user_avatar/discourse.nixos.org/quasigod/32/37014_2.png) [@quasigod](https://discourse.nixos.org/u/quasigod)
#### Post date: [March 18, 2024, 7:56pm UTC](https://discourse.nixos.org/t/link-scripts-to-bin-home-manager/41774/2 "2024-03-18T19:56:12Z")

</div>

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

```auto
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.

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

```

---

_[View the full topic](https://discourse.nixos.org/t/link-scripts-to-bin-home-manager/41774)._
