Updated project details
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
---
|
||||
sessionId: session-260819-004513-s2vk
|
||||
---
|
||||
|
||||
# Requirements
|
||||
|
||||
### Overview & Goals
|
||||
Tailor `flake.nix`, development environments, and packaging configurations specifically to the `coldIron` project (a Rust + `iced` desktop GUI application). Prune obsolete template boilerplate and microcontroller/embedded targets, structure the package derivation to conform to standard `nixpkgs` packaging practices (with runtime library wrapping for `winit`/`wayland`/`x11`/`wgpu`), and retain Flatpak build capabilities with a project-tailored manifest.
|
||||
|
||||
### Scope
|
||||
- **In Scope**:
|
||||
- Pruning generic template outputs (`templates.default`, `devHelper` binary, embedded `rustup target add` hooks) from `flake.nix`.
|
||||
- Creating a clean, idiomatic `nixpkgs`-compatible package derivation (`buildRustPackage` with `makeBinaryWrapper` and `LD_LIBRARY_PATH` wrapping) so `coldIron` can be built with `nix build` and easily contributed/published to `nixpkgs`.
|
||||
- Retaining Flatpak build capabilities by maintaining `flatpak` and `flatpak-builder` in the development environment and updating `flatpak/app.flatpak.json` to target `coldIron`.
|
||||
- Aligning `project.toml`, `shell.nix`, `default.nix`, and `README.md` with the `coldIron` project metadata.
|
||||
- **Out of Scope**:
|
||||
- Modifying the application's UI logic or Rust code in `src/main.rs`.
|
||||
|
||||
# Technical Design
|
||||
|
||||
### Current Implementation
|
||||
- `flake.nix` contains leftover template outputs (`templates.default`), a helper script (`devHelper` / `dev-helper`), and shell hooks attempting to install embedded targets (ARM Cortex-M, RISC-V, ESP32).
|
||||
- `packages.default` builds a dummy `sample-rust-app` without wrapping required Linux GUI runtime libraries (`wayland`, `libxkbcommon`, `libGL`, `vulkan-loader`, `xorg` libraries).
|
||||
- `flatpak/app.flatpak.json` references placeholder IDs (`org.example.rustdevshell`) and binary name `rustdevshell-app` instead of `ColdIron`.
|
||||
- `project.toml` and `README.md` describe a generic reusable template rather than the `coldIron` application.
|
||||
|
||||
### Key Decisions
|
||||
- **Nixpkgs Standard Package (`package.nix` / `packages.default`)**:
|
||||
- Define the package derivation using `pkgs.rustPlatform.buildRustPackage` with `nativeBuildInputs = [ pkgs.pkg-config pkgs.makeBinaryWrapper ]` and `buildInputs = runtimeLibs`.
|
||||
- Wrap the installed binary (`$out/bin/ColdIron`) with `LD_LIBRARY_PATH` prefixing `runtimeLibs` so that `nix run` or `nix build` produces a standalone binary that starts up without Wayland/X11 dynamic library errors.
|
||||
- Structure `package.nix` (or `default.nix`) as a standard `callPackage` function suitable for inclusion in `nixpkgs` (e.g. `pkgs/by-name/co/coldiron/package.nix`).
|
||||
- **Streamlined devShell**:
|
||||
- Retain essential tools for Rust desktop GUI development: `rustToolchain` (fenix), `rust-analyzer`, `pkg-config`, `cargo-watch`, `cargo-edit`, `flatpak`, `flatpak-builder`, `alejandra`, and `runtimeLibs`.
|
||||
- Remove embedded microcontroller hooks (`rustup target add ...`) and embedded tools from the shell hook and tool summary.
|
||||
- **Flatpak Retention & Modernization**:
|
||||
- Retain `Makefile` target `flatpak-build` and `flatpak-builder` in the devShell.
|
||||
- Update `flatpak/app.flatpak.json` to specify `app-id: "io.github.gooba42.coldiron"`, command `ColdIron`, and clean module definitions.
|
||||
|
||||
### File Structure Changes
|
||||
- `flake.nix`: Prune template/embedded artifacts; configure `packages.default`, `apps.default`, and tailored `devShells.default`.
|
||||
- `package.nix` (or `default.nix`): Standard `nixpkgs` packaging expression using `callPackage` conventions.
|
||||
- `flatpak/app.flatpak.json`: Tailor manifest metadata and build command for `coldIron`.
|
||||
- `project.toml` & `README.md`: Update metadata and documentation to reflect the `coldIron` project.
|
||||
|
||||
# Delivery Steps
|
||||
|
||||
### ✓ Step 1: Create standard nixpkgs-compatible package derivation in package.nix and default.nix
|
||||
- Create `package.nix` as a `callPackage`-compatible function using `rustPlatform.buildRustPackage`.
|
||||
- Add `pkg-config` and `makeBinaryWrapper` to `nativeBuildInputs`, and include `runtimeLibs` in `buildInputs`.
|
||||
- Add `postInstall` hook using `wrapProgram` to prefix `LD_LIBRARY_PATH` with `runtimeLibs` so the GUI application can dynamically load Wayland/X11 libraries.
|
||||
- Update `default.nix` to call `package.nix`.
|
||||
|
||||
### ✓ Step 2: Update flake.nix packaging, applications, devShell, and prune template/embedded artifacts
|
||||
- Remove `templates` output and `devHelper` / `dev-helper`.
|
||||
- Configure `packages.default` (and `packages.coldiron`) to use `package.nix`.
|
||||
- Configure `apps.default` to run `$out/bin/ColdIron`.
|
||||
- Streamline `devShells.default` by removing embedded microcontroller targets (`rustup target add`) and updating the shell banner for `coldIron`.
|
||||
- Ensure Flatpak tools (`flatpak`, `flatpak-builder`) and formatting tools are present.
|
||||
|
||||
### ✓ Step 3: Update Flatpak manifest, project metadata, and documentation
|
||||
- Update `flatpak/app.flatpak.json` with app-id `io.github.gooba42.coldiron`, command `ColdIron`, graphics/wayland/x11 permissions, and build commands.
|
||||
- Update `project.toml` with `coldiron` project name and description.
|
||||
- Update `README.md` to describe the `coldIron` Iced application, dev workflow, Nix build/run, and Flatpak build.
|
||||
|
||||
### ✓ Step 4: Verify package build, dev shell, tests, and formatting
|
||||
- Verify `nix build` builds the wrapped `ColdIron` package.
|
||||
- Run `cargo check` and `cargo test` to verify codebase health.
|
||||
- Run `alejandra .` to ensure Nix files are formatted cleanly.
|
||||
Generated
+3964
File diff suppressed because it is too large
Load Diff
@@ -5,3 +5,4 @@ edition = "2021"
|
||||
description = "Learning Rust and Iced"
|
||||
|
||||
[dependencies]
|
||||
iced = "0.14.0"
|
||||
@@ -1,163 +1,95 @@
|
||||
# Rust Nix Flake Template
|
||||
# ColdIron
|
||||
|
||||
This template provides a reproducible Rust development environment using Nix flakes and the fenix toolchain.
|
||||
ColdIron is a desktop GUI application built with [Rust](https://www.rust-lang.org/) and the [Iced](https://iced.rs/) GUI framework.
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Nix Flakes (Recommended)
|
||||
|
||||
Enter the reproducible development shell with all Rust tools and Linux GUI runtime dependencies (`wayland`, `libxkbcommon`, `libGL`, `vulkan-loader`, `xorg` libraries):
|
||||
|
||||
```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
|
||||
Then run the application:
|
||||
|
||||
```sh
|
||||
nix flake init -t path:../flakes#rust
|
||||
nix develop
|
||||
cargo build
|
||||
cargo run
|
||||
```
|
||||
|
||||
## Embedded Rust Support
|
||||
### Running Tests & Quality Checks
|
||||
|
||||
The devShell automatically installs common embedded Rust targets via `rustup`:
|
||||
```sh
|
||||
# Run unit and integration tests
|
||||
cargo test
|
||||
|
||||
| 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) |
|
||||
# Run linter
|
||||
cargo clippy
|
||||
|
||||
**Note:** ESP32 Xtensa targets require espup or custom toolchains (see [esp-rs](https://github.com/esp-rs)).
|
||||
# Format code
|
||||
cargo fmt
|
||||
```
|
||||
|
||||
## Nix Packaging & nixpkgs Compatibility
|
||||
|
||||
`coldIron` provides an idiomatic, `nixpkgs`-compatible package expression in `package.nix` and `flake.nix`.
|
||||
|
||||
### Build with Nix
|
||||
|
||||
```sh
|
||||
nix build
|
||||
./result/bin/ColdIron
|
||||
```
|
||||
|
||||
Or run directly via flake:
|
||||
|
||||
```sh
|
||||
nix run
|
||||
```
|
||||
|
||||
### Contributing to nixpkgs
|
||||
|
||||
The `package.nix` derivation is designed for direct integration into `nixpkgs` (e.g. under `pkgs/by-name/co/coldiron/package.nix`). It uses `rustPlatform.buildRustPackage`, `makeBinaryWrapper`, and wraps the executable with runtime graphics and windowing libraries (`LD_LIBRARY_PATH`).
|
||||
|
||||
## Flatpak Packaging
|
||||
|
||||
This template supports building Flatpak packages for your Rust application.
|
||||
ColdIron includes Flatpak packaging configuration for containerized desktop distribution.
|
||||
|
||||
### Build Flatpak Package
|
||||
|
||||
1. Ensure you have `flatpak-builder` installed.
|
||||
1. Enter the dev shell (`nix develop`) which includes `flatpak` and `flatpak-builder`.
|
||||
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.
|
||||
This uses the manifest in `flatpak/app.flatpak.json` (Application ID: `io.github.gooba42.coldiron`) to build the application into `build-flatpak/`.
|
||||
|
||||
### Customize Manifest
|
||||
## Legacy Nix Shell
|
||||
|
||||
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:
|
||||
If you are not using Nix flakes, you can enter the development environment using:
|
||||
|
||||
```sh
|
||||
nix-shell
|
||||
```
|
||||
|
||||
## Project Metadata
|
||||
## Project Structure
|
||||
|
||||
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)
|
||||
```
|
||||
ColdIron/
|
||||
├── Cargo.toml # Rust package manifest
|
||||
├── Cargo.lock # Exact dependency lockfile
|
||||
├── flake.nix # Nix flake for devShell, packages, and apps
|
||||
├── package.nix # Nixpkgs-compatible buildRustPackage derivation
|
||||
├── default.nix # nix-build entrypoint calling package.nix
|
||||
├── shell.nix # Legacy nix-shell configuration
|
||||
├── flatpak/
|
||||
│ └── app.flatpak.json # Flatpak application manifest
|
||||
├── src/
|
||||
│ └── main.rs # Iced application entrypoint and UI
|
||||
└── tests/ # Integration tests
|
||||
```
|
||||
|
||||
+2
-29
@@ -1,29 +1,2 @@
|
||||
{ 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;
|
||||
};
|
||||
};
|
||||
}
|
||||
{pkgs ? import <nixpkgs> {}}:
|
||||
pkgs.callPackage ./package.nix {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
description = "A Nix-flake-based Rust development environment";
|
||||
description = "ColdIron - Learning Rust and Iced";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
@@ -9,17 +9,14 @@
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
inputs@{ self, ... }:
|
||||
let
|
||||
outputs = inputs @ {self, ...}: let
|
||||
supportedSystems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
forEachSupportedSystem =
|
||||
f:
|
||||
forEachSupportedSystem = f:
|
||||
inputs.nixpkgs.lib.genAttrs supportedSystems (
|
||||
system:
|
||||
f {
|
||||
@@ -31,21 +28,11 @@
|
||||
};
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
templates = {
|
||||
default = {
|
||||
path = ./.;
|
||||
description = "Rust dev environment using fenix; includes a skeletal Cargo project and packaged helper app";
|
||||
};
|
||||
};
|
||||
|
||||
in {
|
||||
overlays.default = _final: prev: {
|
||||
rustToolchain =
|
||||
with inputs.fenix.packages.${prev.stdenv.hostPlatform.system};
|
||||
rustToolchain = with inputs.fenix.packages.${prev.stdenv.hostPlatform.system};
|
||||
combine (
|
||||
with stable;
|
||||
[
|
||||
with stable; [
|
||||
clippy
|
||||
rustc
|
||||
cargo
|
||||
@@ -53,13 +40,45 @@
|
||||
rust-src
|
||||
]
|
||||
);
|
||||
coldiron = prev.callPackage ./package.nix {};
|
||||
};
|
||||
|
||||
packages = forEachSupportedSystem (
|
||||
{pkgs}: {
|
||||
default = pkgs.callPackage ./package.nix {};
|
||||
coldiron = pkgs.callPackage ./package.nix {};
|
||||
}
|
||||
);
|
||||
|
||||
apps = forEachSupportedSystem (
|
||||
{pkgs}: {
|
||||
default = {
|
||||
type = "app";
|
||||
program = pkgs.lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
||||
};
|
||||
coldiron = {
|
||||
type = "app";
|
||||
program = pkgs.lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.coldiron;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
devShells = forEachSupportedSystem (
|
||||
{ pkgs }:
|
||||
{
|
||||
{pkgs}: let
|
||||
runtimeLibs = with pkgs; [
|
||||
wayland
|
||||
libxkbcommon
|
||||
libGL
|
||||
vulkan-loader
|
||||
libx11
|
||||
libxcursor
|
||||
libxrandr
|
||||
libxi
|
||||
];
|
||||
in {
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
packages = with pkgs;
|
||||
[
|
||||
rustToolchain
|
||||
git
|
||||
gnumake
|
||||
@@ -73,30 +92,20 @@
|
||||
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
|
||||
];
|
||||
]
|
||||
++ runtimeLibs;
|
||||
|
||||
env = {
|
||||
# Required by rust-analyzer
|
||||
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
|
||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath runtimeLibs;
|
||||
};
|
||||
|
||||
shellHook = ''
|
||||
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath runtimeLibs}:$LD_LIBRARY_PATH"
|
||||
|
||||
# Initialize git repository if not already present
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
@@ -106,55 +115,11 @@
|
||||
# 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."
|
||||
echo "[ColdIron] Welcome to the ColdIron development shell!"
|
||||
echo "Commands: 'cargo run' to start GUI, 'cargo test' to run tests, 'make flatpak-build' for Flatpak."
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,15 +1,31 @@
|
||||
{
|
||||
"app-id": "org.example.rustdevshell",
|
||||
"app-id": "io.github.gooba42.coldiron",
|
||||
"runtime": "org.freedesktop.Platform",
|
||||
"runtime-version": "23.08",
|
||||
"runtime-version": "24.08",
|
||||
"sdk": "org.freedesktop.Sdk",
|
||||
"command": "rustdevshell-app",
|
||||
"sdk-extensions": [
|
||||
"org.freedesktop.Sdk.Extension.rust-stable"
|
||||
],
|
||||
"command": "ColdIron",
|
||||
"finish-args": [
|
||||
"--share=ipc",
|
||||
"--socket=fallback-x11",
|
||||
"--socket=wayland",
|
||||
"--device=dri"
|
||||
],
|
||||
"build-options": {
|
||||
"append-path": "/usr/lib/sdk/rust-stable/bin",
|
||||
"env": {
|
||||
"CARGO_HOME": "/run/build/coldiron/cargo"
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"name": "rustdevshell-app",
|
||||
"name": "coldiron",
|
||||
"buildsystem": "simple",
|
||||
"build-commands": [
|
||||
"cargo build --release"
|
||||
"cargo build --release",
|
||||
"install -Dm755 target/release/ColdIron /app/bin/ColdIron"
|
||||
],
|
||||
"sources": [
|
||||
{
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
{
|
||||
lib,
|
||||
rustPlatform,
|
||||
makeBinaryWrapper,
|
||||
pkg-config,
|
||||
wayland,
|
||||
libxkbcommon,
|
||||
libGL,
|
||||
vulkan-loader,
|
||||
libx11,
|
||||
libxcursor,
|
||||
libxrandr,
|
||||
libxi,
|
||||
}: let
|
||||
runtimeLibs = [
|
||||
wayland
|
||||
libxkbcommon
|
||||
libGL
|
||||
vulkan-loader
|
||||
libx11
|
||||
libxcursor
|
||||
libxrandr
|
||||
libxi
|
||||
];
|
||||
in
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "coldiron";
|
||||
version = "0.1.0";
|
||||
|
||||
src = lib.cleanSource ./.;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
makeBinaryWrapper
|
||||
];
|
||||
|
||||
buildInputs = runtimeLibs;
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram "$out/bin/ColdIron" \
|
||||
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeLibs}"
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "ColdIron - Learning Rust and Iced desktop GUI application";
|
||||
homepage = "https://github.com/gooba42/coldIron";
|
||||
license = licenses.mit;
|
||||
mainProgram = "ColdIron";
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "rust-template"
|
||||
description = "A reusable Nix flake template for Rust development."
|
||||
name = "coldiron"
|
||||
description = "ColdIron - Learning Rust and Iced desktop GUI application"
|
||||
version = "0.1.0"
|
||||
authors = ["gooba42 <your@email>"]
|
||||
license = "MIT"
|
||||
|
||||
@@ -1,15 +1,33 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
{pkgs ? import <nixpkgs> {}}: let
|
||||
runtimeLibs = with pkgs; [
|
||||
wayland
|
||||
libxkbcommon
|
||||
libGL
|
||||
vulkan-loader
|
||||
libx11
|
||||
libxcursor
|
||||
libxrandr
|
||||
libxi
|
||||
];
|
||||
in
|
||||
pkgs.mkShell {
|
||||
buildInputs = [
|
||||
buildInputs =
|
||||
[
|
||||
pkgs.rustc
|
||||
pkgs.cargo
|
||||
pkgs.rustfmt
|
||||
pkgs.clippy
|
||||
pkgs.rust-analyzer
|
||||
];
|
||||
pkgs.pkg-config
|
||||
]
|
||||
++ runtimeLibs;
|
||||
|
||||
env = {
|
||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath runtimeLibs;
|
||||
};
|
||||
|
||||
shellHook = ''
|
||||
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath runtimeLibs}:$LD_LIBRARY_PATH"
|
||||
echo "[shell.nix] Legacy shell for Rust dev. Use 'nix develop' for full flake support."
|
||||
'';
|
||||
}
|
||||
|
||||
+19
-2
@@ -1,3 +1,20 @@
|
||||
fn main() {
|
||||
println!("Hello from Rust skeletal app. Edit src/main.rs to get started!");
|
||||
use iced::widget::{button, text};
|
||||
use iced::Element;
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
iced::run(update, view)
|
||||
}
|
||||
fn update(counter: &mut u64, message: Message) {
|
||||
match message {
|
||||
Message::Increment => *counter += 1,
|
||||
}
|
||||
|
||||
}
|
||||
#[derive(Debug, Clone)]
|
||||
enum Message {
|
||||
Increment,
|
||||
}
|
||||
|
||||
fn view(counter: &u64) -> Element<'_, Message> {
|
||||
button(text(counter)).on_press(Message::Increment).into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user