diff options
| -rw-r--r-- | .envrc | 5 | ||||
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | README.md | 17 | ||||
| -rw-r--r-- | flake.lock | 85 | ||||
| -rw-r--r-- | flake.nix | 54 | ||||
| -rw-r--r-- | treefmt.nix | 7 |
6 files changed, 169 insertions, 0 deletions
@@ -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 @@ -1,2 +1,3 @@ /build +/result /tests/tmp @@ -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; +} |
