1 # SPDX-FileCopyrightText: 2025 Julien Moutinho <julm+worksheets@sourcephile.fr>
2 # SPDX-License-Identifier: CC0-1.0
4 description = "Worksheet";
6 nixpkgs.url = "flake:nixpkgs";
7 git-hooks.url = "github:cachix/git-hooks.nix";
8 git-hooks.inputs.nixpkgs.follows = "nixpkgs";
9 symantic-base = { url = "git://git.sourcephile.fr/haskell/symantic-base.git"; flake = false; };
15 lib = inputs.nixpkgs.lib;
16 fileInputs = with lib.fileset; toSource {
23 (fileFilter (file: lib.any file.hasExt [ "hs" ]) ./src)
24 (fileFilter (file: lib.any file.hasExt [ "css" ]) ./data/styles)
25 (fileFilter (file: lib.any file.hasExt [ "hs" "html" "txt" ]) ./tests)
26 #(fileFilter (file: lib.any file.hasExt [ "hs" ]) ./app)
29 # Helper to build for each system in `lib.systems.flakeExposed`.
32 lib.genAttrs lib.systems.flakeExposed (
36 #pkgs = import inputs.nixpkgs { inherit system; };
37 pkgs = inputs.nixpkgs.legacyPackages.${system};
38 haskellPackages = pkgs.haskellPackages.extend (with pkgs.haskell.lib; finalHaskellPkgs: previousHaskellPkgs: {
39 ${pkg} = buildFromSdist (finalHaskellPkgs.callCabal2nix pkg fileInputs { });
41 symantic-base = finalHaskellPkgs.callCabal2nix "symantic-base" inputs.symantic-base { };
42 ipa = doJailbreak (unmarkBroken previousHaskellPkgs.ipa);
43 python-pickle = dontCheck (doJailbreak (unmarkBroken previousHaskellPkgs.python-pickle));
50 packages = perSystem ({ haskellPackages, pkgs, ... }: pkgs // {
51 default = haskellPackages.${pkg};
53 # `nix -L develop` or `direnv allow`
54 devShells = perSystem ({ pkgs, haskellPackages, system, ... }: {
56 haskellPackages.shellFor {
57 packages = ps: [ ps.${pkg} ];
59 haskellPackages.cabal-fmt
60 haskellPackages.cabal-install
62 haskellPackages.haskell-language-server
68 inherit (inputs.self.checks.${system}.git-hooks-check) shellHook;
72 checks = perSystem (args: with args; {
73 git-hooks-check = inputs.git-hooks.lib.${system}.run {
76 cabal-fmt.enable = true;
77 fourmolu.enable = true;
79 nixpkgs-fmt.enable = true;
80 ormolu.settings.cabalDefaultExtensions = true;
81 ormolu.settings.defaultExtensions = [
87 entry = "${pkgs.reuse}/bin/reuse lint";
88 pass_filenames = false;