]> Git — Sourcephile - tmp/julm/android.git/blob - flake.nix
reusability: comply with REUSE 3.3
[tmp/julm/android.git] / flake.nix
1 {
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
5
6 nixConfig = {
7 extra-substituters = [
8 # ResourceWarning: this flake is not on Miso's cache,
9 # including the patched GHC.
10 "https://haskell-miso-cachix.cachix.org"
11 ];
12 extra-trusted-public-keys = [
13 "haskell-miso-cachix.cachix.org-1:m8hN1cvFMJtYib4tj+06xkKt5ABMSGfe8W7s40x1kQ0="
14 ];
15 #allow-import-from-derivation = "true";
16 };
17
18 inputs = {
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";
28 };
29
30 outputs =
31 inputs:
32 let
33 systems = [
34 "x86_64-linux"
35 "x86_64-darwin"
36 "aarch64-linux"
37 "aarch64-darwin"
38 ];
39 lib = inputs.nixpkgs.lib;
40 perSystem =
41 f:
42 lib.genAttrs lib.systems.flakeExposed (
43 system:
44 f rec {
45 inherit system;
46 pkgs = import inputs.nixpkgs {
47 inherit system;
48 config = {
49 android_sdk.accept_license = true;
50 allowUnfreePredicate = android.allowUnfreePredicate;
51 };
52 overlays = [
53 ];
54 };
55 pkg = "demo";
56 ghc = "ghc9122";
57 haskell = pkgs.callPackage haskell/default.nix {
58 inherit inputs ghc;
59 miso-lynx = inputs.miso-lynx;
60 };
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 { };
67 }
68 );
69 android = pkgs.callPackage android/default.nix {
70 inherit inputs system;
71 inherit (haskell) mainLynxBundle;
72 };
73 }
74 );
75 in
76 rec {
77 # nix -L build
78 packages = perSystem (
79 args: with args; {
80 default = android.packages.default;
81 android = android.packages.default;
82 android-emulator-x86_64 = android.packages.android-emulator-x86_64;
83 }
84 );
85
86 # nix -L develop
87 devShells = perSystem (
88 args: with args; {
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
95 #pkgs.emscripten
96 pkgs.ghciwatch
97 pkgs.haskellPackages.cabal-fmt
98 pkgs.haskellPackages.cabal-install
99 pkgs.haskellPackages.ghcid
100 pkgs.haskellPackages.hlint
101 pkgs.http-server
102 pkgs.reuse
103 ];
104 withHoogle = false;
105 shellHook = ''
106 ${android.devShells.default.shellHook}
107 ${checks.${system}.git-hooks-check}
108 '';
109 };
110 }
111 );
112
113 # nix flake check
114 checks = perSystem (
115 args: with args; {
116 git-hooks-check = inputs.git-hooks.lib.${system}.run {
117 src = ./.;
118 hooks = {
119 cabal-fmt.enable = true;
120 fourmolu.enable = true;
121 hlint.enable = true;
122 nixfmt-rfc-style.enable = true;
123 ormolu.settings.cabalDefaultExtensions = true;
124 reuse = {
125 enable = true;
126 entry = "${pkgs.reuse}/bin/reuse lint";
127 pass_filenames = false;
128 };
129 };
130 };
131 }
132 );
133 };
134
135 }