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

Fixes flake.nix #403

Merged
merged 5 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# this line sources your `.envrc.local` file
source_env_if_exists .envrc.local
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,7 @@ setup.log
_opam/

# for Nix
result/
result/
/.envrc.local
/result
favonia marked this conversation as resolved.
Show resolved Hide resolved
/.direnv/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ you'll need to [install or enable flakes](https://nixos.wiki/wiki/Flakes).
Then, cooltt can be built with the command

```
nix build --impure
nix build
```

to put a binary `cooltt` in `result/bin/cooltt`. This is good for if you just want to build
Expand All @@ -63,7 +63,7 @@ If you're working on cooltt, you can enter a development shell with an OCaml com
and other tools with

```
nix develop --impure
nix develop
```

and then build as in the [with OPAM](https://github.com/RedPRL/cooltt/#with-opam=) section
Expand Down
2 changes: 1 addition & 1 deletion cooltt.opam
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ depends: [
"kado"
]
pin-depends: [
[ "kado.~dev" "git+https://github.com/RedPRL/kado" ]
[ "kado.~dev" "git+https://github.com/RedPRL/kado#65573a1c0f14f6b09836f8ae317fda17f5900968" ]
[ "bantorra.0.1.0" "git+https://github.com/RedPRL/bantorra#1e78633d9a2ef7104552a24585bb8bea36d4117b" ]
]
build: [
Expand Down
121 changes: 87 additions & 34 deletions flake.lock

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

61 changes: 38 additions & 23 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,50 @@
description = "Experimental implementation of Cartesian cubical type theory";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
flake-utils.url = "github:numtide/flake-utils";

opam-repository = {
url = "github:ocaml/opam-repository";
flake = false;
};

opam-nix = {
url = "github:tweag/opam-nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.opam-repository.follows = "opam-repository";
};
opam-nix.url = "github:tweag/opam-nix";
opam-nix.inputs.opam-repository.follows = "opam-repository";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.follows = "opam-nix/nixpkgs";
};

outputs = { self
, flake-utils
, opam-nix
, nixpkgs
, opam-repository
}@inputs:
flake-utils.lib.eachDefaultSystem (system: {
legacyPackages = let
outputs = { self, flake-utils, opam-nix, opam-repository, nixpkgs }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
on = opam-nix.lib.${system};
in on.buildDuneProject { } "cooltt" ./. {
ocaml-base-compiler = null;
};
localPackagesQuery = builtins.mapAttrs (_: pkgs.lib.last)
(on.listRepo (on.makeOpamRepo ./.));
devPackagesQuery = {
ocaml-lsp-server = "*";
ocp-indent = "*";
merlin = "*";
};
query = devPackagesQuery // {
ocaml-base-compiler = "*";
};
scope = on.buildDuneProject { } "cooltt" ./. query;
devPackages = builtins.attrValues
(pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope);
packages =
pkgs.lib.getAttrs (builtins.attrNames localPackagesQuery) scope;
in
{
legacyPackages = scope;

packages = packages // { default = packages.cooltt; };

defaultPackage = self.legacyPackages.${system}."cooltt";
});
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues packages;
buildInputs = devPackages ++ [
pkgs.fd
pkgs.nixpkgs-fmt
pkgs.pkg-config
pkgs.shellcheck
];
};
});
}