aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2025-02-28 18:08:37 +0100
committerMel <mel@rnrd.eu>2025-02-28 18:10:18 +0100
commit8fe5a3fbcf39a72084aa44d1eb6f43df9f28707c (patch)
tree1860db373abace0588193529a57811affd294dd9
parent66adbe28c7b7e714b18c4c21def4a7470fdd79a9 (diff)
downloadcatskill-8fe5a3fbcf39a72084aa44d1eb6f43df9f28707c.tar.zst
catskill-8fe5a3fbcf39a72084aa44d1eb6f43df9f28707c.zip
Add Makefile and Nix build environment
Signed-off-by: Mel <mel@rnrd.eu>
-rw-r--r--.envrc3
-rw-r--r--.gitignore1
-rw-r--r--Makefile25
-rw-r--r--flake.lock27
-rw-r--r--flake.nix65
5 files changed, 121 insertions, 0 deletions
diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..197c0d5
--- /dev/null
+++ b/.envrc
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+use flake
diff --git a/.gitignore b/.gitignore
index 567609b..eb0b272 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
build/
+.direnv/
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..7099164
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,25 @@
+CFLAGS ?= -Wall -Werror -static -g -Og
+.DEFAULT_GOAL := all
+
+build/catskill: build src/catskill.csk
+ echo "No catskill compiler exists yet. Building empty file."
+ touch ./build/catskill
+
+build/catboot: build boot/catboot.c
+ $(CC) $(CFLAGS) -o ./build/catboot ./boot/catboot.c
+
+build:
+ mkdir -p ./build
+
+.PHONY: all run run-boot clean
+
+all: build/catskill build/catboot
+
+run: build/catskill
+ echo "Not implemented yet."
+
+run-boot: build/catboot
+ ./build/catboot
+
+clean:
+ rm -rf build/*
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..dfa8cf6
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,27 @@
+{
+ "nodes": {
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1739580444,
+ "narHash": "sha256-+/bSz4EAVbqz8/HsIGLroF8aNaO8bLRL7WfACN+24g4=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "8bb37161a0488b89830168b81c48aed11569cb93",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..9021e96
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,65 @@
+{
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+ };
+
+ outputs =
+ { self, nixpkgs }:
+ let
+ systems = [
+ "x86_64-linux"
+ "x86_64-darwin"
+ "aarch64-linux"
+ "aarch64-darwin"
+ "riscv64-linux"
+ ];
+
+ eachSystem =
+ f:
+ nixpkgs.lib.genAttrs systems (
+ system:
+ f {
+ inherit system;
+ pkgs = import nixpkgs { inherit system; };
+ }
+ );
+ in
+ {
+ devShells = eachSystem (
+ { system, pkgs }:
+ with pkgs;
+ let
+ stdenv = llvmPackages.stdenv;
+ shell = mkShell.override { inherit stdenv; };
+
+ musl-src = runCommand "musl-src" { } ''
+ mkdir $out
+ tar -xf ${musl.src} -C $out
+ '';
+
+ musl-static = musl.overrideAttrs (attrs: {
+ # this HAS the be fixed in upstream nixpkgs one day, right?
+ CFLAGS = attrs.CFLAGS ++ [
+ "-fdebug-prefix-map=/build=${musl-src}"
+ ];
+ seperateDebugInfo = false;
+ dontStrip = true;
+ });
+ in
+ {
+ default = shell {
+ buildInputs = [
+ musl-static
+ ];
+
+ nativeBuildInputs = [
+ pkg-config
+ gnumake
+ lldb
+ llvmPackages.bintools
+ ];
+ };
+ }
+ );
+ };
+}