matrix-media-expanded/flake.nix

83 lines
2.9 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 = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
2022-05-26 11:25:38 +00:00
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
flake-compat.inputs.nixpkgs.follows = "nixpkgs";
2021-05-31 23:19:51 +00:00
};
2022-04-27 22:55:51 +00:00
2022-05-26 11:25:38 +00:00
# We use flake-parts as a way to make flakes 'system-aware'
2022-05-22 18:48:09 +00:00
# cf. https://github.com/NixOS/nix/issues/3843#issuecomment-661720562
2022-05-26 11:25:38 +00:00
outputs = { self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit self; } {
systems = nixpkgs.lib.systems.supported.hydra;
# The primed versions (self', inputs') are same as the non-primed
# versions, but with 'system' already applied.
perSystem = { self', inputs', pkgs, system, ... }:
2022-03-23 17:39:20 +00:00
let
2022-05-22 18:53:04 +00:00
name = "haskell-template";
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-05-04 20:24:34 +00:00
pkgs.treefmt
2022-04-27 22:55:51 +00:00
];
2022-03-17 14:16:54 +00:00
project =
{ returnShellEnv ? false
, withHoogle ? false
}:
2022-03-23 17:39:20 +00:00
hp.developPackage {
2022-05-22 18:53:04 +00:00
inherit returnShellEnv withHoogle name;
root = ./.;
2022-03-23 17:39:20 +00:00
overrides = self: super: with pkgs.haskell.lib; {
# Use callCabal2nix to override Haskell dependencies here
# cf. https://tek.brick.do/K3VXJd8mEKO7
# Example:
2022-05-26 11:25:38 +00:00
# > NanoID = self.callCabal2nix "NanoID" inputs'.NanoID { };
2022-03-23 17:39:20 +00:00
# Assumes that you have the 'NanoID' flake input defined.
};
modifier = drv:
pkgs.haskell.lib.overrideCabal drv (oa: {
# All the Cabal-specific overrides go here.
# For examples on what is possible, see:
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/haskell-modules/lib/compose.nix
buildTools = (oa.buildTools or [ ]) ++ optionals returnShellEnv shellDeps;
});
2021-05-31 23:19:51 +00:00
};
2022-03-23 17:39:20 +00:00
in
{
2022-04-27 22:55:51 +00:00
# Used by `nix build ...`
packages = {
default = project { };
2022-04-27 22:55:51 +00:00
};
# 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-05-26 11:25:38 +00:00
program = "${self'.packages.default}/bin/${name}";
2022-04-27 22:34:53 +00:00
};
2022-03-25 18:09:08 +00:00
};
2022-04-27 22:55:51 +00:00
# Used by `nix develop ...`
devShells = {
default = project { returnShellEnv = true; withHoogle = true; };
2022-04-27 22:55:51 +00:00
};
2022-05-26 11:25:38 +00:00
};
};
2021-05-31 23:19:51 +00:00
}