Skip to content

Commit

Permalink
setting up dev environment
Browse files Browse the repository at this point in the history
  • Loading branch information
steinerkelvin committed May 25, 2024
1 parent 7bcb632 commit 50e18c4
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 4 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.nix]
indent_size = 2
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
29 changes: 29 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Benda CI

on:
pull_request:
push:
branches: [master]

jobs:
checks:
name: Nix and Rust checks
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- uses: DeterminateSystems/magic-nix-cache-action@main

- name: Check flake.lock
uses: DeterminateSystems/flake-checker-action@main
with:
fail-mode: true

- name: Clippy
run: nix develop -c cargo clippy

- name: Check Rust formatting
run: nix develop -c cargo fmt --check
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/tmp/
/.direnv/

# Generated by Cargo
# will have compiled files and executables
debug/
target/
/debug/
/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
/Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"rust-lang.rust-analyzer"
]
}
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"cSpell.words": [
"benda",
"Clippy",
"nixpkgs",
"Numba"
]
}
}
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
resolver = "2"
members = ["crates/*"]
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,19 @@ def sum_tree(tree: Tree) -> u24:
class Leaf2:
value: int
```

## Development

- Install Nix with [Determinate Nix Installer]

```sh
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
```

- You can run `nix develop` to enter a shell with the dependencies installed.

- You can use [`direnv`][direnv] to automatically load the environment when you
enter the project directory.

[Determinate Nix Installer]: https://install.determinate.systems
[direnv]: https://direnv.net
6 changes: 6 additions & 0 deletions crates/placeholder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "placeholder"
version = "0.1.0"
edition = "2021"

[dependencies]
3 changes: 3 additions & 0 deletions crates/placeholder/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
163 changes: 163 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
description = "kindelia-node";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
naersk.url = "github:nix-community/naersk";
};

outputs = { self, nixpkgs, rust-overlay, flake-utils, naersk }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rust_toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;

nativeBuildInputs = [
pkgs.git
# Build toolchain
pkgs.pkg-config
pkgs.clang
rust_toolchain
# Python
pkgs.python312
];

dev_packages = [
# GitHub Actions runner
pkgs.act
# Build tools
pkgs.maturin
# Python
pkgs.pyenv
];

naersk' = pkgs.callPackage naersk {
cargo = rust_toolchain;
rustc = rust_toolchain;
};
in
{
devShells.default = pkgs.stdenvNoCC.mkDerivation {
name = "shell";
inherit nativeBuildInputs;
buildInputs = dev_packages;
};

packages.default = naersk'.buildPackage {
inherit nativeBuildInputs;
src = ./.;
};
}
);
}
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
profile = "minimal"
channel = "nightly-2024-05-24"
components = ["rustfmt", "clippy"]
9 changes: 9 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
max_width = 80
tab_spaces = 4

newline_style = "Unix"

# Unstable features
unstable_features = true
imports_granularity = "Module"
group_imports = "StdExternalCrate"

0 comments on commit 50e18c4

Please sign in to comment.