Compare commits
3 Commits
d43b6901ae
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| d1b8be636a | |||
| 355124f672 | |||
| 1063ff337a |
@@ -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
|
||||
+521
-1
@@ -1 +1,521 @@
|
||||
/target
|
||||
# ---> Rust
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
# RustRover
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
# ---> Nix
|
||||
# Ignore build outputs from performing a nix-build or `nix build` command
|
||||
result
|
||||
result-*
|
||||
|
||||
# Ignore automatically generated direnv output
|
||||
.direnv
|
||||
|
||||
# ---> JetBrains
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
# ---> VisualStudioCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
# ---> VisualStudio
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
# but not Directory.Build.rsp, as it configures directory-level build defaults
|
||||
!Directory.Build.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
*.ncb
|
||||
*.aps
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
|
||||
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="uk.co.ben_gibson.git.link.SettingsState">
|
||||
<option name="host" value="e0f86390-1091-4871-8aeb-f534fbc99cf0" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+1
-4
@@ -1,10 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="EMPTY_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
|
||||
@@ -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
|
||||
@@ -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.
|
||||
Generated
-7
@@ -1,7 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "XXXadlibs"
|
||||
version = "0.1.0"
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "XXXadlibs"
|
||||
name = "sample-rust-app"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
Creative Commons Attribution-ShareAlike 4.0 International
|
||||
|
||||
<https://creativecommons.org/licenses/by-sa/4.0/>
|
||||
|
||||
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.
|
||||
@@ -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
|
||||
@@ -0,0 +1,163 @@
|
||||
# Rust Nix Flake Template
|
||||
|
||||
This template provides a reproducible Rust development environment using Nix flakes and the fenix toolchain.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```sh
|
||||
nix develop
|
||||
# or with direnv:
|
||||
direnv allow
|
||||
```
|
||||
|
||||
### Automatic Environment Setup
|
||||
|
||||
When you enter the devShell (via `direnv allow` or `nix develop`), the following happens automatically:
|
||||
|
||||
✓ **Git Repository**: Initializes `.git` if not present
|
||||
✓ **Rust Targets**: Automatically adds common embedded Rust targets (ARM Cortex-M, RISC-V)
|
||||
✓ **Cargo Paths**: Sets up `$HOME/.cargo/bin` in PATH for cargo-installed binaries
|
||||
✓ **Welcome Banner**: Displays available tools and quick commands
|
||||
|
||||
No manual setup needed! Just start coding.
|
||||
|
||||
## Quickstart
|
||||
|
||||
```sh
|
||||
nix flake init -t path:../flakes#rust
|
||||
nix develop
|
||||
cargo build
|
||||
```
|
||||
|
||||
## Embedded Rust Support
|
||||
|
||||
The devShell automatically installs common embedded Rust targets via `rustup`:
|
||||
|
||||
| Target | Platform | Use Case |
|
||||
|--------|----------|----------|
|
||||
| `thumbv6m-none-eabi` | ARM Cortex-M0/M0+ | RP2040 (Pico) |
|
||||
| `thumbv7em-none-eabihf` | ARM Cortex-M4F/M7F | STM32, nRF52840 |
|
||||
| `riscv32imc-unknown-none-elf` | RISC-V 32-bit | ESP32-C3 (basic) |
|
||||
| `riscv32imac-unknown-none-elf` | RISC-V 32-bit (atomic) | ESP32-C3 (advanced) |
|
||||
|
||||
**Note:** ESP32 Xtensa targets require espup or custom toolchains (see [esp-rs](https://github.com/esp-rs)).
|
||||
|
||||
## Flatpak Packaging
|
||||
|
||||
This template supports building Flatpak packages for your Rust application.
|
||||
|
||||
### Build Flatpak Package
|
||||
|
||||
1. Ensure you have `flatpak-builder` installed.
|
||||
2. Run:
|
||||
|
||||
```bash
|
||||
make flatpak-build
|
||||
```
|
||||
|
||||
This will use the manifest at `flatpak/app.flatpak.json` to build a Flatpak bundle in the `build-flatpak/` directory.
|
||||
|
||||
### Customize Manifest
|
||||
|
||||
Edit `flatpak/app.flatpak.json` to update app ID, runtime, build commands, or sources as needed for your project.
|
||||
|
||||
### Install/Run Flatpak Locally
|
||||
|
||||
You can install and run the built Flatpak locally:
|
||||
|
||||
```bash
|
||||
flatpak install --user build-flatpak/org.example.rustdevshell.flatpak
|
||||
flatpak run org.example.rustdevshell
|
||||
```
|
||||
|
||||
## Included Tools
|
||||
|
||||
| Tool | Purpose |
|
||||
|------|---------|
|
||||
| **cargo** | Rust package manager and build system |
|
||||
| **rustc** | Rust compiler |
|
||||
| **clippy** | Rust linter for catching common mistakes |
|
||||
| **rustfmt** | Rust code formatter |
|
||||
| **rust-analyzer** | Language server for IDE integration |
|
||||
| **rust-src** | Rust source code (for tools like rust-analyzer) |
|
||||
| **probe-rs** | Embedded debugger/flasher for ARM targets |
|
||||
| **espflash** | Flashing tool for ESP32 boards |
|
||||
| **openocd** | JTAG/SWD debugger for ARM and other targets |
|
||||
| **minicom** | Serial terminal for device output |
|
||||
| **elf2uf2-rs** | Convert ELF to UF2 format (RP2040) |
|
||||
| **picotool** | Pico-specific firmware operations |
|
||||
| **avrdude** | AVR microcontroller programmer |
|
||||
| **ravedude** | Rapid AVR development utility |
|
||||
|
||||
## Testing & Development Features
|
||||
|
||||
Build and testing tools:
|
||||
|
||||
- **cargo test** - Run unit and integration tests
|
||||
- **cargo clippy** - Lint code for common issues
|
||||
- **cargo fmt** - Format code consistently with rustfmt
|
||||
|
||||
**Example usage:**
|
||||
|
||||
```bash
|
||||
# Run tests
|
||||
cargo test
|
||||
|
||||
# Check code with clippy
|
||||
cargo clippy
|
||||
|
||||
# Format code
|
||||
cargo fmt
|
||||
|
||||
# Build for embedded target
|
||||
cargo build --target thumbv7em-none-eabihf --release
|
||||
```
|
||||
|
||||
## Project Layout
|
||||
|
||||
```
|
||||
Cargo.toml
|
||||
Cargo.lock
|
||||
src/
|
||||
└── main.rs (or lib.rs)
|
||||
Makefile
|
||||
.envrc
|
||||
flake.nix
|
||||
```
|
||||
|
||||
## Legacy Usage
|
||||
|
||||
If you do not use flakes, run:
|
||||
|
||||
```sh
|
||||
nix-shell
|
||||
```
|
||||
|
||||
## Project Metadata
|
||||
|
||||
See project.toml for example metadata.
|
||||
|
||||
## Helper Tools
|
||||
|
||||
- **`nix run .#dev-helper`** - Display tool versions and availability
|
||||
- **`cargo build`** - Build the project
|
||||
- **`cargo check`** - Quick syntax check without building
|
||||
- **`cargo doc --open`** - Generate and view documentation
|
||||
|
||||
## Packaging for nixpkgs
|
||||
|
||||
This template is structured for easy packaging in nixpkgs:
|
||||
|
||||
- All sources in `src/`
|
||||
- `flake.nix` provides a devShell and template
|
||||
- Add a `default.nix` or package expression as needed for nixpkgs
|
||||
|
||||
See [nixpkgs Rust packaging docs](https://nixos.org/manual/nixpkgs/stable/#rust) for more details.
|
||||
|
||||
## Customization
|
||||
|
||||
Edit `flake.nix` to:
|
||||
|
||||
- Add additional Rust targets via `rustup target add [target]`
|
||||
- Include additional cargo plugins
|
||||
- Add board-specific tools (e.g., stm32cube, nrfjprog)
|
||||
@@ -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.
|
||||
+29
@@ -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;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
{
|
||||
description = "A Nix-flake-based Rust development environment";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
fenix = {
|
||||
url = "github:nix-community/fenix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
inputs@{ self, ... }:
|
||||
let
|
||||
supportedSystems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
forEachSupportedSystem =
|
||||
f:
|
||||
inputs.nixpkgs.lib.genAttrs supportedSystems (
|
||||
system:
|
||||
f {
|
||||
pkgs = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
inputs.self.overlays.default
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
templates = {
|
||||
default = {
|
||||
path = ./.;
|
||||
description = "Rust dev environment using fenix; includes a skeletal Cargo project and packaged helper app";
|
||||
};
|
||||
};
|
||||
|
||||
overlays.default = _final: prev: {
|
||||
rustToolchain =
|
||||
with inputs.fenix.packages.${prev.stdenv.hostPlatform.system};
|
||||
combine (
|
||||
with stable;
|
||||
[
|
||||
clippy
|
||||
rustc
|
||||
cargo
|
||||
rustfmt
|
||||
rust-src
|
||||
]
|
||||
);
|
||||
};
|
||||
|
||||
devShells = forEachSupportedSystem (
|
||||
{ pkgs }:
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
rustToolchain
|
||||
git
|
||||
gnumake
|
||||
alejandra
|
||||
statix
|
||||
deadnix
|
||||
flatpak
|
||||
flatpak-builder
|
||||
openssl
|
||||
pkg-config
|
||||
cargo-deny
|
||||
cargo-edit
|
||||
cargo-watch
|
||||
cargo-generate
|
||||
rust-analyzer
|
||||
rustup
|
||||
# Embedded Rust tooling
|
||||
probe-rs-tools
|
||||
espflash
|
||||
openocd
|
||||
minicom
|
||||
# RP2040 UF2 workflows
|
||||
elf2uf2-rs
|
||||
picotool
|
||||
avrdude
|
||||
pkgsCross.avr.buildPackages.libc
|
||||
pkgsCross.avr.buildPackages.gcc
|
||||
ravedude
|
||||
pre-commit
|
||||
];
|
||||
|
||||
env = {
|
||||
# Required by rust-analyzer
|
||||
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
|
||||
};
|
||||
|
||||
shellHook = ''
|
||||
# Initialize git repository if not already present
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
echo "✓ Initialized git repository"
|
||||
fi
|
||||
|
||||
# Ensure user's Cargo-installed binaries are available
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
|
||||
if command -v rustup >/dev/null 2>&1; then
|
||||
echo "Ensuring common embedded Rust targets are available (idempotent)..."
|
||||
rustup target add thumbv6m-none-eabi >/dev/null 2>&1 || true # Cortex-M0/M0+ (RP2040)
|
||||
rustup target add thumbv7em-none-eabihf >/dev/null 2>&1 || true # Cortex-M4F/M7F (many STM32/nRF52)
|
||||
rustup target add riscv32imc-unknown-none-elf >/dev/null 2>&1 || true
|
||||
rustup target add riscv32imac-unknown-none-elf >/dev/null 2>&1 || true # ESP32-C3 class
|
||||
echo "Note: ESP32 Xtensa targets require espup/custom toolchains (see esp-rs)."
|
||||
fi
|
||||
echo "[rust-template] Welcome to the Rust dev shell!"
|
||||
echo "Tools: cargo, rustc, clippy, rustfmt, rust-analyzer, probe-rs, espflash, openocd, minicom, elf2uf2-rs, picotool, avrdude, ravedude"
|
||||
echo "Run 'cargo build' to build, or 'nix run .#dev-helper' for a tool summary."
|
||||
echo "See README.md for usage."
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
packages = forEachSupportedSystem (
|
||||
{ pkgs }:
|
||||
{
|
||||
# Build the skeletal Cargo project
|
||||
default = pkgs.rustPlatform.buildRustPackage {
|
||||
pname = "sample-rust-app";
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
};
|
||||
|
||||
devHelper = pkgs.writeShellScriptBin "dev-helper" ''
|
||||
echo "Rust toolchain available:"
|
||||
command -v cargo >/dev/null 2>&1 && cargo --version || true
|
||||
command -v rustc >/dev/null 2>&1 && rustc --version || true
|
||||
echo "This binary is built by Nix (packages.default)."
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
apps = forEachSupportedSystem (
|
||||
{ pkgs }:
|
||||
{
|
||||
default = {
|
||||
type = "app";
|
||||
program = pkgs.lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
||||
};
|
||||
dev-helper = {
|
||||
type = "app";
|
||||
program = pkgs.lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.devHelper;
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"app-id": "org.example.rustdevshell",
|
||||
"runtime": "org.freedesktop.Platform",
|
||||
"runtime-version": "23.08",
|
||||
"sdk": "org.freedesktop.Sdk",
|
||||
"command": "rustdevshell-app",
|
||||
"modules": [
|
||||
{
|
||||
"name": "rustdevshell-app",
|
||||
"buildsystem": "simple",
|
||||
"build-commands": [
|
||||
"cargo build --release"
|
||||
],
|
||||
"sources": [
|
||||
{
|
||||
"type": "dir",
|
||||
"path": ".."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
[project]
|
||||
name = "rust-template"
|
||||
description = "A reusable Nix flake template for Rust development."
|
||||
version = "0.1.0"
|
||||
authors = ["gooba42 <your@email>"]
|
||||
license = "MIT"
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
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."
|
||||
'';
|
||||
}
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
println!("Hello from Rust skeletal app. Edit src/main.rs to get started!");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#[test]
|
||||
fn test_sample() {
|
||||
assert_eq!(1, 1);
|
||||
}
|
||||
Reference in New Issue
Block a user