Initial commit

Setup a nix flake for an ocaml setup with mruby dependency
This commit is contained in:
2026-07-25 22:00:25 +01:00
commit 4cbacf7172
12 changed files with 211 additions and 0 deletions
+97
View File
@@ -0,0 +1,97 @@
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
inputs.self.submodules = true;
outputs =
{ self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
mruby = pkgs.stdenv.mkDerivation {
pname = "mruby";
version = "0.0.1";
src = pkgs.lib.cleanSourceWith {
src = "${self}/libs";
name = "mruby-src";
};
patches = [ ./libs/changes.patch ];
nativeBuildInputs = with pkgs; [
ruby
gnumake
gcc
];
buildPhase = ''
(cd mruby && rake)
'';
installPhase = ''
mkdir -p $out
cp -r mruby/build/host/lib $out/
'';
};
kutu = pkgs.stdenv.mkDerivation {
pname = "kutu";
version = "0.1.0";
src = self;
nativeBuildInputs = with pkgs; [
dune_3
ocaml
ocamlPackages.findlib
];
buildInputs = with pkgs; [
libxcb
xcbutilwm
xrandr
xprop
ocamlPackages.ctypes
ocamlPackages.ctypes-foreign
mruby
];
buildPhase = ''
export MRUBY_LIB=${mruby}/lib
dune build src/main.exe --release
'';
installPhase = ''
mkdir -p $out/bin
cp _build/default/src/main.exe $out/bin/kutu
'';
};
in
{
packages.${system} = {
default = kutu;
kutu = kutu;
mruby = mruby;
};
devShells.${system}.default = pkgs.mkShell {
inputsFrom = [ kutu ];
packages = with pkgs; [
ocamlPackages.utop
ocamlPackages.ocaml-lsp
ocamlPackages.ocamlformat
];
shellHook = ''
export CC=clang
export CXX=clang++
export LD=clang
export MRUBY_LIB=${mruby}/lib
'';
};
};
}