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:
|
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
|
- 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
|
- [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
|
- 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:
|
Renaming the project:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
# First, click the green "Use this template" button on GitHub to create your copy.
|
||||||
git clone <your-clone-url>
|
git clone <your-clone-url>
|
||||||
cd your-project
|
cd your-project
|
||||||
NAME=myproject
|
NAME=myproject
|
||||||
|
|
24
flake.lock
generated
24
flake.lock
generated
|
@ -16,19 +16,23 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils": {
|
"flake-parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1652776076,
|
"lastModified": 1653510071,
|
||||||
"narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=",
|
"narHash": "sha256-KoBs0USqNunyxaBOYx/trSREMf8f3fA+msDfADiMI5o=",
|
||||||
"owner": "numtide",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-parts",
|
||||||
"rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8",
|
"rev": "c7d1a3d10117247892df7db45cef562bf62789d5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "hercules-ci",
|
||||||
"ref": "v1.0.0",
|
"repo": "flake-parts",
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -51,7 +55,7 @@
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"flake-utils": "flake-utils",
|
"flake-parts": "flake-parts",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
35
flake.nix
35
flake.nix
|
@ -2,29 +2,24 @@
|
||||||
description = "haskell-template's description";
|
description = "haskell-template's description";
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||||
flake-utils.url = "github:numtide/flake-utils/v1.0.0";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
flake-utils.inputs.nixpkgs.follows = "nixpkgs";
|
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
flake-compat.url = "github:edolstra/flake-compat";
|
flake-compat.url = "github:edolstra/flake-compat";
|
||||||
flake-compat.flake = false;
|
flake-compat.flake = false;
|
||||||
flake-compat.inputs.nixpkgs.follows = "nixpkgs";
|
flake-compat.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Consider this to be a function producing Flake outputs for the given system
|
# We use flake-parts as a way to make flakes 'system-aware'
|
||||||
# and inputs; viz.:
|
|
||||||
#
|
|
||||||
# mkOutputsFrom :: Set Inputs -> System -> Set Outputs
|
|
||||||
# mkOutputsFrom inputs system = { ... }
|
|
||||||
#
|
|
||||||
# We use eachDefaultSystem to allow other architectures.
|
|
||||||
# cf. https://github.com/NixOS/nix/issues/3843#issuecomment-661720562
|
# cf. https://github.com/NixOS/nix/issues/3843#issuecomment-661720562
|
||||||
outputs = inputs:
|
outputs = { self, nixpkgs, flake-parts, ... }:
|
||||||
inputs.flake-utils.lib.eachDefaultSystem
|
flake-parts.lib.mkFlake { inherit self; } {
|
||||||
(system:
|
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
|
let
|
||||||
name = "haskell-template";
|
name = "haskell-template";
|
||||||
|
|
||||||
# Because: https://zimbatm.com/notes/1000-instances-of-nixpkgs
|
|
||||||
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
|
||||||
inherit (pkgs.lib.lists) optionals;
|
inherit (pkgs.lib.lists) optionals;
|
||||||
|
|
||||||
# Specify GHC version here. To get the appropriate value, run:
|
# Specify GHC version here. To get the appropriate value, run:
|
||||||
|
@ -54,7 +49,7 @@
|
||||||
# Use callCabal2nix to override Haskell dependencies here
|
# Use callCabal2nix to override Haskell dependencies here
|
||||||
# cf. https://tek.brick.do/K3VXJd8mEKO7
|
# cf. https://tek.brick.do/K3VXJd8mEKO7
|
||||||
# Example:
|
# Example:
|
||||||
# > NanoID = self.callCabal2nix "NanoID" inputs.NanoID { };
|
# > NanoID = self.callCabal2nix "NanoID" inputs'.NanoID { };
|
||||||
# Assumes that you have the 'NanoID' flake input defined.
|
# Assumes that you have the 'NanoID' flake input defined.
|
||||||
};
|
};
|
||||||
modifier = drv:
|
modifier = drv:
|
||||||
|
@ -75,17 +70,13 @@
|
||||||
apps = {
|
apps = {
|
||||||
default = {
|
default = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = "${inputs.self.packages.${system}.default}/bin/${name}";
|
program = "${self'.packages.default}/bin/${name}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
# Used by `nix develop ...`
|
# Used by `nix develop ...`
|
||||||
devShells = {
|
devShells = {
|
||||||
default = project { returnShellEnv = true; withHoogle = true; };
|
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