2 description = "Haskell application using Miso";
3 # UsageNote: to run the Haskell app inside an Android emulator:
4 # nix -L run .#android-emulator-x86_64
8 # ResourceWarning: this flake is not on Miso's cache,
9 # including the patched GHC.
10 "https://haskell-miso-cachix.cachix.org"
12 extra-trusted-public-keys = [
13 "haskell-miso-cachix.cachix.org-1:m8hN1cvFMJtYib4tj+06xkKt5ABMSGfe8W7s40x1kQ0="
15 #allow-import-from-derivation = "true";
19 ghcjs-base.flake = false;
20 ghcjs-base.url = "github:ghcjs/ghcjs-base";
21 git-hooks.inputs.nixpkgs.follows = "nixpkgs";
22 git-hooks.url = "github:cachix/git-hooks.nix";
23 miso-lynx.flake = false;
24 miso-lynx.url = "github:dmjio/miso-lynx";
25 miso.inputs.nixpkgs.follows = "nixpkgs";
26 miso.url = "github:dmjio/miso";
27 nixpkgs.url = "flake:nixpkgs";
39 lib = inputs.nixpkgs.lib;
42 lib.genAttrs lib.systems.flakeExposed (
46 pkgs = import inputs.nixpkgs {
49 android_sdk.accept_license = true;
50 allowUnfreePredicate = android.allowUnfreePredicate;
57 haskell = pkgs.callPackage haskell/default.nix {
59 miso-lynx = inputs.miso-lynx;
61 ghcPackages = pkgs.haskell.packages.${ghc}.extend (
62 with pkgs.haskell.lib;
63 finalHaskellPkgs: previousHaskellPkgs: {
64 ${pkg} = buildFromSdist (finalHaskellPkgs.callCabal2nix pkg haskell.src { });
65 miso = finalHaskellPkgs.callCabal2nix "miso" inputs.miso { };
66 miso-lynx = finalHaskellPkgs.callCabal2nix "miso-lynx" inputs.miso-lynx { };
69 android = pkgs.callPackage android/default.nix {
70 inherit inputs system;
71 inherit (haskell) mainLynxBundle;
78 packages = perSystem (
80 default = android.packages.default;
81 android = android.packages.default;
82 android-emulator-x86_64 = android.packages.android-emulator-x86_64;
87 devShells = perSystem (
89 default = ghcPackages.shellFor {
90 packages = haskellPackages: [ haskellPackages.${pkg} ];
91 nativeBuildInputs = android.devShells.default.nativeBuildInputs ++ [
92 # CompatibilityNote: pull haskell-language-server from ghcPackages
93 # to ensure its compatibility with the selected GHC.
94 ghcPackages.haskell-language-server
97 pkgs.haskellPackages.cabal-fmt
98 pkgs.haskellPackages.cabal-install
99 pkgs.haskellPackages.ghcid
100 pkgs.haskellPackages.hlint
106 ${android.devShells.default.shellHook}
107 ${checks.${system}.git-hooks-check}
108 rm -rf haskell/cache/gc-roots
109 nix-store --add-root haskell/cache/gc-roots/ghcjs-ghc \
110 --indirect --realise ${haskell.haskellPackages.ghc}
119 git-hooks-check = inputs.git-hooks.lib.${system}.run {
122 cabal-fmt.enable = true;
123 fourmolu.enable = true;
125 nixfmt-rfc-style.enable = true;
126 ormolu.settings.cabalDefaultExtensions = true;
129 entry = "${pkgs.reuse}/bin/reuse lint";
130 pass_filenames = false;