1
0

flake.nix 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. {
  2. inputs = {
  3. nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
  4. flake-parts.url = "github:hercules-ci/flake-parts";
  5. systems.url = "github:nix-systems/default";
  6. rust-overlay.url = "github:oxalica/rust-overlay";
  7. # crane.url = "github:ipetkov/crane";
  8. # crane.inputs.nixpkgs.follows = "nixpkgs";
  9. };
  10. outputs = inputs:
  11. inputs.flake-parts.lib.mkFlake { inherit inputs; } {
  12. systems = import inputs.systems;
  13. perSystem = { config, self', pkgs, lib, system, ... }:
  14. let
  15. rustToolchain = pkgs.rust-bin.stable.latest.default.override {
  16. extensions = [
  17. "rust-src"
  18. "rust-analyzer"
  19. "clippy"
  20. ];
  21. };
  22. rustBuildInputs = [
  23. pkgs.openssl
  24. pkgs.libiconv
  25. pkgs.pkg-config
  26. ] ++ lib.optionals pkgs.stdenv.isLinux [
  27. pkgs.glib
  28. pkgs.gtk3
  29. pkgs.libsoup_3
  30. pkgs.webkitgtk_4_1
  31. pkgs.xdotool
  32. ] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [
  33. IOKit
  34. Carbon
  35. WebKit
  36. Security
  37. Cocoa
  38. ]);
  39. # This is useful when building crates as packages
  40. # Note that it does require a `Cargo.lock` which this repo does not have
  41. # craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain;
  42. in
  43. {
  44. _module.args.pkgs = import inputs.nixpkgs {
  45. inherit system;
  46. overlays = [
  47. inputs.rust-overlay.overlays.default
  48. ];
  49. };
  50. devShells.default = pkgs.mkShell {
  51. name = "dioxus-dev";
  52. buildInputs = rustBuildInputs;
  53. nativeBuildInputs = [
  54. # Add shell dependencies here
  55. rustToolchain
  56. ];
  57. shellHook = ''
  58. # For rust-analyzer 'hover' tooltips to work.
  59. export RUST_SRC_PATH="${rustToolchain}/lib/rustlib/src/rust/library";
  60. '';
  61. };
  62. };
  63. };
  64. }