129 lines
3.2 KiB
Nix
129 lines
3.2 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:nixOS/nixpkgs";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
outputs = {
|
|
self,
|
|
nixpkgs,
|
|
flake-utils,
|
|
ocaml-overlay,
|
|
}: let
|
|
version = builtins.toString self.lastModified;
|
|
in
|
|
flake-utils.lib.eachDefaultSystem (
|
|
system: let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [
|
|
ocaml-overlay.overlays.default
|
|
];
|
|
extra-substituters = "https://anmonteiro.nix-cache.workers.dev";
|
|
extra-trusted-public-keys = "ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=";
|
|
};
|
|
inherit (pkgs) mkShell ocamlPackages ocaml-ng;
|
|
inherit
|
|
(ocamlPackages)
|
|
dune_3
|
|
ocaml
|
|
utop
|
|
ocaml-lsp
|
|
ocamlformat
|
|
ocamlformat-rpc-lib
|
|
angstrom
|
|
angstrom-unix
|
|
ppx_inline_test
|
|
;
|
|
minimal = [
|
|
dune_3
|
|
ocaml
|
|
angstrom
|
|
angstrom-unix
|
|
ppx_inline_test
|
|
];
|
|
dev = [
|
|
utop
|
|
ocaml-lsp
|
|
ocamlformat
|
|
ocamlformat-rpc-lib
|
|
pkgs.just
|
|
];
|
|
in {
|
|
devShells.default = mkShell {
|
|
buildInputs = minimal ++ dev;
|
|
shellHook = let
|
|
justFile = ''
|
|
default:
|
|
@just --list
|
|
|
|
@build:
|
|
nix build .#debug --offline
|
|
|
|
@release:
|
|
nix build --offline
|
|
|
|
@test:
|
|
printf "\\n\\n\\t************ running nix+dune tests ************\\n\\n\\n"
|
|
nix flake check --offline
|
|
nix build .#tests --offline
|
|
printf "\\n\\n\\t************ running visual test ************\\n\\n\\n"
|
|
echo one two three four | CULRS="(255,0,0);(0,0,255);#00FF00" CULR_ORDER="1;0;2" result/bin/culr
|
|
'';
|
|
in ''
|
|
printf '${justFile}' > justfile
|
|
'';
|
|
};
|
|
|
|
checks.default = pkgs.callPackage ./nix/test.nix {
|
|
culr = self.packages.${system}.tests;
|
|
inherit version;
|
|
};
|
|
|
|
packages.default = pkgs.callPackage ./nix/default.nix {
|
|
ocaml-deps = minimal;
|
|
inherit version;
|
|
};
|
|
|
|
packages.debug = pkgs.callPackage ./nix/default.nix {
|
|
debug = true;
|
|
ocaml-deps = minimal;
|
|
inherit version;
|
|
};
|
|
|
|
packages.tests = pkgs.callPackage ./nix/default.nix {
|
|
debug = true;
|
|
ocaml-deps = minimal;
|
|
doCheck = true;
|
|
inherit version;
|
|
};
|
|
}
|
|
)
|
|
// {
|
|
nixosModules.culr = import ./nix/module.nix {culrOverlay = self.overlays.culr;};
|
|
|
|
overlays.culr = final: prev: let
|
|
ocaml-deps = let
|
|
inherit
|
|
(prev.ocamlPackages)
|
|
dune_3
|
|
ocaml
|
|
angstrom
|
|
angstrom-unix
|
|
ppx_inline_test
|
|
;
|
|
in [
|
|
dune_3
|
|
ocaml
|
|
angstrom
|
|
angstrom-unix
|
|
ppx_inline_test
|
|
];
|
|
in {
|
|
culr = final.callPackage ./nix/default.nix {
|
|
inherit ocaml-deps version;
|
|
};
|
|
};
|
|
};
|
|
}
|