Refactor flake.nix
This commit is contained in:
parent
916b9023d8
commit
5dad24283f
1 changed files with 42 additions and 24 deletions
66
flake.nix
66
flake.nix
|
@ -15,16 +15,31 @@
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
|
|
||||||
flake-utils.lib.eachDefaultSystem
|
outputs = inputs:
|
||||||
(system:
|
let
|
||||||
|
# Function that produces Flake outputs for the given system.
|
||||||
|
outputsFor = system:
|
||||||
let
|
let
|
||||||
# Because: https://zimbatm.com/notes/1000-instances-of-nixpkgs
|
# Because: https://zimbatm.com/notes/1000-instances-of-nixpkgs
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
||||||
|
inherit (pkgs.lib.trivial) pipe flip;
|
||||||
|
inherit (pkgs.lib.lists) optionals;
|
||||||
|
|
||||||
# Change GHC version here. To get the appropriate value, run:
|
# Specify GHC version here. To get the appropriate value, run:
|
||||||
# nix-env -f "<nixpkgs>" -qaP -A haskell.compiler
|
# nix-env -f "<nixpkgs>" -qaP -A haskell.compiler
|
||||||
hp = pkgs.haskellPackages; # pkgs.haskell.packages.ghc921;
|
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
|
||||||
|
];
|
||||||
|
|
||||||
project = returnShellEnv:
|
project = returnShellEnv:
|
||||||
hp.developPackage {
|
hp.developPackage {
|
||||||
|
@ -40,16 +55,14 @@
|
||||||
# Assumes that you have the 'NanoID' flake input defined.
|
# Assumes that you have the 'NanoID' flake input defined.
|
||||||
};
|
};
|
||||||
modifier = drv:
|
modifier = drv:
|
||||||
pkgs.haskell.lib.addBuildTools drv (with hp; pkgs.lib.lists.optionals returnShellEnv [
|
let inherit (pkgs.haskell.lib) addBuildTools;
|
||||||
# Specify your build/dev dependencies here.
|
in
|
||||||
cabal-fmt
|
pipe drv
|
||||||
cabal-install
|
[
|
||||||
ghcid
|
# Transform the Haskell derivation (`drv`) here.
|
||||||
haskell-language-server
|
(flip addBuildTools
|
||||||
fourmolu
|
(optionals returnShellEnv shellDeps))
|
||||||
hlint
|
];
|
||||||
pkgs.nixpkgs-fmt
|
|
||||||
]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
lintSpec = {
|
lintSpec = {
|
||||||
|
@ -60,24 +73,29 @@
|
||||||
ghcOpts = "-o-XTypeApplications -o-XImportQualifiedPost";
|
ghcOpts = "-o-XTypeApplications -o-XImportQualifiedPost";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Used by `nix build` & `nix run` (prod exe)
|
# Used by `nix build ...`
|
||||||
defaultPackage = project false;
|
packages = {
|
||||||
# Used by `nix develop` (dev shell)
|
default = project false;
|
||||||
devShell = project true;
|
};
|
||||||
|
|
||||||
# Used by `nix run ...`
|
# Used by `nix run ...`
|
||||||
apps = {
|
apps = {
|
||||||
default = {
|
default = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = "${self.defaultPackage.${system}}/bin/haskell-template";
|
program = "${inputs.self.packages.${system}.default}/bin/haskell-template";
|
||||||
};
|
};
|
||||||
format = inputs.lint-utils.mkApp.${system} lintSpec;
|
format = inputs.lint-utils.mkApp.${system} lintSpec;
|
||||||
};
|
};
|
||||||
|
# Used by `nix develop ...`
|
||||||
|
devShells = {
|
||||||
|
default = project false;
|
||||||
|
};
|
||||||
|
|
||||||
}) // {
|
};
|
||||||
|
in
|
||||||
|
inputs.flake-utils.lib.eachDefaultSystem outputsFor
|
||||||
|
// {
|
||||||
# For hercules-CI support,
|
# For hercules-CI support,
|
||||||
# https://docs.hercules-ci.com/hercules-ci/guides/upgrade-to-agent-0.9/#_upgrade_your_repositories
|
# https://docs.hercules-ci.com/hercules-ci/guides/upgrade-to-agent-0.9/#_upgrade_your_repositories
|
||||||
herculesCI.ciSystems = [ "x86_64-linux" ];
|
herculesCI.ciSystems = [ "x86_64-linux" ];
|
||||||
|
|
Loading…
Reference in a new issue