diff --git a/README.md b/README.md index 5cc06c3..4d348ff 100644 --- a/README.md +++ b/README.md @@ -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 cd your-project NAME=myproject diff --git a/flake.lock b/flake.lock index 2e1fe9c..7107e0c 100644 --- a/flake.lock +++ b/flake.lock @@ -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" } } diff --git a/flake.nix b/flake.nix index 39edc8f..c2b995d 100644 --- a/flake.nix +++ b/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; - } - ); + }; + }; }