chore(nix): add cargo-tauri

This commit is contained in:
Alice Carroll
2024-08-30 18:04:41 +03:00
parent bf4f06e4e5
commit 61a6ca571f
3 changed files with 90 additions and 11 deletions

8
flake.lock generated
View File

@@ -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"
}
},

View File

@@ -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
};
};
}

67
nix/cargo-tauri.nix Normal file
View File

@@ -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
];
};
}