# Hard coded executable paths

**URL:** <https://openziti.discourse.group/t/hard-coded-executable-paths/791>\
**Category:** Building/Development\
**Created:** [October 1, 2022, 12:11am UTC](https://openziti.discourse.group/t/hard-coded-executable-paths/791 "2022-10-01T00:11:50Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![johnalotoski](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/johnalotoski/32/570_2.png) [@johnalotoski](https://openziti.discourse.group/u/johnalotoski)\
**Post date:** [October 1, 2022, 9:38pm UTC](https://openziti.discourse.group/t/hard-coded-executable-paths/791/3 "2022-10-01T21:38:55Z")

</div>

Hi @sabedevops! Sure, happy to answer questions on NixOS; it is rather different from most other distros.

> Are the links `/run/current-system/sw/bin/[binary]` always installed to some `/nix/store/.../bin/[binary]` ?

- The nix store typically begins with a prefix of `/nix/store/`, and while it is possible to change it, that tends to be fairly rare except under special use cases and [is generally not advised](https://nixos.org/manual/nix/stable/installation/building-source.html#:~:text=It%20is%20best%20not%20to%20change%20the%20Nix%20store%20from%20its%20default) as doing so prevents the use of community binary caches.

- The general pattern for binaries is for to be placed in `/nix/store/$HASH/bin/$BINARY`. However, there are exceptions to this. Checking my own `/run/current-system/sw/bin/` directory, for example, I have:

> Similarly, can you describe the purpose of `/etc/static` in some greater detail for NixOS?

- Linking declarative `/etc` files in a `static` subdir [helps implement](https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/etc/setup-etc.pl#L82-L84) an [atomic upgrade and rollback](https://nixos.org/guides/how-nix-works.html#:~:text=reinstalling%20from%20scratch.-,Atomic%20upgrades,-NixOS%20has%20a) feature in NixOS.

> I’m trying to understand whether the solution here is to change these hardcoded paths to depends on some `#ifndef` pattern, as opposed to searching $PATH. We could potentially then handle this in system packaging, or allow the user to define their own during build time. What do you think?

Some of what I'm thinking would depend on whether OpenZiti would like to have the release artifacts work directly on NixOS. Probably the answer to that may depend on level of effort, right? Maybe yes if level of effort is low, maybe not so much if level of effort is high? There are probably 3 levels of NixOS compatibility to consider with regard to direct use of the release binaries:

1. Binaries work on NixOS as downloaded from the repo:

2. Binaries don't work on NixOS (reason: lib refs only):

3. Binaries don't work on NixOS (reason: FHS code deps and logic [and optionally lib ref problem also]):

Right now, we are in case (3) for the tunneler client. I haven't look at the other binaries yet, but probably they are case (3) also. If the code logic adjustments are addressed at the runtime level, then we are in case (2) and it would be fairly trivial for a NixOS user to download a release binary, patch the lib refs and directly use the binary. Case (1) would probably only be achieved if the builds are static like mentioned in the other thread [here](https://openziti.discourse.group/t/static-binary-artifacts-for-ci-releases/790) as well as the FHS code logic issue being handled at runtime.

If the hard coded paths are handled by `#ifndef` at build time, I think that pretty much guarantees NixOS incompatibility with release binaries because presumably the CI binary artifact releases will continue to be built with FHS paths, right?

Ultimately, we'd like to see OpenZiti packaged for Nix, in which case the tunneler code will work with or without `#ifndef` addition, because the libs will be appropriately linked and the FHS paths appropriately substituted for NixOS compatible paths during the build. Downside will be that NixOS users won't be able to use the upstream release binaries directly if they want, although I think that's probably not unusual on NixOS for these very reasons. It just may be awhile before we (or someone else) gets the time to package OpenZiti for Nix.

John

---

_[View the full topic](https://openziti.discourse.group/t/hard-coded-executable-paths/791)._
