How can I use Nix to statically compile the program in Application

I assume when you say “Application library”, you mean nixpkgs?
Nix does not help you with static compilation of programs, as I already explained to @Axwiolv in the other thread.

nixStatic is just a statically linked binary of regular nix, it works exactly like regular Nix, meaning you build packages as a set of dependencies that are all stored in /nix/store. You can copy compiled programs to other machines using the nix copy command, but I’m not sure if that’s what you’re after. If you take a look at the nixStatic expression in nixpkgs, you’ll see that it uses very specific building instructions to build a statically linked binary. You’d have to do the same for every package you want to build this way.

Could you explain in more detail what it is you’re trying to achieve? What sort of applications do you want to build statically and why?


I’m also curious why two new users joined within the span of 1 hour and asked almost the exact same question in two different threads and a private message with similar wording.

Screenshot 2023-10-18 at 13.18.10
Screenshot 2023-10-18 at 13.18.24

Is @Axwiolv your account as well? What is going on here?