Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Nix for a more sophisticated library system? #2

Open
KoviRobi opened this issue Mar 31, 2020 · 0 comments
Open

[Proposal] Nix for a more sophisticated library system? #2

KoviRobi opened this issue Mar 31, 2020 · 0 comments

Comments

@KoviRobi
Copy link

KoviRobi commented Mar 31, 2020

Hi,

I'd like to propose Nix for a more sophisticated library system, there are a couple of benefits:

  1. It's already written, and is very sophisticated.
  2. It can also capture non-Bluespec dependencies, should some simulation need some other software
  3. It has support for Linux and MacOS
  4. It supports per-project packages
  5. Bluespec is already packaged for it (and was perhaps one of the first package managers to have it packaged?)
  6. It supports pre-compiled packages so that you can ship compiled libraries.

This is more to gauge interest/opinions, I can do the Nix bits. In the end I'd imagine it to look something like this:

  1. You could install global packages, e.g. nix-env -i bsc-contrib
  2. You can have per-project packages, with Nix these are described by a shell.nix file, e.g.
    # Imports default package set, optional argument,
    # can be overridden from the command line
    { nixpkgs ? import <nixpkgs> { }
    }:
    with nixpkgs; # Use the default package set namespace
    mkShell {
      buildInputs = # A list of the project dependencies
      [ bluespec # The already packaged bluespec compiler
        bsc-contrib # This repo
        # others...
        # Or to prevent it 'polluting' the lib/Libraries path, replace the above with
        (bluespec.withPackages [ bsc-contrib ])
      ];
    }

As an example, see https://gist.github.com/KoviRobi/1381abdfce8e87139e4d04cfef3d76be#file-example-bluespec-shell-nix-L16-L27 where the highlighted lines are an 'inline package'. Then we merge the libraries from the BlueSpec compiler and this repo with symlinkJoin. This is just a quick test, that I am using to play around with the connectal library.

There is one limitation of the BlueSpec compiler that I'm aware of, which is that it doesn't support either a nested namespace, or *.bo files pointing to their own dependencies, which means that essentially we have to have a flat path containing all the libraries a project uses (recursively), and this limits will lead to namespace clashes.

E.g. suppose a project has a file MagicNumbers.bsv (as an example), this means that no other dependency can have a MagicNumbers.bsv file.

This would need to be changed in the compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant