Personal Nix setup
at main 3.0 kB view raw
1{ lib, system, helpers, config, pkgs, ... }: 2 3with lib; 4let 5 cfg = config.modules.development; 6 7 android-arch = if helpers.system == "aarch64-darwin" then "arm64-v8a" else "x86-64"; 8 9 create-avd = pkgs.writeShellScriptBin "create-avd" '' 10 avdmanager create avd \ 11 --name android-35 \ 12 --package 'system-images;android-35;google_apis_playstore;${android-arch}' \ 13 --tag google_apis_playstore \ 14 --device pixel_8 \ 15 --force 16 ''; 17in { 18 options.modules.development.react-native = { 19 enable = mkOption { 20 default = cfg.enable; 21 example = true; 22 description = "Whether to enable React Native configuration."; 23 type = types.bool; 24 }; 25 26 android-sdk = mkOption { 27 default = cfg.react-native.enable; 28 type = types.bool; 29 }; 30 31 android-studio = mkOption { 32 default = cfg.react-native.enable && cfg.react-native.android-sdk; 33 type = types.bool; 34 }; 35 36 cocoapods = mkOption { 37 default = cfg.react-native.enable; 38 type = types.bool; 39 }; 40 41 xcode = mkOption { 42 default = cfg.react-native.enable; 43 type = types.bool; 44 }; 45 46 maestro = mkOption { 47 default = cfg.react-native.enable; 48 type = types.bool; 49 }; 50 51 fastlane = mkOption { 52 default = cfg.react-native.enable; 53 type = types.bool; 54 }; 55 }; 56 57 config = mkIf cfg.react-native.enable (mkMerge [ 58 { 59 modules.development.react-native = { 60 cocoapods = if helpers.isDarwin then (mkDefault true) else (mkForce false); 61 }; 62 63 home.packages = with pkgs; [ ruby ] ++ optionals cfg.react-native.maestro [ 64 maestro 65 ]; 66 } 67 68 (helpers.mkIfDarwin { 69 home.packages = with pkgs; [ cmake ] 70 ++ optionals cfg.react-native.cocoapods [ cocoapods ] 71 ++ optionals cfg.react-native.fastlane [ fastlane ]; 72 home.sessionVariables = { 73 CP_HOME_DIR = mkIf cfg.react-native.cocoapods "${config.xdg.dataHome}/cocoapods"; 74 }; 75 }) 76 77 (mkIf cfg.react-native.android-sdk { 78 home.packages = [ 79 pkgs.gradle_8 80 create-avd 81 ] ++ optionals (helpers.isLinux && cfg.react-native.android-studio) [ 82 pkgs.android-studio 83 ]; 84 85 home.sessionVariables = rec { 86 JAVA_HOME = pkgs.jdk.home; 87 ANDROID_USER_HOME = "${config.xdg.stateHome}/android"; 88 ANDROID_AVD_HOME = "${ANDROID_USER_HOME}/avd"; 89 GRADLE_USER_HOME = "${config.xdg.dataHome}/gradle"; 90 }; 91 92 android-sdk = { 93 enable = true; 94 packages = sdk: with sdk; [ 95 build-tools-35-0-0 96 build-tools-36-0-0 97 cmdline-tools-latest 98 emulator 99 platform-tools 100 platforms-android-35 101 platforms-android-36 102 sources-android-35 103 sources-android-36 104 ndk-27-1-12297006 105 ndk-27-0-12077973 106 cmake-3-22-1 107 sdk."system-images-android-35-google-apis-${android-arch}" 108 sdk."system-images-android-35-google-apis-playstore-${android-arch}" 109 ]; 110 }; 111 }) 112 ]); 113}