flake-utils
-> flake-parts
(#20)
This commit is contained in:
parent
c082385a7f
commit
8ac592271b
3 changed files with 29 additions and 33 deletions
|
@ -12,7 +12,7 @@ Haskell project template optimized for a fully reproducible and friendly develop
|
|||
|
||||
First-time setup:
|
||||
|
||||
- [Install Nix](https://nixos.org/download.html) & [enable Flakes](https://nixos.wiki/wiki/Flakes)
|
||||
- [Install Nix](https://nixos.org/download.html) (>= 2.8) & [enable Flakes](https://nixos.wiki/wiki/Flakes)
|
||||
- Run `nix develop -c haskell-language-server` to sanity check your environment
|
||||
- [Open as single-folder workspace](https://code.visualstudio.com/docs/editor/workspaces#_singlefolder-workspaces) in Visual Studio Code
|
||||
- When prompted by VSCode, install the [workspace recommended](https://code.visualstudio.com/docs/editor/extension-marketplace#_workspace-recommended-extensions) extensions
|
||||
|
@ -30,6 +30,7 @@ Open `Main.hs`, and expect all HLS IDE features like hover-over tooltip to work
|
|||
Renaming the project:
|
||||
|
||||
```sh
|
||||
# First, click the green "Use this template" button on GitHub to create your copy.
|
||||
git clone <your-clone-url>
|
||||
cd your-project
|
||||
NAME=myproject
|
||||
|
|
24
flake.lock
generated
24
flake.lock
generated
|
@ -16,19 +16,23 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1652776076,
|
||||
"narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8",
|
||||
"lastModified": 1653510071,
|
||||
"narHash": "sha256-KoBs0USqNunyxaBOYx/trSREMf8f3fA+msDfADiMI5o=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "c7d1a3d10117247892df7db45cef562bf62789d5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"ref": "v1.0.0",
|
||||
"repo": "flake-utils",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
|
@ -51,7 +55,7 @@
|
|||
"root": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
|
|
35
flake.nix
35
flake.nix
|
@ -2,29 +2,24 @@
|
|||
description = "haskell-template's description";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils/v1.0.0";
|
||||
flake-utils.inputs.nixpkgs.follows = "nixpkgs";
|
||||
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";
|
||||
};
|
||||
|
||||
# Consider this to be a function producing Flake outputs for the given system
|
||||
# and inputs; viz.:
|
||||
#
|
||||
# mkOutputsFrom :: Set Inputs -> System -> Set Outputs
|
||||
# mkOutputsFrom inputs system = { ... }
|
||||
#
|
||||
# We use eachDefaultSystem to allow other architectures.
|
||||
# We use flake-parts as a way to make flakes 'system-aware'
|
||||
# cf. https://github.com/NixOS/nix/issues/3843#issuecomment-661720562
|
||||
outputs = inputs:
|
||||
inputs.flake-utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
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, ... }:
|
||||
let
|
||||
name = "haskell-template";
|
||||
|
||||
# Because: https://zimbatm.com/notes/1000-instances-of-nixpkgs
|
||||
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
||||
inherit (pkgs.lib.lists) optionals;
|
||||
|
||||
# Specify GHC version here. To get the appropriate value, run:
|
||||
|
@ -54,7 +49,7 @@
|
|||
# Use callCabal2nix to override Haskell dependencies here
|
||||
# cf. https://tek.brick.do/K3VXJd8mEKO7
|
||||
# Example:
|
||||
# > NanoID = self.callCabal2nix "NanoID" inputs.NanoID { };
|
||||
# > NanoID = self.callCabal2nix "NanoID" inputs'.NanoID { };
|
||||
# Assumes that you have the 'NanoID' flake input defined.
|
||||
};
|
||||
modifier = drv:
|
||||
|
@ -75,17 +70,13 @@
|
|||
apps = {
|
||||
default = {
|
||||
type = "app";
|
||||
program = "${inputs.self.packages.${system}.default}/bin/${name}";
|
||||
program = "${self'.packages.default}/bin/${name}";
|
||||
};
|
||||
};
|
||||
# Used by `nix develop ...`
|
||||
devShells = {
|
||||
default = project { returnShellEnv = true; withHoogle = true; };
|
||||
};
|
||||
# For compatability with older Nix (eg in CI)
|
||||
devShell = inputs.self.devShells.${system}.default;
|
||||
defaultPackage = inputs.self.packages.${system}.default;
|
||||
defaultApp = inputs.self.apps.${system}.default;
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue