diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db8401a..6c5e895 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,6 +31,18 @@ When you submit your first pull request, you acknowledge that you agree to the t ## Development Setup +### Using Nix (Recommended for Linux) + +If you have [Nix](https://nixos.org/) installed, you can skip the manual setup below and simply run: + +```bash +nix develop +``` + +This will provide Node.js, Rust, and all necessary system libraries. + +### Manual Setup + Ensure you have the following dependencies installed: - Node.js (see `.node-version` for exact version) diff --git a/README.md b/README.md index 6d40c12..b5e02f6 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,16 @@ The app can be downloaded from the [releases page](https://github.com/zhom/donut See [CONTRIBUTING.md](CONTRIBUTING.md). +### Nix Support + +For a reproducible development environment (especially on Linux), you can use [Nix](https://nixos.org/): + +```bash +nix develop +# or if you use direnv +direnv allow +``` + ## Issues If you face any problems while using the application, please [open an issue](https://github.com/zhom/donutbrowser/issues). diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d1976e0 --- /dev/null +++ b/flake.lock @@ -0,0 +1,82 @@ +{ + "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": 1767767207, + "narHash": "sha256-Mj3d3PfwltLmukFal5i3fFt27L6NiKXdBezC1EBuZs4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5912c1772a44e31bf1c63c0390b90501e5026886", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1767926800, + "narHash": "sha256-x0n73J6ufD/EhDlVdcoAmF0OQHZ+b0a2cKDc8RZyt+o=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "499e9eed88ff9494b6604205b42847e847dfeb91", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "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 0000000..9061bf2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,66 @@ +{ + description = "Donut Browser Development Environment"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, flake-utils, rust-overlay, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + + # Rust toolchain + rustToolchain = pkgs.rust-bin.stable.latest.default.override { + extensions = [ "rust-src" "rust-analyzer" "clippy" "rustfmt" ]; + }; + + # System dependencies for Tauri on Linux + libraries = with pkgs; [ + webkitgtk_4_1 + gtk3 + cairo + gdk-pixbuf + glib + dbus + librsvg + libsoup_3 + ]; + + packages = with pkgs; [ + rustToolchain + nodejs_22 + pnpm + pkg-config + cargo-tauri + openssl + # App specific tools + biome + ] ++ libraries; + + in + { + devShells.default = pkgs.mkShell { + buildInputs = packages; + + shellHook = '' + export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath libraries}:$LD_LIBRARY_PATH + export XDG_DATA_DIRS=${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS + + echo "🍩 Donut Browser Dev Environment Loaded!" + echo "Node: $(node --version)" + echo "Rust: $(rustc --version)" + echo "Tauri CLI: $(cargo-tauri --version)" + ''; + }; + } + ); +}