meat/flake.nix
2025-06-23 00:43:55 +10:00

145 lines
3.5 KiB
Nix

{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
ocaml-overlay.url = "github:nix-ocaml/nix-overlays";
flake-utils.url = "github:numtide/flake-utils";
nh.url = "github:viperML/nh";
lix = {
url = "https://git.lix.systems/lix-project/lix/archive/main.tar.gz";
flake = false;
};
lix-module = {
url = "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz";
inputs.nixpkgs.follows = "ocaml-overlay";
inputs.lix.follows = "lix";
};
};
nixConfig = {
extra-substituters = "https://anmonteiro.nix-cache.workers.dev";
extra-trusted-public-keys = "ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=";
};
outputs = inputs @ {
self,
nixpkgs,
ocaml-overlay,
flake-utils,
...
}: let
inherit (inputs) ocaml-overlay;
lix-overlay = inputs.lix-module.overlays.default;
lix-module = inputs.lix-module.nixosModules.default;
nh-overlay = inputs.nh.overlays.default;
version = builtins.toString self.lastModified;
in
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
lix-overlay
nh-overlay
ocaml-overlay.overlays.default
];
modules = [lix-module];
extra-substituters = "https://anmonteiro.nix-cache.workers.dev";
extra-trusted-public-keys = "ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=";
};
minimal = let
inherit
(pkgs.ocamlPackages)
dune_3
ocaml
;
in [
dune_3
ocaml
];
dev = let
inherit
(pkgs.ocamlPackages)
utop
ocaml-lsp
ocamlformat
ocamlformat-rpc-lib
;
in [
utop
ocaml-lsp
ocamlformat
ocamlformat-rpc-lib
];
inherit (pkgs) lix nh;
in {
devShells.default = let
inherit (pkgs) mkShell;
in
mkShell {
buildInputs = minimal ++ dev ++ [lix nh];
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
@push:
git commit -a
git push
'';
in ''
printf '${justFile}' > justfile
'';
};
packages.default = pkgs.callPackage ./nix/default.nix {
ocaml-deps = minimal;
inherit version;
};
defaultPackage = self.packages.${system}.default;
}
)
// {
nixosModules.meat = import ./nix/module.nix {
meatOverlays = [
ocaml-overlay.overlays.default
nh-overlay
self.overlays.meat
];
lixModule = lix-module;
};
overlays.meat = final: prev: let
ocaml-deps = let
inherit
(final.ocamlPackages)
dune_3
ocaml
;
in [
dune_3
ocaml
];
in {
meat = final.callPackage ./nix/default.nix {
inherit ocaml-deps version;
};
};
};
}