Compare commits

..

1 commit

Author SHA1 Message Date
Fabien Freling 3f596a6dc9 use zig overlay 2023-10-13 13:57:52 +02:00
4 changed files with 83 additions and 116 deletions

View file

@ -16,25 +16,25 @@
"type": "github" "type": "github"
} }
}, },
"flake-parts": { "flake-utils": {
"inputs": { "inputs": {
"nixpkgs-lib": "nixpkgs-lib" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1696343447, "lastModified": 1694529238,
"narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=", "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "hercules-ci", "owner": "numtide",
"repo": "flake-parts", "repo": "flake-utils",
"rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4", "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "hercules-ci", "owner": "numtide",
"repo": "flake-parts", "repo": "flake-utils",
"type": "github" "type": "github"
} }
}, },
"flake-utils": { "flake-utils_2": {
"locked": { "locked": {
"lastModified": 1659877975, "lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
@ -51,52 +51,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1696983906, "lastModified": 1696725822,
"narHash": "sha256-L7GyeErguS7Pg4h8nK0wGlcUTbfUMDu+HMf1UcyP72k=", "narHash": "sha256-B7uAOS7TkLlOg1aX01rQlYbydcyB6ZnLJSfaYbKVww8=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "bd1cde45c77891214131cbbea5b1203e485a9d51",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1696019113,
"narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a", "rev": "5aabb5780a11c500981993d49ee93cfa6df9307b",
"type": "github" "type": "github"
}, },
"original": { "original": {
"dir": "lib", "id": "nixpkgs",
"owner": "NixOS", "type": "indirect"
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1697009197,
"narHash": "sha256-viVRhBTFT8fPJTb1N3brQIpFZnttmwo3JVKNuWRVc3s=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "01441e14af5e29c9d27ace398e6dd0b293e25a54",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
} }
}, },
"nixpkgs_2": { "nixpkgs_2": {
@ -117,24 +81,38 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable", "zig": "zig"
"zig-overlay": "zig-overlay"
} }
}, },
"zig-overlay": { "systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"zig": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-utils": "flake-utils", "flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1697198920, "lastModified": 1696810944,
"narHash": "sha256-dtaoksNoOMC3H+FDF3cK+bP+jYvJokYBAFvzCALLDYk=", "narHash": "sha256-yvt223HLZlAJa/u4uzT5aw3ph2bifto/KfU2k+eX+jg=",
"owner": "mitchellh", "owner": "mitchellh",
"repo": "zig-overlay", "repo": "zig-overlay",
"rev": "2d779a7657e346323ab048b218994dbdc42655d7", "rev": "6dc03885321cc8aad6356c847148eb40e167f9fb",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -1,59 +1,47 @@
{ {
description = "FabApp"; description = "FabApp";
# Inspired by https://github.com/mitchellh/zig-objc/blob/main/flake.nix
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; # take unstable if not specified
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable"; # nixpkgs.url = "github:nixos/nixpkgs/release-23.05";
zig-overlay.url = "github:mitchellh/zig-overlay"; # nixpkgs.url = "github:NixOS/nixpkgs/unstable";
flake-parts.url = "github:hercules-ci/flake-parts"; flake-utils.url = "github:numtide/flake-utils";
zig.url = "github:mitchellh/zig-overlay";
}; };
outputs = inputs@{ flake-parts, nixpkgs, ... }: outputs = {
flake-parts.lib.mkFlake { inherit inputs; } { self,
flake = { nixpkgs,
# Put your original flake attributes here. flake-utils,
}; ...
} @ inputs: let
systems = [ "x86_64-linux" ]; overlays = [
(final: prev: {
# https://flake.parts/module-arguments.html#persystem-module-parameters zigpkgs = inputs.zig.packages.${prev.system};
perSystem = { pkgs, system, ... }: { })
# We need unstable for Zig ];
_module.args.pkgs = import inputs.nixpkgs-unstable { systems = ["x86_64-linux"];
inherit system; in
# https://flake.parts/overlays flake-utils.lib.eachSystem systems (
overlays = [ system: let
inputs.zig-overlay.overlays.default pkgs = import nixpkgs {inherit overlays system;};
in rec {
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
zigpkgs.master
zls
emscripten
];
buildInputs = with pkgs; [
sqlite
# Linux graphical deps
xorg.libX11
libGL
]; ];
config = { };
}; };
formatter = pkgs.alejandra;
formatter = pkgs.nixfmt; }
);
devShells.default = with pkgs;
mkShell {
buildInputs = [
sqlite
# Zig / webAssembly impl.
zig
# zigpkgs."master" # Issue with X11/GL libraries
zls
emscripten
# Linux graphical deps
xorg.libX11
libGL
# xorg.libXcursor
# xorg.libXi
# xorg.libXext
# xorg.libXrandr
# xorg.libXinerama
# libGLU
];
};
};
};
} }

View file

@ -1,5 +1,11 @@
const std = @import("std"); const std = @import("std");
const raylib = @import("raylib.zig"); const raylib = @cImport({
@cInclude("raylib.h");
});
const raygui = @cImport({
@cDefine("RAYGUI_IMPLEMENTATION", "1");
@cInclude("raygui.h");
});
const sqlite = @cImport({ const sqlite = @cImport({
@cInclude("sqlite3.h"); @cInclude("sqlite3.h");
}); });
@ -15,7 +21,7 @@ pub fn main() !void {
raylib.ClearBackground(raylib.RAYWHITE); raylib.ClearBackground(raylib.RAYWHITE);
raylib.DrawText("Congrats! You created your first window!", 190, 200, 20, raylib.LIGHTGRAY); raylib.DrawText("Congrats! You created your first window!", 190, 200, 20, raylib.LIGHTGRAY);
if (raylib.GuiButton(.{ .x = 0, .y = 0, .width = 100, .height = 100 }, "MyButton") == 1) {} if (raygui.GuiButton(.{ .x = 0, .y = 0, .width = 100, .height = 100 }, "MyButton") == 1) {}
} }
raylib.CloseWindow(); raylib.CloseWindow();
} }

View file

@ -1,5 +0,0 @@
pub usingnamespace @cImport({
@cInclude("raylib.h");
@cDefine("RAYGUI_IMPLEMENTATION", "1");
@cInclude("raygui.h");
});