From 7aa55883e2d7c41a577c1865412e92cbacd32bcc Mon Sep 17 00:00:00 2001 From: Pujit Mehrotra Date: Tue, 18 Mar 2025 11:15:57 -0400 Subject: [PATCH] add nix flake for development (#1233) ## Summary by CodeRabbit - **Chores** - Refined repository settings to auto-exclude environment and build-related files. - Introduced a new configuration that streamlines local development and displays key tool versions on setup. - **Documentation** - Expanded contribution guidelines with a dedicated developer resources section linking to guides on development practices and repository structure. - Updated workflow instructions to better assist developers in setting up their environment, especially for those using Nix. --- .gitignore | 6 ++++ CONTRIBUTING.md | 8 +++++ api/docs/developer/workflows.md | 2 ++ flake.lock | 61 +++++++++++++++++++++++++++++++++ flake.nix | 47 +++++++++++++++++++++++++ readme.md | 13 ++++++- 6 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index df5cd377e..cf3ab575b 100644 --- a/.gitignore +++ b/.gitignore @@ -95,3 +95,9 @@ fb_keepalive # pnpm store .pnpm-store + +# Nix +result +result-* +.direnv/ +.envrc diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 41d35f297..0d688ac12 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,6 +58,14 @@ We use GitHub to host code, to track issues and feature requests, as well as acc **Note:** Direct pushes to the main branch are not allowed. All changes must go through the PR process. +## Developer Documentation + +For detailed information about development workflows, repository organization, and other technical details, please refer to our developer documentation: + +- [Development Guide](api/docs/developer/development.md) - Setup, building, and debugging instructions +- [Development Workflows](api/docs/developer/workflows.md) - Detailed workflows for local development, building, and deployment +- [Repository Organization](api/docs/developer/repo-organization.md) - High-level architecture and project structure + ## Bug Reports and Feature Requests We use GitHub issues to track bugs and feature requests: diff --git a/api/docs/developer/workflows.md b/api/docs/developer/workflows.md index 96f391705..f5325341a 100644 --- a/api/docs/developer/workflows.md +++ b/api/docs/developer/workflows.md @@ -215,3 +215,5 @@ unraid-api --help 5. Test your changes: `pnpm test` 6. Deploy to a development server: `pnpm unraid:deploy ` 7. Verify your changes on the Unraid server + +If using nix, run `nix develop` from the root of the repo before Step 2. diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..5ed1735b1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1742069588, + "narHash": "sha256-C7jVfohcGzdZRF6DO+ybyG/sqpo1h6bZi9T56sxLy+k=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c80f6a7e10b39afcc1894e02ef785b1ad0b0d7e5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..b26745256 --- /dev/null +++ b/flake.nix @@ -0,0 +1,47 @@ +{ + description = "Unraid Connect Monorepo Development Environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + # Node.js and pnpm + nodejs_22 + nodePackages.pnpm + + # Development tools + just + git + + # libvirt (for development) + libvirt + + # Docker (for development) + docker + ]; + + shellHook = '' + echo "🚀 Unraid API Development Environment" + echo "" + echo "✔︎ BASH version: $BASH_VERSION" + echo "✔︎ Node.js version: $(node --version)" + echo "✔︎ pnpm version: $(pnpm --version)" + echo "✔︎ just version: $(just --version)" + echo "✔︎ git version: $(git --version)" + echo "✔︎ docker version: $(docker --version)" + echo "✔︎ libvirt version: $(virsh --version)" + echo "" + ''; + }; + } + ); +} \ No newline at end of file diff --git a/readme.md b/readme.md index 29c16cc4b..3cb5061ec 100644 --- a/readme.md +++ b/readme.md @@ -130,7 +130,8 @@ Once you have your key pair, add your public SSH key to your Unraid server: Navigate to Plugins->Install and install the local plugin file that is output to the console. -## View other workflows (local dev, etc.) in the [Developer Workflows](./api/docs/developer/workflows.md) +> [!TIP] +> View other workflows (local dev, etc.) in the [Developer Workflows](./api/docs/developer/workflows.md)

(back to top)

@@ -158,6 +159,16 @@ See the [open issues](https://github.com/unraid/api/issues) for a full list of p ## Contributing +For a complete guide on contributing to the project, including our code of conduct and development process, please see our [Contributing Guide](./CONTRIBUTING.md). Please read this before contributing. + +### Developer Documentation + +For more information about development workflows, repository organization, and other technical details, please refer to the developer documentation inside this repository: + +* [Development Guide](./api/docs/developer/development.md) - Setup, building, and debugging instructions +* [Development Workflows](./api/docs/developer/workflows.md) - Detailed workflows for local development, building, and deployment +* [Repository Organization](./api/docs/developer/repo-organization.md) - High-level architecture and project structure + ### Work Intent Process Before starting development work on this project, you must submit a Work Intent and have it approved by a core developer. This helps prevent duplicate work and ensures changes align with the project's goals.