1 # SPDX-FileCopyrightText: 2022 Julien Mouyinho <julm+most-perfect-magic-squares@sourcephile.fr>
2 # SPDX-License-Identifier: CC0-1.0
4 description = "Most-Perfect Magic Square";
6 nixpkgs.url = "flake:nixpkgs";
11 lib = inputs.nixpkgs.lib;
12 # Helper to build for each system in `lib.systems.flakeExposed`.
15 lib.genAttrs lib.systems.flakeExposed (
19 pkgs = import inputs.nixpkgs { inherit system; };
20 haskellPackages = pkgs.haskellPackages;
26 packages = perSystem (
27 { pkgs, system, haskellPackages, ... }:
29 # The Glasgow Haskell Compiler (GHC)
30 # Here made available as `.#ghc` for Main.hs's shebang
31 ghc = haskellPackages.ghcWithPackages (
33 # Extra Haskell packages available
34 haskellPackages.blaze-builder
35 haskellPackages.blaze-html
36 haskellPackages.blaze-markup
37 haskellPackages.relude
39 haskellPackages.transformers
43 # A compiled version of `Main.hs`
44 # (instead of an interpreted one when run as `./Main.hs`)
45 # To avoid writing a `.cabal` file, `ghc --make` is called directly here,
46 # but should the script become a full fledge executable,
47 # a `.cabal` file should be written instead.
48 default = pkgs.stdenv.mkDerivation {
52 inputs.self.packages.${system}.ghc
56 ghc -o "$out/bin/Main" -O2 --make ./Main.hs
61 # `nix develop` or `direnv allow`
62 devShells = perSystem (
63 { pkgs, system, ... }:
65 default = pkgs.mkShell {
67 inputs.self.packages.${system}.ghc
68 pkgs.haskellPackages.haskell-language-server
69 pkgs.haskellPackages.hlint
76 checks = perSystem (args: with args; {
77 git-hooks-check = inputs.git-hooks.lib.${system}.run {
80 ormolu.settings.cabalDefaultExtensions = true;
81 cabal-fmt.enable = true;
82 fourmolu.enable = true;
84 nixfmt-rfc-style.enable = true;
87 entry = "${pkgs.reuse}/bin/reuse lint";
88 pass_filenames = false;