xin/templates/ocaml/flake.nix

60 lines
1.6 KiB
Nix
Raw Normal View History

2022-10-05 21:46:32 -06:00
{
description = "thing: stuff and things";
2023-12-01 14:27:57 -07:00
inputs.nixpkgs.url = "nixpkgs/nixos-23.11";
2022-10-05 21:46:32 -06:00
2023-09-12 08:44:05 -06:00
outputs =
{ self
, nixpkgs
,
}:
let
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in
{
packages = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
in
{
thing = pkgs.stdenv.mkDerivation {
pname = "thing";
version = "v0.0.0";
src = ./.;
buildInputs = with pkgs;
[ ocaml opam ocamlformat pkg-config ]
++ (with pkgs.ocamlPackages; [ dune_3 odoc ]);
2022-10-05 21:46:32 -06:00
2023-09-12 08:44:05 -06:00
buildPhase = ''
ocamlc -o thing thing.ml
'';
2022-10-05 21:46:32 -06:00
2023-09-12 08:44:05 -06:00
installPhase = ''
mkdir -p $out/bin
mv thing $out/bin
'';
};
});
2022-10-05 21:46:32 -06:00
2023-09-12 08:44:05 -06:00
defaultPackage = forAllSystems (system: self.packages.${system}.thing);
devShells = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
in
{
default = pkgs.mkShell {
shellHook = ''
PS1='\u@\h:\@; '
nix flake run github:qbit/xin#flake-warn
echo "OCaml `${pkgs.ocaml}/bin/ocaml --version`"
'';
nativeBuildInputs = with pkgs;
[ ocaml opam ocamlformat pkg-config ]
++ (with pkgs.ocamlPackages; [ dune_3 odoc ]);
};
});
};
2022-10-05 21:46:32 -06:00
}