diff --git a/templates/haskell/.config/project/default.nix b/templates/haskell/.config/project/default.nix index b68c002..780d483 100644 --- a/templates/haskell/.config/project/default.nix +++ b/templates/haskell/.config/project/default.nix @@ -9,17 +9,56 @@ project = { name = "{{project.name}}"; summary = "{{project.summary}}"; - ## TODO: Move something like this to Flaky. file = let - copyLicenses = dir: { + ## Cabal requires many files to exist at the package level, rather than + ## the repo level. This makes copies of the individual files into the + ## package directory. + ## + ## TODO: Move something like this to Flaky. + perPackageFiles = dir: { "${dir}/LICENSE".source = ../../LICENSE; "${dir}/LICENSE.AGPL-3.0-only".source = ../../LICENSE.AGPL-3.0-only; "${dir}/LICENSE.Universal-FOSS-exception-1.0".source = ../../LICENSE.Universal-FOSS-exception-1.0; - "${dir}/LICENSE.commercial".source = ../../LICENSE.commercial; + "${dir}/LICENSE.proprietary".source = ../../LICENSE.proprietary; + ## We might want to put this somewhere else (like .config/henforcer/), + ## but that isn’t currently an option, because of flipstone/henforcer#7. + "${dir}/henforcer.toml".text = + lib.pm.generators.toTOML {} { + globalSection = {}; + sections = { + forAnyModule = { + ## doesn’t yet support nested attr sets + # allowedAliasUniqueness.allAliasesUniqueExcept = []; + maximumExportsPlusHeaderUndocumented = 0; + maximumExportsWithoutSince = 0; + moduleHeaderCopyrightMustExistNonEmpty = true; + ## We want to require a description, but just a “normal” + ## description, not the header field. + moduleHeaderDescriptionMustExistNonEmpty = false; + moduleHeaderLicenseMustExistNonEmpty = true; + }; + }; + } + ## NB: `toTOML` is really just an INI generator, so it can’t handle a + ## lot of syntax. This tacks some bits onto the end that the INI + ## generator does’t like. + + '' + # Exclude auto-generated `Paths` module + [[forPatternModules]] + pattern = "Paths_*" + [forPatternModules.rulesToIgnore] + all = true + + # Exclude auto-generated `Build_doctests` module + [[forSpecifiedModules]] + module = "Build_doctests" + [forSpecifiedModules.rulesToIgnore] + all = true + ''; }; in - copyLicenses "core"; + perPackageFiles "core"; }; imports = [./hlint.nix]; diff --git a/templates/haskell/LICENSE b/templates/haskell/LICENSE index a3f833f..d125966 100644 --- a/templates/haskell/LICENSE +++ b/templates/haskell/LICENSE @@ -1,5 +1,5 @@ LicenseListVersion: 3.27.0 -SPDX-License-Identifier: AGPL-3.0-only WITH Universal-FOSS-exception-1.0 OR LicenseRef-commercial +SPDX-License-Identifier: AGPL-3.0-only WITH Universal-FOSS-exception-1.0 OR LicenseRef-proprietary The individual licenses are included in files named “LICENSE.” with a suffix that matches each license’s identifier. diff --git a/templates/haskell/LICENSE.commercial b/templates/haskell/LICENSE.commercial deleted file mode 100644 index 3bc6320..0000000 --- a/templates/haskell/LICENSE.commercial +++ /dev/null @@ -1,3 +0,0 @@ -This software is available for commercial licensing with flexible terms. - -Contact licensing@technomadic.org for more information. diff --git a/templates/haskell/LICENSE.proprietary b/templates/haskell/LICENSE.proprietary new file mode 100644 index 0000000..7193f4b --- /dev/null +++ b/templates/haskell/LICENSE.proprietary @@ -0,0 +1,3 @@ +This software is available for proprietary licensing with flexible terms. + +Contact licensing@technomadic.org for more information. diff --git a/templates/haskell/cabal.project b/templates/haskell/cabal.project index 681af77..2ef86a3 100644 --- a/templates/haskell/cabal.project +++ b/templates/haskell/cabal.project @@ -5,10 +5,15 @@ max-backjumps: -1 minimize-conflict-set: true reorder-goals: true +-- Maximize parallelism +jobs: $ncpus +if impl(ghc >= 9.8) + semaphore: True + flags: - -- Ensure development of this project always uses @NoRecursion@, even if it - -- causes the solver to fail. - +verify-no-recursion + -- Ensure development of this project always uses linters, even if it causes + -- the solver to fail. + +lint program-options ghc-options: diff --git a/templates/haskell/core/{{project.name}}.cabal b/templates/haskell/core/{{project.name}}.cabal index 86556e9..84cf8fc 100644 --- a/templates/haskell/core/{{project.name}}.cabal +++ b/templates/haskell/core/{{project.name}}.cabal @@ -5,18 +5,17 @@ cabal-version: 3.0 name: {{project.name}} version: 0.0.1.0 synopsis: {{project.summary}} -description: {{project.description}} +description: + {{project.description}} maintainer: Greg Pfeil author: Greg Pfeil copyright: 2025 Greg Pfeil --- TODO: Remove the redundant `OR AGPL-3.0-only` once --- haskell/hackage-server#1440 is fixed. -license: AGPL-3.0-only WITH Universal-FOSS-exception-1.0 OR AGPL-3.0-only OR LicenseRef-commercial +license: AGPL-3.0-only WITH Universal-FOSS-exception-1.0 OR LicenseRef-proprietary license-files: LICENSE LICENSE.AGPL-3.0-only LICENSE.Universal-FOSS-exception-1.0 - LICENSE.commercial + LICENSE.proprietary category: build-type: Custom extra-doc-files: @@ -85,9 +84,9 @@ flag noisy-deprecations -- Because disabling this flag won’t help the solver. manual: True -flag verify-no-recursion +flag lint description: - Compile with "NoRecursion" enabled. This is intended for developers of this + Build with linting plugins enabled. This is intended for developers of this package. default: False -- Because disabling this flag won’t help the solver. @@ -204,11 +203,16 @@ common defaults if flag(noisy-deprecations) cpp-options: -DSELLOUT_NOISY_DEPRECATIONS - if flag(verify-no-recursion) + if flag(lint) build-depends: no-recursion, ghc-options: -fplugin=NoRecursion + if impl(ghc >= 9.4) + build-depends: + henforcer ^>= {1.0.0}, + ghc-options: + -fplugin Henforcer library import: defaults @@ -226,6 +230,8 @@ test-suite doctests build-depends: doctest, {{project.name}}, + ghc-options: + -fno-warn-missing-import-lists if impl(ghc >= 8.10.1) ghc-options: -- `doctest` requires the package containing the doctests as a dependency @@ -237,11 +243,7 @@ test-suite doctests -- all of its warnings one way or another. if impl(ghc >= 8.0.1) ghc-options: - -Wno-missing-import-lists -Wno-safe - else - ghc-options: - -fno-warn-missing-import-lists if impl(ghc >= 8.4.1) ghc-options: -Wno-missing-export-lists