Ah, you’re right. For some reason my brain decided to group powershell with windows, but it is cross platform. I’ll add your suggestion and see how it goes!
Okay I tried your suggestion but I get an error sh: ns: command not found but I don’t get this error how I did it previously.
Edit: Ah, is it that unlike the completions only it actually tries to use my program? I’m not sure that will work in this case since it’s done in a sandbox.
OK, got it! I just needed to point the path to the binary, not just assume it. So this worked:
postInstall = ''
${cmdliner}/bin/cmdliner install tool-support $out/bin/ns $out
'';
How do I install the man page? I can see an ns.1.gz was generated but man ns says no man page available.
Ah, one other question. After changing to use the recommended way instead of standalone way, I’ve been seeing this error after updating the tool and it persists between boots and garbage collection. Does this mean it writes to some other file?
_ns:3: _cmdliner_generic: function definition file not found
_ns:3: _cmdliner_generic: function definition file not found
_ns:3: _cmdliner_generic: function definition file not found
Yes tool-support runs your binary because it installs man pages and those are extracted from by the binary by invoking it. Again, invoke with --dry-run to see what that entails.
You need the generic support for the cmdliner library installed. So I guess it depends on what the install of cmdliner does on nix. See the documentation here.
In general the documentation here should answer most of your install questions.
I see, that makes sense. Adding this line fixed it:
postInstall = ''
${cmdliner}/bin/cmdliner install tool-support $out/bin/ns $out
${cmdliner}/bin/cmdliner install generic-completion $out/share
'';
I don’t know how nix is organized but note that normally that line you added should be added by the cmdliner package and packages that use cmdliner should make these files visible to packages that depend on them at runtime.
That’s exactly what’s happening here I believe. The resulting derivation has all of the scripts where nix assumes they should be and as a result the functions are found when they are needed in the nix-store path for that derivation.
This is the result of building the derivation. The result directory is a symlink to the nix-store path which is read-only: /nix/store/5kjcs63p8357pd1cwq9z3fv85wk35y3i-ocaml5.3.0-ns-0.3.0
If you wanna give it a try, it’s pretty neat. I’ve been using nix for years at this point, can’t look back.
result
├── bin
│ └── ns
├── lib
│ └── ocaml
│ └── 5.3.0
│ └── site-lib
│ └── ns
│ ├── dune-package
│ ├── META
│ └── opam
└── share
├── bash-completion
│ └── completions
│ ├── _cmdliner_generic
│ └── ns
├── doc
│ └── ns
│ ├── LICENSE
│ └── README.md
├── man
│ └── man1
│ └── ns.1.gz
├── powershell
│ ├── cmdliner_generic_completion.ps1
│ └── ns_completion.ps1
└── zsh
└── site-functions
├── _cmdliner_generic
└── _ns