Skip to content

Commit

Permalink
Adds CI and nix.flake
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix "xq" Queißner committed Jun 15, 2024
1 parent 02d2608 commit e39cd84
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build

on:
pull_request:
branches: [master]
push:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

- name: Build
run: |
zig build
11 changes: 9 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
const std = @import("std");

pub fn build(b: *std.Build) void {
// Options:

const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

// Targets:

const run_step = b.step("run", "Run the app");
const test_step = b.step("test", "Run unit tests");

// Build:

const parser_toolkit = b.dependency("parser_toolkit", .{});
const args = b.dependency("args", .{});

Expand Down Expand Up @@ -33,7 +42,6 @@ pub fn build(b: *std.Build) void {
run_cmd.addArgs(arg);
}

const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);

const exe_tests = b.addTest(.{
Expand All @@ -44,6 +52,5 @@ pub fn build(b: *std.Build) void {

exe_tests.root_module.addImport("hyperdoc", hyperdoc);

const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&b.addRunArtifact(exe_tests).step);
}
147 changes: 147 additions & 0 deletions flake.lock

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

49 changes: 49 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
description = "HyperDoc, a simple hyper document format";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
zig.url = "github:mitchellh/zig-overlay";
};

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 let
zig = pkgs.zigpkgs."0.13.0";
in rec {
packages.default = pkgs.stdenv.mkDerivation {
name = "hyperdoc";
src = ./.;
nativeBuildInputs = [zig];

configurePhase = "";

buildPhase = ''
zig build
'';

installPhase = ''
mv zig-out $out
'';
};
}
);
}

0 comments on commit e39cd84

Please sign in to comment.