diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..93b82d6 --- /dev/null +++ b/.envrc @@ -0,0 +1,5 @@ +use flake + +if [ -f .env ]; then + dotenv .env +fi diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bc4a2e --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/target +/.direnv +/.env +/.yoi +/result diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..104af91 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "decodal" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..3c61fb9 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "decodal" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/devshell.nix b/devshell.nix new file mode 100644 index 0000000..f311596 --- /dev/null +++ b/devshell.nix @@ -0,0 +1,15 @@ +{ pkgs }: +pkgs.mkShell { + packages = with pkgs; [ + cargo + clippy + git + nixfmt + rustc + rustfmt + ]; + + shellHook = '' + echo "decodal dev shell" + ''; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..38a158c --- /dev/null +++ b/flake.lock @@ -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": 1781074563, + "narHash": "sha256-md8WlXOlfnIeHeOScMTTHFyf2d6iaTwPl2apR5EQ3P4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "9ae611a455b90cf061d8f332b977e387bda8e1ca", + "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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..fbd60b0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,38 @@ +{ + description = "Decodal - Deferred Constraint Data Language"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + decodal = pkgs.callPackage ./package.nix { }; + mkApp = name: description: { + type = "app"; + program = "${decodal}/bin/${name}"; + meta.description = description; + }; + in + { + packages.default = decodal; + packages.decodal = decodal; + + apps.default = mkApp "decodal" "Run Decodal"; + apps.decodal = mkApp "decodal" "Run Decodal"; + + checks.default = decodal; + + devShells.default = import ./devshell.nix { inherit pkgs; }; + } + ); +} diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..560f815 --- /dev/null +++ b/package.nix @@ -0,0 +1,54 @@ +{ + lib, + rustPlatform, +}: + +let + srcRoot = ./.; + srcRootString = toString srcRoot; + sourceFilter = + path: type: + let + pathString = toString path; + relPath = lib.removePrefix "${srcRootString}/" pathString; + baseName = baseNameOf pathString; + isExcludedTree = dir: relPath == dir || lib.hasPrefix "${dir}/" relPath; + in + !( + baseName == ".git" + || baseName == "target" + || baseName == "result" + || isExcludedTree ".yoi" + || isExcludedTree ".worktree" + ); +in +rustPlatform.buildRustPackage { + pname = "decodal"; + version = "0.1.0"; + + src = lib.cleanSourceWith { + src = srcRoot; + filter = sourceFilter; + }; + + cargoLock.lockFile = ./Cargo.lock; + + strictDeps = true; + + doInstallCheck = true; + installCheckPhase = '' + runHook preInstallCheck + + test -x "$out/bin/decodal" + "$out/bin/decodal" >/dev/null + + runHook postInstallCheck + ''; + + meta = { + description = "Deferred Constraint Data Language"; + license = lib.licenses.mit; + mainProgram = "decodal"; + platforms = lib.platforms.unix; + }; +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}