Skip to content

Commit fd90fec

Browse files
author
g
committed
Add Nix CI support with GitHub-hosted runners
- Add flake.nix for reproducible builds using Cargo.toml version - Add Nix job to rust.yml workflow running parallel to existing tests - Update README.md with comprehensive Nix development instructions - Update AGENTS.md with separate Nix development commands - Supports Linux/macOS with platform-specific dependencies
1 parent 5118ad2 commit fd90fec

File tree

4 files changed

+112
-0
lines changed

4 files changed

+112
-0
lines changed

.github/workflows/rust.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,18 @@ jobs:
152152
153153
# Test with invalid WebSocket URL
154154
timeout 5s ./target/release/obs-cmd --ws-url invalid-url scene list || echo "Expected URL parsing failure"
155+
156+
nix:
157+
runs-on: ubuntu-latest
158+
steps:
159+
- uses: actions/checkout@v4
160+
- name: Install Nix
161+
uses: cachix/install-nix-action@v25
162+
with:
163+
nix_path: nixpkgs=channel:nixos-unstable
164+
- name: Check flake
165+
run: nix flake check
166+
- name: Build package
167+
run: nix build
168+
- name: Test dev shell
169+
run: nix develop --run "cargo test"

AGENTS.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ src/
7575
- **Scene Collections**: List, create, switch between scene collections
7676

7777
## Development Commands
78+
79+
### Traditional Rust Development
7880
```bash
7981
# Build and run
8082
cargo run # Build and run locally
@@ -94,6 +96,22 @@ cargo deny check # License and dependency checks
9496
cargo install --path . # Install locally
9597
```
9698

99+
### Nix Development
100+
```bash
101+
# Nix development (alternative)
102+
nix develop # Enter development shell
103+
nix build # Build reproducible package
104+
nix flake check # Validate flake configuration
105+
106+
# Run from Nix store
107+
./result/bin/obs-cmd --help
108+
109+
# Code quality (within nix develop)
110+
cargo fmt # Format code
111+
cargo clippy -- -D warnings # Lint with strict warnings
112+
cargo test # Run tests
113+
```
114+
97115
## Release Configuration
98116
- Optimized release profile in `Cargo.toml` with size optimizations
99117
- LTO enabled, single codegen unit, panic=abort for smaller binaries

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ RUST_LOG=debug obs-cmd info
326326

327327
## Development
328328

329+
### Traditional Rust Development
330+
329331
```bash
330332
# Build from source
331333
cargo build --release
@@ -340,6 +342,35 @@ cargo fmt
340342
cargo clippy -- -D warnings
341343
```
342344

345+
### Nix Support
346+
347+
This project supports Nix for reproducible builds and development environments.
348+
349+
#### Development with Nix
350+
351+
1. **Enter development shell**:
352+
```bash
353+
nix develop
354+
```
355+
356+
2. **Build project**:
357+
```bash
358+
nix build
359+
```
360+
361+
3. **Run from Nix store**:
362+
```bash
363+
./result/bin/obs-cmd --help
364+
```
365+
366+
#### Nix Flakes
367+
368+
This project uses Nix Flakes for reproducible builds. The flake provides:
369+
- `obs-cmd` package: Build release binary
370+
- `devShell`: Development environment with Rust tools and dependencies
371+
372+
See [flake.nix](./flake.nix) for full configuration.
373+
343374
## Donations
344375

345376
If you find this project helpful, please consider making a donation to support its development.

flake.nix

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
description = "A minimal command to control obs via obs-websocket";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = nixpkgs.legacyPackages.${system};
13+
# Extract version from Cargo.toml
14+
version = (pkgs.lib.importTOML ./Cargo.toml).package.version;
15+
in {
16+
packages.default = pkgs.rustPlatform.buildRustPackage {
17+
pname = "obs-cmd";
18+
inherit version;
19+
src = ./.;
20+
cargoLock = {
21+
lockFile = ./Cargo.lock;
22+
allowBuiltinFetchGit = true;
23+
};
24+
25+
# Build dependencies
26+
nativeBuildInputs = with pkgs; [ pkg-config ];
27+
buildInputs = with pkgs; [ openssl ]
28+
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
29+
pkgs.darwin.apple_sdk.frameworks.Security
30+
];
31+
};
32+
33+
devShells.default = pkgs.mkShell {
34+
buildInputs = with pkgs; [
35+
rustc
36+
cargo
37+
clippy
38+
rustfmt
39+
pkg-config
40+
openssl
41+
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
42+
pkgs.darwin.apple_sdk.frameworks.Security
43+
];
44+
45+
RUST_BACKTRACE = "1";
46+
};
47+
});
48+
}

0 commit comments

Comments
 (0)