matrix-media-expanded/flake.nix

104 lines
3.5 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
};
2022-04-27 22:55:51 +00:00
outputs = inputs:
let
# Function that produces Flake outputs for the given system.
outputsFor = system:
2022-03-23 17:39:20 +00:00
let
# Because: https://zimbatm.com/notes/1000-instances-of-nixpkgs
2022-04-27 22:55:51 +00:00
pkgs = inputs.nixpkgs.legacyPackages.${system};
inherit (pkgs.lib.trivial) pipe flip;
inherit (pkgs.lib.lists) optionals;
2022-03-17 14:16:54 +00:00
2022-04-27 22:55:51 +00:00
# Specify GHC version here. To get the appropriate value, run:
2022-03-23 17:39:20 +00:00
# nix-env -f "<nixpkgs>" -qaP -A haskell.compiler
2022-04-27 22:55:51 +00:00
hp = pkgs.haskellPackages; # Eg: pkgs.haskell.packages.ghc921;
# Specify your build/dev dependencies here.
shellDeps = with hp; [
cabal-fmt
cabal-install
ghcid
haskell-language-server
fourmolu
hlint
pkgs.nixpkgs-fmt
];
2022-03-17 14:16:54 +00:00
2022-03-23 17:39:20 +00:00
project = returnShellEnv:
hp.developPackage {
inherit returnShellEnv;
name = "haskell-template";
root = ./.;
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:
2022-04-27 22:55:51 +00:00
let inherit (pkgs.haskell.lib) addBuildTools;
in
pipe drv
[
# Transform the Haskell derivation (`drv`) here.
(flip addBuildTools
(optionals returnShellEnv shellDeps))
];
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-23 17:39:20 +00:00
in
{
2022-04-27 22:55:51 +00:00
# Used by `nix build ...`
packages = {
default = project false;
};
# Used by `nix run ...`
2022-03-25 18:09:08 +00:00
apps = {
2022-04-27 22:34:53 +00:00
default = {
type = "app";
2022-04-27 22:55:51 +00:00
program = "${inputs.self.packages.${system}.default}/bin/haskell-template";
2022-04-27 22:34:53 +00:00
};
format = inputs.lint-utils.mkApp.${system} lintSpec;
2022-03-25 18:09:08 +00:00
};
2022-04-27 22:55:51 +00:00
# Used by `nix develop ...`
devShells = {
default = project false;
};
2022-03-25 18:09:08 +00:00
2022-04-27 22:55:51 +00:00
};
in
inputs.flake-utils.lib.eachDefaultSystem outputsFor
// {
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
}