Skip to content

Commit

Permalink
Fixes flake.nix (#403)
Browse files Browse the repository at this point in the history
* Fixes flake.nix

* Update readme to remove --impure flag for nix build and develop

* Remove explicit library pins from opam file

* Update Kado pin

* Updates gitignore file
  • Loading branch information
solomon-b authored Sep 4, 2023
1 parent 081eae8 commit ce1ba90
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 61 deletions.
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,8 @@ setup.log
_opam/

# for Nix
result/
result

# for Direnv
/.envrc.local
/.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
];
};
});
}

0 comments on commit ce1ba90

Please sign in to comment.