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/.gitignore b/.gitignore index 5bf4dbb..314e65f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,7 @@ vite.config.ts.timestamp-* # IDE: .vscode + +# Nix +result +.direnv \ No newline at end of file diff --git a/README.md b/README.md index d596af4..d95093e 100644 --- a/README.md +++ b/README.md @@ -144,33 +144,48 @@ The compiled binaries will be available in: - **macOS**: `src-tauri/target/release/bundle/dmg/` - **Windows**: `src-tauri/target/release/bundle/` -## Building with Nix +## Building and Development with Nix -[Nix](https://nixos.org/) is a powerful package manager that provides clean, reproducible builds. You can use Nix to build picoforge painlessly. +[Nix](https://nixos.org/) provides developers with a complete and consistent development environment. + +You can use Nix to build and develop picoforge painlessly. ### 1. Install Nix -Follow the [official installation guide](https://nixos.org/download/#download-nix). +Follow the [Installation Guide](https://nixos.org/download/#download-nix) and [NixOS Wiki](https://wiki.nixos.org/wiki/Flakes#Setup) to install Nix and enable Flakes. -### 2. Download the package definition +### 2. Build & Run + +You can build and run PicoForge with a single command: ```bash -curl -O https://raw.githubusercontent.com/librekeys/picoforge/main/package.nix +nix run github:librekeys/picoforge ``` -### 3. Build the project - -Run the following command in the directory containing `package.nix`: +Or simply build it and link to the current directory: ```bash -nix-build -E 'with import {}; callPackage ./package.nix { }' +nix build github:librekeys/picoforge ``` -The compiled binary will be available at: `result/bin/picoforge` +### 3. Develop +Alternatively, you can enter a developement environement with all the required dependencies by running: -### 4. Nix-shell developement environment -Alternatively, you can use the shell.nix file that is at the root of the repository to enter a developement environement with all the required dependencies by simply running `nix-shell` -Then you can build from source and run the application with `deno task tauri dev`. +```bash +nix develop github:librekeys/picoforge +``` + +Or use the shell.nix file that is at the root of the repository: + +```bash +nix-shell +``` + +Then you can build from source and run the application with: + +```bash +deno task tauri dev +``` ## Project Structure diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..57a4201 --- /dev/null +++ b/flake.lock @@ -0,0 +1,113 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1769064677, + "narHash": "sha256-Upa108vGOlaOBGQTmmLEKuWekBm519u42A/oYSjTs+4=", + "owner": "nix-community", + "repo": "fenix", + "rev": "439e81e0b40781e16c444ca1c7fcd1cf8c5c406c", + "type": "github" + }, + "original": { + "id": "fenix", + "type": "indirect" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1768135262, + "narHash": "sha256-PVvu7OqHBGWN16zSi6tEmPwwHQ4rLPU9Plvs8/1TUBY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "80daad04eddbbf5a4d883996a73f3f542fa437ac", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1768886240, + "narHash": "sha256-C2TjvwYZ2VDxYWeqvvJ5XPPp6U7H66zeJlRaErJKoEM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "80e4adbcf8992d3fd27ad4964fbb84907f9478b0", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1765674936, + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1769018530, + "narHash": "sha256-MJ27Cy2NtBEV5tsK+YraYr2g851f3Fl1LpNHDzDX15c=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "88d3861acdd3d2f0e361767018218e51810df8a1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs_2" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1768996281, + "narHash": "sha256-s+TolkG0f98fR6RtBEmymBb8RHmZ04U3SL8cjoqog2k=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "2d124215693f13dcf6ad097a02acdd473c80e447", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b1f6a9b --- /dev/null +++ b/flake.nix @@ -0,0 +1,17 @@ +{ + description = "PicoForge Dev Flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; + + outputs = inputs@{ flake-parts, fenix, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" "x86_64-darwin" ]; + perSystem = { config, self', inputs', pkgs, system, ... }: { + packages.default = pkgs.callPackage ./package.nix { }; + devShells.default = import ./shell.nix { inherit pkgs; }; + }; + }; +}