1 # SPDX-FileCopyrightText: 2025 Julien Mouyinho <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";
14 lib = inputs.nixpkgs.lib;
15 fileInputs = with lib.fileset; toSource {
22 (fileFilter (file: lib.any file.hasExt [ "hs" ]) ./src)
23 (fileFilter (file: lib.any file.hasExt [ "css" ]) ./style)
24 (fileFilter (file: lib.any file.hasExt [ "hs" "html" "txt" ]) ./tests)
25 #(fileFilter (file: lib.any file.hasExt [ "hs" ]) ./app)
28 # Helper to build for each system in `lib.systems.flakeExposed`.
31 lib.genAttrs lib.systems.flakeExposed (
35 #pkgs = import inputs.nixpkgs { inherit system; };
36 pkgs = inputs.nixpkgs.legacyPackages.${system};
37 haskellPackages = pkgs.haskellPackages.extend (with pkgs.haskell.lib; finalHaskellPkgs: previousHaskellPkgs: {
38 ${pkg} = buildFromSdist (finalHaskellPkgs.callCabal2nix pkg fileInputs { });
45 packages = perSystem ({ haskellPackages, ... }: {
46 default = haskellPackages.${pkg};
48 # `nix -L develop` or `direnv allow`
49 devShells = perSystem ({ pkgs, haskellPackages, system, ... }: {
51 haskellPackages.shellFor {
52 packages = ps: [ ps.${pkg} ];
54 haskellPackages.cabal-fmt
55 haskellPackages.cabal-install
57 haskellPackages.haskell-language-server
63 inherit (inputs.self.checks.${system}.git-hooks-check) shellHook;
67 checks = perSystem (args: with args; {
68 git-hooks-check = inputs.git-hooks.lib.${system}.run {
71 cabal-fmt.enable = true;
72 fourmolu.enable = true;
74 nixpkgs-fmt.enable = true;
75 ormolu.settings.cabalDefaultExtensions = true;
76 ormolu.settings.defaultExtensions = [
82 entry = "${pkgs.reuse}/bin/reuse lint";
83 pass_filenames = false;