jankae / LibreVNA

100kHz to 6GHz 2 port USB based VNA
GNU General Public License v3.0
1.09k stars 207 forks source link

feat: add nix flake to package for NixOS #263

Open mtahernia opened 3 months ago

mtahernia commented 3 months ago

I added a Nix flake to package the LibreVNA-GUI for NixOS users.

jankae commented 3 months ago

Hi, thank you for the PR. I am unfamiliar with NixOS and flake. Could you please explain why this is needed, how installation would work on NixOS and whether the files have to be at the root of the repository? (I would rather prefer adding a folder for packaging instead of cluttering root)

jankae commented 2 months ago

This has been stale for a while. Any chance you can answer my questions? I am not against merging this, but would need to understand a bit more about it

mtahernia commented 2 months ago

Hi, apologies for my late response

Nix is a package management system based on Nix's functional programming language. You can find many resources about it online and from their official website. NixOS is not as user-friendly as distributions such as Ubuntu, but once you overcome the learning curve, it is hard to use any other distribution.

Ideally, we should submit the package to nixpkgs to include it in Nix distribution. (I didn't due to unfamiliarity with the community and lack of time, but I will do at some point). The next best thing is to include a flake for Nix users.

Now for why it has to be in the root, it doesn't have to be, but having it at the root of the repo is more convenient.

Here are some possibilities:

At root of a branch

In my fork of LibreVNA, I have a branch called nixos-support where flake.nix and flake.lock are present at the root of the repository. Anyone with Nix can run the following command to build and run LibreVNA-GUI:

nix run github:mtahernia/LibreVNA/nixos-support

This will pull the repo and build it and run the software. (also can install with nix,...)

At root of the main branch

If the files were in the main branch, you can omit the branch and simply run

nix run github:jankae/LibreVNA

In the subdirectory of a branch

They can also be in a subdirectory. Imagine flake.nix and flake.lock are located in package/nix of a branch test_branch; then one can use the following:

nix run github:jankae/LibreVNA/test_branch?dir=package/nix

In a separate repo containing only the flake.nix and flake.lock

nix run github:jankae/LibreVNA-nix

I hope this answers your question. Many thanks for your incredible work :)