Skip to content

Commit

Permalink
Adds nix flake, adds tooling for creating a deployment of microzig, v…
Browse files Browse the repository at this point in the history
…endors some code from ezpkg
  • Loading branch information
Felix "xq" Queißner committed Jan 4, 2024
1 parent 597034b commit 0c4e82e
Show file tree
Hide file tree
Showing 10 changed files with 1,283 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
zig-out/
zig-cache/
microzig-deploy/
.DS_Store
.gdbinit
.lldbinit
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# MicroZig

## Overview

- `core/` contains the shared components of MicroZig.
- `board-support/` contains all official board support package.
- `examples/` contains examples that can be used with the board support packages.
- `tools/` contains tooling to work *on* MicroZig.

## Versioning Scheme

MicroZig versions are tightly locked with Zig versions.

The general scheme is `${zig_version}-${commit}-${count}`, so the MicroZig versions will look really similar to
Zigs versions, but with our own commit abbreviations and counters.

As MicroZig sticks to tagged Zig releases, `${zig_version}` will show to which Zig version the MicroZig build is compatible.

Consider the version `0.11.0-abcdef-123` means that this MicroZig version has a commit starting with `abcdef`, which was the 123rd commit of the version that is compatible with Zig 0.11.0.
20 changes: 20 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const std = @import("std");

pub fn build(b: *std.Build) void {
buildTools(b);
}

fn buildTools(b: *std.Build) void {
const tools_step = b.step("tools", "Only build the development tools");
b.getInstallStep().dependOn(tools_step);

const archive_info = b.addExecutable(.{
.name = "archive-info",
.optimize = .ReleaseSafe,
.root_source_file = .{ .path = "tools/archive-info.zig" },
});

tools_step.dependOn(&b.addInstallArtifact(archive_info, .{
.dest_dir = .{ .override = .{ .custom = "tools" } },
}).step);
}
146 changes: 146 additions & 0 deletions flake.lock

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

62 changes: 62 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
description = "microzig development environment";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-23.05";
flake-utils.url = "github:numtide/flake-utils";

# required for latest zig
zig.url = "github:mitchellh/zig-overlay";

# Used for shell.nix
flake-compat = {
url = github:edolstra/flake-compat;
flake = false;
};
};

outputs = {
self,
nixpkgs,
flake-utils,
...
} @ inputs: let
overlays = [
# Other overlays
(final: prev: {
zigpkgs = inputs.zig.packages.${prev.system};
})
];

# Our supported systems are the same supported systems as the Zig binaries
systems = builtins.attrNames inputs.zig.packages;
in
flake-utils.lib.eachSystem systems (
system: let
pkgs = import nixpkgs {inherit overlays system;};
in rec {
devShells.default = pkgs.mkShell {
nativeBuildInputs = [
pkgs.zigpkgs."0.11.0"
];

buildInputs = [
# we need a version of bash capable of being interactive
# as opposed to a bash just used for building this flake
# in non-interactive mode
pkgs.bashInteractive
pkgs.zlib
];

shellHook = ''
# once we set SHELL to point to the interactive bash, neovim will
# launch the correct $SHELL in its :terminal
export SHELL=${pkgs.bashInteractive}/bin/bash
'';
};

# For compatibility with older versions of the `nix` binary
devShell = self.devShells.${system}.default;
}
);
}
Loading

0 comments on commit 0c4e82e

Please sign in to comment.