aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-08-31 16:41:47 +0900
committernsfisis <nsfisis@gmail.com>2025-08-31 16:41:47 +0900
commit54699e921e23a684c711773b123c1bcfecd91ae0 (patch)
tree606ac78296ecc82b6ab215931951073c9188c1c3
parentc84b5ccd48ca188f439cde3e5cdac95d26ed0be3 (diff)
downloadducc-54699e921e23a684c711773b123c1bcfecd91ae0.tar.gz
ducc-54699e921e23a684c711773b123c1bcfecd91ae0.tar.zst
ducc-54699e921e23a684c711773b123c1bcfecd91ae0.zip
feat: add Nix support
-rw-r--r--.envrc5
-rw-r--r--.gitignore1
-rw-r--r--README.md17
-rw-r--r--flake.lock85
-rw-r--r--flake.nix54
-rw-r--r--treefmt.nix7
6 files changed, 169 insertions, 0 deletions
diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..2fe7020
--- /dev/null
+++ b/.envrc
@@ -0,0 +1,5 @@
+# shellcheck shell=bash
+if ! has nix_direnv_version || ! nix_direnv_version 3.1.0; then
+ source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.1.0/direnvrc" "sha256-yMJ2OVMzrFaDPn7q8nCBZFRYpL/f0RcHzhmw/i6btJM="
+fi
+use flake
diff --git a/.gitignore b/.gitignore
index fbd12ac..0291275 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
/build
+/result
/tests/tmp
diff --git a/README.md b/README.md
index 14822d2..3fe06f5 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,23 @@ Ducc, Decidedly Unimplemented C compiler, is a toy C compiler.
* [just](https://github.com/casey/just)
+### Optional: Nix support
+
+This project includes Nix support with flake.
+
+To build:
+
+```
+$ nix build
+```
+
+To develop:
+
+```
+$ nix develop
+```
+
+
## Build
```
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..5316e16
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,85 @@
+{
+ "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": 1756542300,
+ "narHash": "sha256-tlOn88coG5fzdyqz6R93SQL5Gpq+m/DsWpekNFhqPQk=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "d7600c775f877cd87b4f5a831c28aa94137377aa",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs",
+ "systems": "systems",
+ "treefmt-nix": "treefmt-nix"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1680978846,
+ "narHash": "sha256-Gtqg8b/v49BFDpDetjclCYXm8mAnTrUzR0JnE2nv5aw=",
+ "owner": "nix-systems",
+ "repo": "x86_64-linux",
+ "rev": "2ecfcac5e15790ba6ce360ceccddb15ad16d08a8",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "x86_64-linux",
+ "type": "github"
+ }
+ },
+ "treefmt-nix": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1755934250,
+ "narHash": "sha256-CsDojnMgYsfshQw3t4zjRUkmMmUdZGthl16bXVWgRYU=",
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "rev": "74e1a52d5bd9430312f8d1b8b0354c92c17453e5",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..385fcc1
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,54 @@
+{
+ description = "Decidedly Unimplemented C compiler, a toy C compiler";
+
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
+
+ systems.url = "github:nix-systems/x86_64-linux";
+
+ flake-utils = {
+ url = "github:numtide/flake-utils";
+ inputs.systems.follows = "systems";
+ };
+
+ treefmt-nix = {
+ url = "github:numtide/treefmt-nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ };
+
+ outputs =
+ {
+ self,
+ nixpkgs,
+ flake-utils,
+ treefmt-nix,
+ ...
+ }:
+ flake-utils.lib.eachDefaultSystem (
+ system:
+ let
+ pkgs = import nixpkgs { inherit system; };
+ treefmt = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
+ in
+ {
+ packages.default = pkgs.stdenv.mkDerivation {
+ pname = "ducc";
+ version = "0.1.0";
+ src = ./.;
+ installPhase = ''
+ mkdir -p $out/bin
+ cp build/ducc $out/bin
+ '';
+ };
+
+ devShells.default = pkgs.mkShell {
+ packages = [
+ pkgs.just
+ ];
+ };
+
+ formatter = treefmt.config.build.wrapper;
+ }
+ );
+}
diff --git a/treefmt.nix b/treefmt.nix
new file mode 100644
index 0000000..b32553e
--- /dev/null
+++ b/treefmt.nix
@@ -0,0 +1,7 @@
+{ pkgs, ... }:
+{
+ projectRootFile = "flake.nix";
+
+ programs.clang-format.enable = true;
+ programs.nixfmt.enable = true;
+}