diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f02fd20 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# EditorConfig for Rust template +root = false +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..ea35353 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +# Direnv configuration for Nix flakes +use flake \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..93d696f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,8 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..a94fcb9 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,9 @@ +# Contributing + +Thank you for considering contributing! + +- Please follow the project coding style and directory structure. +- Submit issues or pull requests for bugs, features, or improvements. +- Add tests for new features where possible. +- Ensure your code builds and passes tests before submitting. +- Contributions are licensed under CC BY-SA 4.0. diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..3a7b7a8 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "r_eom" +description = "R_EoM library with a demo platform for testing and showcasing its features" +version = "0.1.0" +edition = "2021" + +[lib] +name = "r_eom" +path = "src/lib.rs" + +[[bin]] +name = "r_eom_demo" +path = "src/main.rs" + +[dependencies] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..eae17d3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,17 @@ +Creative Commons Attribution-ShareAlike 4.0 International + + + +You are free to: + +- Share — copy and redistribute the material in any medium or format +- Adapt — remix, transform, and build upon the material for any purpose, even commercially. + +Under the following terms: + +- Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. +- ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. + +No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. + +See the full license at the link above. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..efd5f56 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +build: + cargo build + +run: + cargo run + +test: + cargo test + +clean: + cargo clean + +.PHONY: build run test clean + + +# Flatpak build target +.PHONY: flatpak-build +flatpak-build: + flatpak-builder --force-clean build-flatpak flatpak/app.flatpak.json diff --git a/README.md b/README.md index 28f68ee..880bcbd 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,46 @@ # R_EoM +R_EoM is a library with a demo platform for testing and showcasing its features. + +## Project Structure + +- `src/lib.rs`: The core library logic. +- `src/main.rs`: The demo platform application. +- `tests/`: Integration tests. +- `flatpak/`: Flatpak manifest for the demo platform. + +## Getting Started + +### Prerequisites + +- Rust and Cargo +- (Optional) Flatpak and Flatpak Builder + +### Building and Running + +To build the project: + +```bash +cargo build +``` + +To run the demo platform: + +```bash +cargo run --bin r_eom_demo +``` + +To run tests: + +```bash +cargo test +``` + +### Flatpak + +To build the Flatpak: + +```bash +make flatpak-build +``` + diff --git a/agents.md b/agents.md new file mode 100644 index 0000000..1bb9395 --- /dev/null +++ b/agents.md @@ -0,0 +1,16 @@ +# Coding Agent Instructions + +This project is intended for educational purposes. To support this, please adhere to the following guidelines: + +## Allowed Actions +- **Environment Maintenance:** Feel free to update Nix flakes, shell configurations, or other environment-related setup. +- **Project Housekeeping:** Maintain a standard project layout, keep `README.md` up-to-date, and clean up temporary or build-related files. +- **Documentation:** Add comments, manage project documentation, and add links to relevant external resources. + +## Restricted Actions +- **Source Code Editing:** You are NOT allowed to edit the executable source code (`src/` directory) except to improve documentation.. +- **Code Generation:** Do not provide example code unless explicitly asked by the user. + +## Communication Guidelines +- **Educational Focus:** When asked about code, prioritize explaining the concepts and providing advice over writing code. +- **Documentation Links:** Always include links to official language or library documentation for references. diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..9bfc4d3 --- /dev/null +++ b/default.nix @@ -0,0 +1,29 @@ +{ pkgs }: +let + lib = pkgs.lib; + templateName = builtins.baseNameOf (toString ./.); +in +{ + ${templateName} = pkgs.stdenvNoCC.mkDerivation { + pname = templateName; + version = "0.1.0"; + src = ./.; + dontBuild = true; + installPhase = '' + mkdir -p $out/share/${templateName} + if [ -d src ]; then + cp -r src $out/share/${templateName}/ + fi + for f in README.md project.toml flake.nix default.nix shell.nix Makefile .editorconfig .gitignore; do + if [ -f "$f" ]; then + cp "$f" $out/share/${templateName}/ + fi + done + ''; + meta = with lib; { + description = "Template project: ${templateName}"; + license = licenses.unfreeRedistributable; + platforms = platforms.all; + }; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..61fb7eb --- /dev/null +++ b/flake.lock @@ -0,0 +1,66 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1784017020, + "narHash": "sha256-49WO85egjNtN1vMgJ3zUjDh5IqO+ou4zZY80WQ6EKGg=", + "owner": "nix-community", + "repo": "fenix", + "rev": "fa2a0be0f712d7147d1677d33d15ea7b0589cdb4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1784007870, + "narHash": "sha256-djcLt/JJphyNt4eDY9XTly+/WbCK5lqWq9lSgCmJkkQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18b9261cb3294b6d2a06d03f96872827b8fe2698", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1783975201, + "narHash": "sha256-oyHWTfKWk06nTynCO8ByEAx/KEARvOOyTVnwinOmK3Q=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "63a6f0d4bcfd3bbcf36383fcbcbcd93456ed1653", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flatpak/app.flatpak.json b/flatpak/app.flatpak.json new file mode 100644 index 0000000..88de620 --- /dev/null +++ b/flatpak/app.flatpak.json @@ -0,0 +1,22 @@ +{ + "app-id": "org.reom.Demo", + "runtime": "org.freedesktop.Platform", + "runtime-version": "23.08", + "sdk": "org.freedesktop.Sdk", + "command": "r_eom_demo", + "modules": [ + { + "name": "r_eom", + "buildsystem": "simple", + "build-commands": [ + "cargo build --release" + ], + "sources": [ + { + "type": "dir", + "path": ".." + } + ] + } + ] +} \ No newline at end of file diff --git a/project.toml b/project.toml new file mode 100644 index 0000000..c307b6d --- /dev/null +++ b/project.toml @@ -0,0 +1,6 @@ +[project] +name = "r_eom" +description = "R_EoM library with a demo platform for testing and showcasing its features" +version = "0.1.0" +authors = ["gooba42 "] +license = "MIT" diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..c0c1627 --- /dev/null +++ b/shell.nix @@ -0,0 +1,15 @@ +{ + pkgs ? import { }, +}: +pkgs.mkShell { + buildInputs = [ + pkgs.rustc + pkgs.cargo + pkgs.rustfmt + pkgs.clippy + pkgs.rust-analyzer + ]; + shellHook = '' + echo "[shell.nix] Legacy shell for Rust dev. Use 'nix develop' for full flake support." + ''; +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..2118276 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,18 @@ +//! R_EoM library +//! +//! This library provides the core logic for the R_EoM project. + +/// Returns a greeting message from the R_EoM library. +pub fn greeting() -> String { + "Hello from the R_EoM library!".to_string() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_greeting() { + assert_eq!(greeting(), "Hello from the R_EoM library!"); + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..afc25ba --- /dev/null +++ b/src/main.rs @@ -0,0 +1,7 @@ +use r_eom; + +fn main() { + println!("R_EoM Demo Platform"); + println!("-------------------"); + println!("{}", r_eom::greeting()); +} diff --git a/tests/sample_test.rs b/tests/sample_test.rs new file mode 100644 index 0000000..b08611c --- /dev/null +++ b/tests/sample_test.rs @@ -0,0 +1,6 @@ +use r_eom; + +#[test] +fn test_library_greeting() { + assert_eq!(r_eom::greeting(), "Hello from the R_EoM library!"); +}