Skip to content

Commit

Permalink
Add Nix/Flake support
Browse files Browse the repository at this point in the history
- Use tweag/opam-nix for supporting and building Owl
- Add 'owl' as a default library to build
  • Loading branch information
yogeshsajanikar committed Jul 21, 2024
1 parent c788252 commit 7573ba1
Show file tree
Hide file tree
Showing 3 changed files with 259 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ setup.log
*.install

# editor config files
.vscode
.vscode

# Ignore direnv files
.envrc
.direnv/

# Ignore Nix/Flake related files/folders
result
result-*
189 changes: 189 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
inputs = {
opam-nix.url = "github:tweag/opam-nix";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.follows = "opam-nix/nixpkgs";
};
outputs = { self, flake-utils, opam-nix, nixpkgs }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
on = opam-nix.lib.${system};
localPackagesQuery = builtins.mapAttrs (_: pkgs.lib.last)
(on.listRepo (on.makeOpamRepo ./.));
devPackagesQuery = {
# You can add "development" packages here. They will get added to the devShell automatically.
ocaml-lsp-server = "*";
ocamlformat = "*";
};
query = devPackagesQuery // {
## You can force versions of certain packages here, e.g:
## - force the ocaml compiler to be taken from opam-repository:
ocaml-base-compiler = "*";
## - or force the compiler to be taken from nixpkgs and be a certain version:
# ocaml-system = "4.14.0";
## - or force ocamlfind to be a certain version:
# ocamlfind = "1.9.2";
ocaml-compiler-libs = "*";
alcotest = "*";
dune-configurator = "*";
bigarray-compat = "*";
};
scope = on.buildOpamProject' { } ./. query;
overlay = final: prev:
{
# You can add overrides here
# dune = prev.dune.overrideAttrs (_: { buildPhase = "make && make install"; });
};
scope' = scope.overrideScope' overlay;
# Packages from devPackagesQuery
devPackages = builtins.attrValues
(pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope');
# Packages in this workspace
packages =
pkgs.lib.getAttrs (builtins.attrNames localPackagesQuery) scope';
in {
legacyPackages = scope';

#inherit packages;

## If you want to have a "default" package which will be built with just `nix build`, do this instead of `inherit packages;`:
packages = packages // { default = packages.owl; };

devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues packages;
buildInputs = devPackages ++ [
# You can add packages from nixpkgs here
pkgs.openblas
];
};
});
}

0 comments on commit 7573ba1

Please sign in to comment.