1
0

flake.nix 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [
  27. IOKit
  28. Carbon
  29. WebKit
  30. Security
  31. Cocoa
  32. ]);
  33. # This is useful when building crates as packages
  34. # Note that it does require a `Cargo.lock` which this repo does not have
  35. # craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain;
  36. in
  37. {
  38. _module.args.pkgs = import inputs.nixpkgs {
  39. inherit system;
  40. overlays = [
  41. inputs.rust-overlay.overlays.default
  42. ];
  43. };
  44. devShells.default = pkgs.mkShell {
  45. name = "dioxus-dev";
  46. buildInputs = rustBuildInputs;
  47. nativeBuildInputs = [
  48. # Add shell dependencies here
  49. rustToolchain
  50. ];
  51. shellHook = ''
  52. # For rust-analyzer 'hover' tooltips to work.
  53. export RUST_SRC_PATH="${rustToolchain}/lib/rustlib/src/rust/library";
  54. '';
  55. };
  56. };
  57. };
  58. }