about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.envrc1
-rw-r--r--.gitignore4
-rw-r--r--build.zig34
-rw-r--r--flake.lock40
-rw-r--r--flake.nix16
-rw-r--r--shell.nix6
-rw-r--r--src/main.zig9
7 files changed, 110 insertions, 0 deletions
diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..3550a30
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use flake
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..dde441d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+zig-cache/
+zig-out/
+
+.direnv/
diff --git a/build.zig b/build.zig
new file mode 100644
index 0000000..766bc01
--- /dev/null
+++ b/build.zig
@@ -0,0 +1,34 @@
+const std = @import("std");
+
+pub fn build(b: *std.build.Builder) void {
+    // Standard target options allows the person running `zig build` to choose
+    // what target to build for. Here we do not override the defaults, which
+    // means any target is allowed, and the default is native. Other options
+    // for restricting supported target set are available.
+    const target = b.standardTargetOptions(.{});
+
+    // Standard release options allow the person running `zig build` to select
+    // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
+    const mode = b.standardReleaseOptions();
+
+    const exe = b.addExecutable("wl-dpms", "src/main.zig");
+    exe.setTarget(target);
+    exe.setBuildMode(mode);
+    exe.install();
+
+    const run_cmd = exe.run();
+    run_cmd.step.dependOn(b.getInstallStep());
+    if (b.args) |args| {
+        run_cmd.addArgs(args);
+    }
+
+    const run_step = b.step("run", "Run the app");
+    run_step.dependOn(&run_cmd.step);
+
+    const exe_tests = b.addTest("src/main.zig");
+    exe_tests.setTarget(target);
+    exe_tests.setBuildMode(mode);
+
+    const test_step = b.step("test", "Run unit tests");
+    test_step.dependOn(&exe_tests.step);
+}
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..0b3c367
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,40 @@
+{
+  "nodes": {
+    "flake-utils": {
+      "locked": {
+        "lastModified": 1659877975,
+        "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1662732537,
+        "narHash": "sha256-iqxa+38SRU+SwNsKDyP8rZt79yPFGSgTe+K4Ujbb/uw=",
+        "path": "/nix/store/fvlw9w0m49k94ag7bb674yyc92rr5fif-source",
+        "rev": "74a1793c659d09d7cf738005308b1f86c90cb59b",
+        "type": "path"
+      },
+      "original": {
+        "id": "nixpkgs",
+        "type": "indirect"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-utils": "flake-utils",
+        "nixpkgs": "nixpkgs"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..74fd650
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,16 @@
+{
+  description = "baitinq.github.io flake";
+
+  inputs.flake-utils.url = "github:numtide/flake-utils";
+
+  outputs = { self, nixpkgs, flake-utils }:
+
+    flake-utils.lib.eachDefaultSystem
+      (system:
+        let pkgs = nixpkgs.legacyPackages.${system}; in
+        {
+          devShells.default = import ./shell.nix { inherit pkgs; };
+        }
+      );
+
+}
diff --git a/shell.nix b/shell.nix
new file mode 100644
index 0000000..606384d
--- /dev/null
+++ b/shell.nix
@@ -0,0 +1,6 @@
+{ pkgs ? import <nixpkgs> { } }:
+pkgs.mkShell {
+  nativeBuildInputs = with pkgs; [
+    zig
+  ];
+}
diff --git a/src/main.zig b/src/main.zig
new file mode 100644
index 0000000..a7a7c95
--- /dev/null
+++ b/src/main.zig
@@ -0,0 +1,9 @@
+const std = @import("std");
+
+pub fn main() anyerror!void {
+    std.log.info("All your codebase are belong to us.", .{});
+}
+
+test "basic test" {
+    try std.testing.expectEqual(10, 3 + 7);
+}