{ description = "Demo Haskell app using Miso"; # UsageNote: to run the app inside an Android emulator: # nix -L run .#android-emulator-x86_64 nixConfig = { extra-substituters = [ # ResourceWarning: this flake is not cached "https://haskell-miso-cachix.cachix.org" ]; extra-trusted-public-keys = [ "haskell-miso-cachix.cachix.org-1:m8hN1cvFMJtYib4tj+06xkKt5ABMSGfe8W7s40x1kQ0=" ]; #allow-import-from-derivation = "true"; }; inputs = { ghcjs-base.flake = false; ghcjs-base.url = "github:ghcjs/ghcjs-base"; git-hooks.inputs.nixpkgs.follows = "nixpkgs"; git-hooks.url = "github:cachix/git-hooks.nix"; miso-lynx.flake = false; miso-lynx.url = "github:dmjio/miso-lynx"; miso.inputs.nixpkgs.follows = "nixpkgs"; miso.url = "github:dmjio/miso"; nixpkgs.url = "flake:nixpkgs"; }; outputs = inputs: let systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; lib = inputs.nixpkgs.lib; perSystem = f: lib.genAttrs lib.systems.flakeExposed ( system: f rec { inherit system; pkgs = import inputs.nixpkgs { inherit system; config = { android_sdk.accept_license = true; allowUnfreePredicate = android.allowUnfreePredicate; }; overlays = [ ]; }; pkg = "demo"; ghc = "ghc9122"; haskell = pkgs.callPackage haskell/default.nix { inherit inputs ghc; miso-lynx = inputs.miso-lynx; }; ghcPackages = pkgs.haskell.packages.${ghc}.extend ( with pkgs.haskell.lib; finalHaskellPkgs: previousHaskellPkgs: { ${pkg} = buildFromSdist (finalHaskellPkgs.callCabal2nix pkg haskell.src { }); miso = finalHaskellPkgs.callCabal2nix "miso" inputs.miso { }; miso-lynx = finalHaskellPkgs.callCabal2nix "miso-lynx" inputs.miso-lynx { }; } ); android = pkgs.callPackage android/default.nix { inherit inputs system; inherit (haskell) mainLynxBundle; }; } ); in rec { # nix -L build packages = perSystem ( args: with args; { default = android.packages.default; android = android.packages.default; android-emulator-x86_64 = android.packages.android-emulator-x86_64; } ); # nix -L develop devShells = perSystem ( args: with args; { default = ghcPackages.shellFor { packages = haskellPackages: [ haskellPackages.${pkg} ]; nativeBuildInputs = android.devShells.default.nativeBuildInputs ++ [ # CompatibilityNote: pull haskell-language-server from ghcPackages # to ensure its compatibility with the selected GHC. ghcPackages.haskell-language-server #pkgs.emscripten pkgs.ghciwatch pkgs.haskellPackages.cabal-install pkgs.haskellPackages.ghcid pkgs.haskellPackages.hlint pkgs.http-server pkgs.reuse ]; withHoogle = false; shellHook = '' ${android.devShells.default.shellHook} ${checks.${system}.git-hooks-check} ''; }; } ); # nix flake check checks = perSystem ( args: with args; { git-hooks-check = inputs.git-hooks.lib.${system}.run { src = ./.; hooks = { cabal-fmt.enable = true; fourmolu.enable = true; hlint.enable = true; nixfmt-rfc-style.enable = true; ormolu.settings.cabalDefaultExtensions = true; reuse = { enable = true; entry = "${pkgs.reuse}/bin/reuse lint"; pass_filenames = false; }; }; }; } ); }; }