I’m trying to integrate my custom scripts into the system’s PATH on NixOS with WSL, using Home Manager (unstable). My file structure includes:
configuration.nix
flake.lock
flake.nix
home.nix
README.md
scripts/
myscript.sh
I want to symbolically link my scripts or add the path to the scripts directory to $PATH. I’ve searched extensively but haven’t found a clear solution. This NixOS Discourse post discusses a similar issue but uses Git to fetch scripts. It references a Reddit comment that also didn’t solve my problem.
My configurations are available in this GitHub repo.
But this has the downside of not being very reproducible, since you will need to have your repository cloned at the declared location for this to work.
2 - You can install each script as a package:
{ pkgs, ... }: {
home.packages = with pkgs; [
(writeShellScriptBin {
name = "lzd";
runtimeInputs = [ lazydocker ];
text = import ./lzd;
})
];
}
The downside here is that you will need to run home-manager switch to tinker with your scripts.
3 - You can also do a mix of the two, trying the cloned repo first, and falling back to the installed scripts.
{ pkgs, ... }: {
home.sessionPath = [ "/home/sul/your-repository-path-here/scripts" ];
home.packages = with pkgs; [
lazydocker
(writeShellScriptBin {
name = "lzd";
text = import ./lzd;
})
];
}
it created copy of scipts in .local/bin but I can’t call it from terminal for some reason, it’s look like .local/bin not have in $PATH . I first thought it don’t have execution access but it has