Skip to content

Commit

Permalink
Dev update (#4)
Browse files Browse the repository at this point in the history
 - Added Dox the haxe documentation generator
 - mkHeapsGame support buildInputs
 - Added a simple default haxe shell
 - Better documentation organisation
 - Template gives you more useful files
 - Action only checks if changes on nix files
 - Format and whitespaces clean-up
 - Updated flake lock
  • Loading branch information
MadMcCrow authored Nov 9, 2023
1 parent 48ed022 commit 833e8a2
Show file tree
Hide file tree
Showing 20 changed files with 212 additions and 86 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: Check
on:
push:
branches: [main]
paths:
- '**.nix'
- 'flake.lock'
- 'flake.nix'
- 'nix/**'
pull_request:

jobs:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ result*
# hashlink build result
*.hl
# hashlink/c out build folder
out*
out*
# MacOS
.DS_Store
4 changes: 0 additions & 4 deletions demo/src/Main.hx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import map.*;

// Our main app
class Main extends hxd.App {
override function init() {
var tf = new h2d.Text(hxd.res.DefaultFont.get(), s2d);
tf.text = "Hello World !";
}

static function main() {
new Main();
}
Expand Down
8 changes: 8 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- build and run Heaps games on linux
- build wih latest Haxe, Heaps, etc.
- MacOS (darwin) support
- M1 support (no native heaps game, because HL cannot be built in arm64)
- package haxelibs
- Check flake with github action for PRs
- mkHeapsGame support buildInputs
- Added a simple default haxe shell
File renamed without changes.
9 changes: 9 additions & 0 deletions README.md → docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ A flake to build and run games made with [heaps.io](https://heaps.io/) and possi

See the flake [template](template/flake.nix) for a example on how to use haxix in your own projects.

you can instantiate it in any folder with :
```
nix flake init -t github:MadMcCrow/haxix#
```

## TODO

See [TODO.md](docs/TODO.md). these are the most likely things to be added to the project.
Expand All @@ -21,3 +26,7 @@ Licensed under [MIT](Licence.md)
## Authors

See [AUTHORS](docs/AUTHORS.md) for the complete list of people who helped make haxix.

## Status

![check](https://github.com/MadMcCrow/haxix/actions/workflows/check.yml/badge.svg?branch=main)
17 changes: 6 additions & 11 deletions docs/TODO.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# DONE :

- build and run Heaps games on linux
- build wih latest Haxe, Heaps, etc.
- MacOS (darwin) support
- M1 support (no native heaps game, because HL cannot be built in arm64)
- package haxelibs

# TODO :

- [ ] Github Action
- [X] Check Flake
- [ ] Build Cachix cache
- [ ] Clean, remove `_latest` from package names
- [ ] Other Haxe game engines
- [ ] Godot-Haxe
- [ ] OpenFL
- [ ] Auto-Update through Github Action
- [ ] Clean, remove `_latest` from package names
- [ ] OpenFL
43 changes: 30 additions & 13 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 20 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
url = "github:HaxeFoundation/hashlink?ref=refs/tags/latest";
flake = false;
};
# Dox : the documentation tool
dox = {
url ="github:HaxeFoundation/dox";
flake = false;
};
# format : the format support library
haxe_format = {
url = "github:HaxeFoundation/format";
Expand Down Expand Up @@ -61,33 +66,40 @@

# template for heaps projects :
templates.default = {
path = ./template;
description = "A simple haxe game project";
welcomeText = "";
};
path = ./template;
description = "A simple haxe/heaps game project";
welcomeText = "";
};

# expose functions :
lib = forAllSystems (system: {
mkHaxelib = (haxix system).haxelib.mkHaxelib;
mkHaxedoc = (haxix system).dox.mkHaxedoc;
mkHeapsGame = (haxix system).heaps.mkGame;
mkHeapsShell = (haxix system).heaps.mkShell;
});

# All important packages and the demo
packages = forAllSystems (system: {
# haxelang :
haxe = (haxix system).haxe.haxe_latest;
hashlink = (haxix system).hashlink.hashlink_latest;
# libs :
format = (haxix system).format.format_latest;
dox = (haxix system).dox.dox_latest;
# helloworld :
demo = demo system;
});

# checks
# TODO : improve to only build minimal checks
checks = forAllSystems (system: {
demo = demo system;
});
checks = forAllSystems (system: { demo = demo system; });

# shell for the demo
devShells = forAllSystems
(system: { default = (haxix system).heaps.mkShell (demo system); });
(system: {
default = (haxix system).shell;
demo = (haxix system).heaps.mkShell (demo system);
});
};
}
2 changes: 1 addition & 1 deletion nix/darwin/hashlink.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ in (finalAttrs: previousAttrs:{
''
install_name_tool -add_rpath $out/lib $out/bin/hl
'';
})
})
19 changes: 18 additions & 1 deletion nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,21 @@ let
inherit (hashlink) hashlink_latest;
};

in { inherit haxe hashlink heaps format; }
# Dox documentation tool
dox = import ./dox.nix {
inherit pkgs haxelib;
inherit (inputs) dox;
inherit (haxe) haxe_latest;
};

shell = pkgs.mkShell {
buildInputs = [
haxe.haxe_latest
hashlink.hashlink_latest
format.format_latest
heaps.heaps_latest
dox.dox_latest
];
};

in { inherit haxe hashlink heaps format dox shell; }
44 changes: 44 additions & 0 deletions nix/dox.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# dox.nix
# a haxe library for creating beautiful docs
{ pkgs, dox , haxe_latest, haxelib }:
let
# dox haxelib
dox_latest = haxelib.mkHaxelib {
version = "latest";
libname = "dox";
src = dox;
meta = {
description = "A Haxe tool to generate Haxe documentation";
licenses = [pkgs.lib.licenses.mit];
};
};

# haxedoc : the resulting documentation of a haxe derivation :
# TODO: support for custom Compile.hxml
mkHaxedoc = {haxeDrv, srcDir ? "src", main ? "Main", haxeLibs ? []} :
pkgs.stdenvNoCC.mkDerivation {
# TODO : check/fix versionned names
name = "${haxeDrv.name}-doc";
src = haxeDrv.src;
buildInputs = [haxe_latest dox_latest] ++ haxeDrv.buildInputs;
unpackPhase = ''
cp -R $src/src/* ./
'';
buildPhase = ''
ls -la
${haxe_latest}/bin/haxe -xml docs/doc.xml -D doc-gen \
${builtins.concatStringsSep " " (map (x: "-lib ${x}") haxeLibs)}
haxelib run dox -i docs
'';
installPhase = ''
mkdir -p $out/doc
cp pages/* $out/doc
'';
meta = haxeDrv.meta // {
description = "Documentation of ${haxeDrv.name}";
};
};

in {
inherit dox_latest mkHaxedoc;
}
2 changes: 1 addition & 1 deletion nix/format.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ in {
src = haxe_format;
version = "latest";
};
}
}
4 changes: 2 additions & 2 deletions nix/hashlink.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let
# darwin support
darwinOverrides = if pkgs.stdenv.isDarwin
then (import ./darwin/hashlink.nix pkgs) else (f: p: {});

# Custom HL with libraries for haxelib added
generic = { version, src }:
let
Expand Down Expand Up @@ -46,4 +46,4 @@ in {
version = "latest";
src = hashlink;
};
}
}
2 changes: 1 addition & 1 deletion nix/haxe.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ in {
src = haxe;
ocaml-ng = pkgs.ocaml-ng.ocamlPackages_4_08;
};
}
}
2 changes: 1 addition & 1 deletion nix/haxelib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ in {
description = throw "please write meta.description";
} // (attrs.meta or { });
});
}
}
Loading

0 comments on commit 833e8a2

Please sign in to comment.