]> Git — Sourcephile - julm/worksheets.git/blob - flake.nix
update
[julm/worksheets.git] / flake.nix
1 # SPDX-FileCopyrightText: 2025 Julien Moutinho <julm+worksheets@sourcephile.fr>
2 # SPDX-License-Identifier: CC0-1.0
3 {
4 description = "Worksheet";
5 inputs = {
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; };
10 };
11 outputs =
12 inputs:
13 let
14 pkg = "worksheets";
15 lib = inputs.nixpkgs.lib;
16 fileInputs = with lib.fileset; toSource {
17 root = ./.;
18 fileset = unions [
19 ./worksheets.cabal
20 #./ChangeLog.md
21 #./Readme.md
22 ./LICENSES
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)
27 ];
28 };
29 # Helper to build for each system in `lib.systems.flakeExposed`.
30 perSystem =
31 f:
32 lib.genAttrs lib.systems.flakeExposed (
33 system:
34 f rec {
35 inherit system;
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 { });
40 anki-tools = null;
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));
44 });
45 }
46 );
47 in
48 {
49 # `nix -L build`
50 packages = perSystem ({ haskellPackages, pkgs, ... }: pkgs // {
51 default = haskellPackages.${pkg};
52 });
53 # `nix -L develop` or `direnv allow`
54 devShells = perSystem ({ pkgs, haskellPackages, system, ... }: {
55 default =
56 haskellPackages.shellFor {
57 packages = ps: [ ps.${pkg} ];
58 nativeBuildInputs = [
59 haskellPackages.cabal-fmt
60 haskellPackages.cabal-install
61 haskellPackages.ghcid
62 haskellPackages.haskell-language-server
63 haskellPackages.hlint
64 #pkgs.git-chglog
65 pkgs.reuse
66 ];
67 withHoogle = false;
68 inherit (inputs.self.checks.${system}.git-hooks-check) shellHook;
69 };
70 });
71 # `nix flake check`
72 checks = perSystem (args: with args; {
73 git-hooks-check = inputs.git-hooks.lib.${system}.run {
74 src = ./.;
75 hooks = {
76 cabal-fmt.enable = true;
77 fourmolu.enable = true;
78 hlint.enable = true;
79 nixpkgs-fmt.enable = true;
80 ormolu.settings.cabalDefaultExtensions = true;
81 ormolu.settings.defaultExtensions = [
82 "ImportQualifiedPost"
83 "TypeApplications"
84 ];
85 reuse = {
86 enable = true;
87 entry = "${pkgs.reuse}/bin/reuse lint";
88 pass_filenames = false;
89 };
90 };
91 };
92 });
93 };
94 }