snowleopard / alga

Algebraic graphs
MIT License
717 stars 68 forks source link

Allow project to be developed using Nix #177

Closed srid closed 5 years ago

srid commented 5 years ago

Some Haskell developers like myself use Nix to manage their environment. This change makes it easier to use Nix to get the project up and running. The nix-shell --run ghcid command for example will pull the dependencies (including ghc itself!), and launch ghcid which is extremely handy for iterative compilation feedback from edits.

I have also increased the version (referring to a yet to be published version) in default.nix so that nix does not accidentally pick the published version from hackage.

Ref:

snowleopard commented 5 years ago

Thanks @srid! I'm unsure if it's worth committing this file to the repository, because it's completely generic, i.e. has no relation to the library itself. What about adding it to .gitignore instead? It would allow you and other Nix users build the library with Nix by just creating this file.

Bumping the version to 0.4 is a good idea, let's do that.

srid commented 5 years ago

Sure, that's fine (the default.nix can grow depending on custom dependencies used though).

snowleopard commented 5 years ago

the default.nix can grow depending on custom dependencies used though

Thanks, I see. In this case I'll be happy to add it!

srid commented 5 years ago

Yea. Here's an example, where my app is using your library but using a local checkout (with changes) with tests disabled:

let
  pkgs = import <nixpkgs> { };
  H = pkgs.haskellPackages;
  dontCheck = pkgs.haskell.lib.dontCheck;
in H.developPackage {
  root = ./.;
  overrides = self: super: {
    algebraic-graphs = dontCheck (H.callCabal2nix "algebraic-graphs" dep/algebraic-graphs {});
  };
}

I could also have it point to a fork (instead of local directory) by using fetchFromGithub (example here).

All of this is only useful if a dev is using Nix for the Haskell workflow.

snowleopard commented 5 years ago

My worry is that I won't be able to maintain any sophisticated Nix scripts, because I'm not a Nix user. It's probably better to not have any Nix scripts at all than to have a Nix script that's occasionally out-of-date.