forked from IllustratedMan-code/Godot-Flake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
79 lines (65 loc) · 2.13 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Godot is a cross-platform open-source game engine written in C++
# This flake build godot, the cpp bindings and the export templates
{
description = "the godot Engine, and the godot-cpp bindings for extensions";
inputs = {
# the godot Engine
godot = {
url = "github:godotengine/godot";
flake = false;
};
# the godot cpp bindings to build GDExtensions
godot-cpp = {
url = "github:godotengine/godot-cpp";
flake = false;
};
# the nixpkgs repo
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, ... }@inputs:
let
# only linux supported for now
systems = [ "x86_64-linux" "aarch64-linux" ];
# helper to build for multiple system
forAllSystems = f: nixpkgs.lib.genAttrs systems f;
forAllSystemPkgs = f:
forAllSystems (system: f (nixpkgs.legacyPackages.${system}));
# function to gen godot :
mkLib = pkgs: {
mkGodot = args: import ./godot.nix { inherit pkgs inputs; } args;
mkGdext = args: import ./extension.nix pkgs args;
mkExport = args: import ./export.nix pkgs args;
};
in {
# add build functions
lib = forAllSystemPkgs mkLib;
# template for godot projects :
templates = {
default = {
path = ./template;
description = "A simple Godot-Flake project";
welcomeText = "";
};
};
# pre-defined godot engine
packages = forAllSystemPkgs (pkgs:
let all = (mkLib pkgs).mkGodot { };
in all // { default = all.godot; });
# shell is just unputs for building godot from source
devShells = forAllSystemPkgs
(pkgs: { default = ((mkLib pkgs).mkGodot { }).shell; });
# Check that everything builds correctly
checks = forAllSystemPkgs (pkgs:
let
lib = mkLib pkgs;
godot = lib.mkGodot { };
in {
inherit (godot) godot-editor;
extension = lib.mkGdext {
godot-cpp = godot.godot-cpp;
src = "${inputs.godot-cpp}/test";
name = "godot-cpp-test";
};
});
};
}