Open guibou opened 2 months ago
Hey! Thanks for the PR and for starting a discussion on this. I definitely want tsui to be easy to run on NixOS, if only because the build system is already flake-based and so there isn't much other work required.
You're right that the flake.nix
is currently a little wonky in the context of running it on Nix systems. This is because we're actually primarily using Nix as a build system for the distributable binaries. They need to be able to run on non-Nix systems, which is why we have to patch the interp to one that real systems will actually have. The downside of this is that now, despite having a Nix flake, it doesn't actually support NixOS without FHS :)
Why not build the binary statically? The main dependency we care about here is X, which is used for the clipboard copying support. It probably isn't a great idea to statically link X into the binary.
I think there are two useful things that can both be done here:
Neither of these are truthfully my top priority at the moment, but if you are interested in either I will eagerly review and merge the changes!
Hi @kognise, thank you for your detailed answer! It is highly appreciated. (To be honest, I was expecting this MR and discussion to stale for years and was just publishing it in order to keep track and give visibility and a partial solution to the "I want to run that NOW on nixos" question).
Why not build the binary statically? The main dependency we care about here is X, which is used for the clipboard copying support. It probably isn't a great idea to statically link X into the binary.
Because of the licence or because you want the "self contained executable" to be able to use the "runtime" system X libraries versus the "buildtime" ones?
If that's about the licenses, my understanding is that with these MIT (-like) licences, you should be good.
If that's about the runtime vs buildtime, I think (but it should be confirmed) that X is perfectly able to work with some libraries discrepancy because it should only be an entrypoint for the X protocol (a bit like libc fopen
is internally using the stable kernel API).
Anyway, I've added a commit to the MR which implements point 1
: it provides two build artifacts:
#tsui
(which is also the default): no hack, works on nixos#tsui_no_nix_ld
(naming is difficult, I'm open to suggestions) which restores the behavior you had previouslySo could be the best of both world. I set the "no-hack" as default so it allows users to run tsui
from anywhere without really bothering, the variant with the hack being more of a dev specific entrypoint. Feel free to suggest a switch here.
I've also added a nix bundle
command. In theory it could create a self-extracting self-contained bundle which can be easy to relocate on any other computer. Try it with nix bundle
, and the result is in ./tsui
. I said in theory, because that's not a simple task, but I had success with this multiples times on some complex programs. (tl;dr; the archive contains a copy of /nix/store
with all the dependencies, it self extracts itself on a temporary filesystem namespace and runs). Other flavor of bundle are accessible, more here: https://nix.dev/manual/nix/2.18/command-ref/new-cli/nix3-bundle
The current point of this MR is that:
nix run github:neuralinkcorp/tsui
nix bundle
nix build .#tsui_no_nix_ld
.Tell me what to do next, in the meantime, enjoy your sunday ;)
This fixed the installation for me btw. Before and after updating my flake input to guibou
's fork (thanks btw!):
The standard nix builds creates a binary which is reproducible with pinned shared libraries in
/nix/store
as well as a pinned library loader (also located in/nix/store
).However the
preFixup
phase is replacing the reproducible and pinned library loader by one which is hopefully located in/lib64/ld-linux-x86-64.so.2
(e.g. forx86-64
systems). I don't understand this fix because:/lib64/ld-linux-x86-64.so.2
exists (e.g. on nixos systems) or that it is compatible (e.g. on system with a more recent libc).Note that I don't really understand the comment:
Alternates solutions:
nix run
and one other which does this patching.Note that with this commit, users can directly run
tsui
usingnix run 'github:neuralinkcorp/tsui'
(once merged).