diff --git a/flake.lock b/flake.lock index 734df5a1..6fd02316 100644 --- a/flake.lock +++ b/flake.lock @@ -20,17 +20,17 @@ }, "nixpkgs": { "locked": { - "lastModified": 1724395761, - "narHash": "sha256-zRkDV/nbrnp3Y8oCADf5ETl1sDrdmAW6/bBVJ8EbIdQ=", + "lastModified": 1724190949, + "narHash": "sha256-fb5hyGoUSOdaYQwak3OIArqAt1PB1oEsZXJ9BXbom3w=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ae815cee91b417be55d43781eb4b73ae1ecc396c", + "rev": "69f3b4defe91949a97ca751ada931525d391e0fc", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixpkgs-unstable", "repo": "nixpkgs", + "rev": "69f3b4defe91949a97ca751ada931525d391e0fc", "type": "github" } }, diff --git a/flake.nix b/flake.nix index df188a78..e55d4a1f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,15 +1,27 @@ { inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + # TODO: switch to nixpkgs-unstable when this commit is there + nixpkgs.url = "github:nixos/nixpkgs/69f3b4defe91949a97ca751ada931525d391e0fc"; flake-parts.url = "github:hercules-ci/flake-parts"; }; - outputs = inputs@{ nixpkgs, flake-parts, ... }: + outputs = + inputs@{ nixpkgs, flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } { systems = nixpkgs.lib.platforms.all; - perSystem = { pkgs, ... }: { - devShells.default = - pkgs.mkShell { packages = [ pkgs.bun pkgs.nodejs ]; }; - # TODO: Package LA using Nix - }; + perSystem = + { pkgs, ... }: + let + cargo-tauri = pkgs.callPackage ./nix/cargo-tauri.nix { }; + in + { + devShells.default = pkgs.mkShell { + packages = [ + pkgs.bun + pkgs.nodejs + cargo-tauri + ]; + }; + # TODO: Package LA using Nix + }; }; } diff --git a/nix/cargo-tauri.nix b/nix/cargo-tauri.nix new file mode 100644 index 00000000..9ef519d4 --- /dev/null +++ b/nix/cargo-tauri.nix @@ -0,0 +1,67 @@ +# TODO: use upstream cargo-tauri when it is updated to v2 in nixpkgs +# copied from nixpkgs to change the version and hashes +{ + lib, + stdenv, + rustPlatform, + fetchFromGitHub, + openssl, + pkg-config, + glibc, + libsoup, + cairo, + gtk3, + webkitgtk, + darwin, +}: + +let + inherit (darwin.apple_sdk.frameworks) CoreServices Security SystemConfiguration; +in +rustPlatform.buildRustPackage rec { + pname = "tauri"; + version = "2.0.0-rc.7"; + + src = fetchFromGitHub { + owner = "tauri-apps"; + repo = pname; + rev = "tauri-cli-v${version}"; + hash = "sha256-y8Y9En1r1HU9sZcYHFhB+botVQBZfzqoDrlgp98ltrY="; + }; + + # Manually specify the sourceRoot since this crate depends on other crates in the workspace. Relevant info at + # https://discourse.nixos.org/t/difficulty-using-buildrustpackage-with-a-src-containing-multiple-cargo-workspaces/10202 + sourceRoot = "${src.name}/tooling/cli"; + + cargoHash = "sha256-u1JcLuP9KFCIb7Wkk3u/hoV/bBarEvFfqpGXVyXSvpo="; + + buildInputs = + [ openssl ] + ++ lib.optionals stdenv.isLinux [ + glibc + libsoup + cairo + gtk3 + webkitgtk + ] + ++ lib.optionals stdenv.isDarwin [ + CoreServices + Security + SystemConfiguration + ]; + nativeBuildInputs = [ pkg-config ]; + + meta = with lib; { + description = "Build smaller, faster, and more secure desktop applications with a web frontend"; + mainProgram = "cargo-tauri"; + homepage = "https://tauri.app/"; + license = with licenses; [ + asl20 # or + mit + ]; + maintainers = with maintainers; [ + dit7ya + happysalada + ]; + }; +}