Initial commit
This commit is contained in:
commit
f4670e510f
6 changed files with 151 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
|||
use flake
|
||||
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Zig
|
||||
zig-*
|
||||
.zig-*
|
||||
|
||||
# Nix
|
||||
result*
|
||||
|
||||
# Misc
|
||||
.direnv
|
||||
35
build.zig
Normal file
35
build.zig
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
// TODO: This should be a non-exhaustive enum with one option: all
|
||||
const day = b.option(u8, "day", "Build day") orelse 1;
|
||||
|
||||
// TODO: Depending on the day chosen, only that day should compile, or all days
|
||||
const exe = addDay(b, target, optimize, day);
|
||||
b.installArtifact(exe);
|
||||
|
||||
// run step
|
||||
const run_exe = b.addRunArtifact(exe);
|
||||
const run_step = b.step("run", "Run the binary");
|
||||
run_step.dependOn(&run_exe.step);
|
||||
}
|
||||
|
||||
fn addDay(
|
||||
b: *std.Build,
|
||||
target: std.Build.ResolvedTarget,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
day: u8,
|
||||
) *std.Build.Step.Compile {
|
||||
return b.addExecutable(.{
|
||||
.name = "aoc2025",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path(b.fmt("src/day_{d}.zig", .{day})),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1763283776,
|
||||
"narHash": "sha256-Y7TDFPK4GlqrKrivOcsHG8xSGqQx3A6c+i7novT85Uk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "50a96edd8d0db6cc8db57dab6bb6d6ee1f3dc49a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
40
flake.nix
Normal file
40
flake.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
description = "Zig Template";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
nativeBuildInputs = with pkgs; [
|
||||
zig
|
||||
zls
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [];
|
||||
in {
|
||||
devShells.default = pkgs.mkShell {inherit nativeBuildInputs buildInputs;};
|
||||
|
||||
packages.default = pkgs.stdenv.mkDerivation {
|
||||
pname = "template";
|
||||
version = "0.0.0";
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs =
|
||||
nativeBuildInputs
|
||||
++ [
|
||||
pkgs.zig.hook
|
||||
];
|
||||
inherit buildInputs;
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
5
src/day_1.zig
Normal file
5
src/day_1.zig
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue