matrix-media-expanded/flake.nix

112 lines
4.3 KiB
Nix
Raw Normal View History

2021-05-31 23:19:51 +00:00
{
2021-06-01 02:46:25 +00:00
description = "haskell-template's description";
2021-05-31 23:19:51 +00:00
inputs = {
# To find a suitable nixpkgs hash, pick one from https://status.nixos.org/ (these are cached)
2022-04-27 19:02:18 +00:00
nixpkgs.url = "github:nixos/nixpkgs/d9e593ed5889f3906dc72811c45bf684be8865cf";
2021-05-31 23:19:51 +00:00
flake-utils.url = "github:numtide/flake-utils";
flake-utils.inputs.nixpkgs.follows = "nixpkgs";
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
flake-compat.inputs.nixpkgs.follows = "nixpkgs";
2022-03-25 18:09:08 +00:00
lint-utils = {
type = "git";
url = "https://gitlab.homotopic.tech/nix/lint-utils.git";
2022-04-20 17:29:08 +00:00
ref = "overengineered"; # https://gitlab.homotopic.tech/nix/lint-utils/-/merge_requests/4
2022-03-25 18:09:08 +00:00
inputs.nixpkgs.follows = "nixpkgs";
2022-03-26 16:04:22 +00:00
};
2021-05-31 23:19:51 +00:00
};
outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
2022-03-23 17:39:20 +00:00
flake-utils.lib.eachDefaultSystem
(system:
let
# Because: https://zimbatm.com/notes/1000-instances-of-nixpkgs
pkgs = nixpkgs.legacyPackages.${system};
2022-03-17 14:16:54 +00:00
2022-03-23 17:39:20 +00:00
# Change GHC version here. To get the appropriate value, run:
# nix-env -f "<nixpkgs>" -qaP -A haskell.compiler
hp = pkgs.haskellPackages; # pkgs.haskell.packages.ghc921;
2022-03-17 14:16:54 +00:00
2022-04-27 19:03:34 +00:00
# Paths to ignore when building the cabal package.
# FIXME: Why does changing any of this this retrigger Nix builds anyway?
ignorePatterns = [ "*.nix" "flake.lock" "*.md" "fourmolu.yaml" "hie.yaml" "bin" ".envrc" ".ghcid" ".gitattributes" ".github" ".gitignore" ".vscode" ];
2022-03-23 17:39:20 +00:00
project = returnShellEnv:
hp.developPackage {
inherit returnShellEnv;
name = "haskell-template";
2022-04-27 19:03:34 +00:00
root = pkgs.nix-gitignore.gitignoreSource ignorePatterns ./.;
2022-03-23 17:39:20 +00:00
withHoogle = false;
overrides = self: super: with pkgs.haskell.lib; {
# Use callCabal2nix to override Haskell dependencies here
# cf. https://tek.brick.do/K3VXJd8mEKO7
# Example:
# > NanoID = self.callCabal2nix "NanoID" inputs.NanoID { };
# Assumes that you have the 'NanoID' flake input defined.
};
modifier = drv:
pkgs.haskell.lib.addBuildTools drv (with hp; pkgs.lib.lists.optionals returnShellEnv [
# Specify your build/dev dependencies here.
cabal-fmt
cabal-install
ghcid
haskell-language-server
2022-03-23 17:46:51 +00:00
fourmolu
2022-03-23 17:39:20 +00:00
hlint
pkgs.nixpkgs-fmt
]);
2021-05-31 23:19:51 +00:00
};
2022-03-26 16:04:22 +00:00
lintSpec = {
nixpkgs-fmt = { };
cabal-fmt = { };
2022-04-09 15:45:48 +00:00
# hlint = { };
fourmolu = {
ghcOpts = "-o-XTypeApplications -o-XImportQualifiedPost";
};
};
2022-03-26 16:04:22 +00:00
# Checks the shell script using ShellCheck
2022-03-26 19:05:11 +00:00
checkedShellScript = name: text:
2022-03-26 16:04:22 +00:00
(pkgs.writeShellApplication {
inherit name text;
}) + "/bin/${name}";
2022-03-23 17:39:20 +00:00
in
{
# Used by `nix build` & `nix run` (prod exe)
defaultPackage = project false;
# Used by `nix develop` (dev shell)
devShell = project true;
2021-05-31 23:19:51 +00:00
# Used by `nix run ...`
2022-03-25 18:09:08 +00:00
apps = {
format = inputs.lint-utils.mkApp.${system} lintSpec;
2022-03-25 18:09:08 +00:00
};
2022-03-26 23:09:41 +00:00
# Used by `nix flake check` (but see next attribute)
checks =
inputs.lint-utils.mkChecks.${system} lintSpec ./.
// {
hls = checkedShellScript "hls" "${hp.haskell-language-server}/bin/haskell-language-server";
};
2022-03-26 19:05:11 +00:00
# We need this hack because `nix flake check` won't work for Haskell
# projects: https://nixos.wiki/wiki/Import_From_Derivation#IFD_and_Haskell
#
# Instead, run: `nix build .#check.x86_64-linux` (replace with your system)
2022-03-26 16:04:22 +00:00
check =
pkgs.runCommand "combined-checks"
{
checksss = builtins.attrValues self.checks.${system};
} ''
echo $checksss
touch $out
2022-03-26 16:04:22 +00:00
'';
2022-03-23 17:39:20 +00:00
}) // {
# For hercules-CI support,
# https://docs.hercules-ci.com/hercules-ci/guides/upgrade-to-agent-0.9/#_upgrade_your_repositories
herculesCI.ciSystems = [ "x86_64-linux" ];
};
2021-05-31 23:19:51 +00:00
}