Skip to content

Commit

Permalink
nix: Upgrade haskell-flake/flake-parts (#41)
Browse files Browse the repository at this point in the history
* nix: Update haskell-flake & flake-parts

Adapt to their API changes.

* readme: Update links

* nix: Simplify shell.nix
  • Loading branch information
srid authored Nov 17, 2023
1 parent 371a853 commit f9643f2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 34 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ Install Nix, enable Flakes (see below) and then run `bin/run` to get the site up

To develop with full IDE support in Visual Studio Code, follow these steps:

- [Install Nix](https://nixos.org/download.html) & [enable Flakes](https://nixos.wiki/wiki/Flakes)
- Run `nix develop -c haskell-language-server` to sanity check your environment
- [Install Nix](https://zero-to-flakes.com/install/)
- Run `nix develop -c haskell-language-server` to sanity check your environment
- Open the repository [as single-folder workspace](https://code.visualstudio.com/docs/editor/workspaces#_singlefolder-workspaces) in Visual Studio Code
- Install the recommended extensions
- <kbd>Ctrl+Shift+P</kbd> to run the command "Nix-Env: Select Environment" and select `shell.nix`. The extension will ask you to reload VSCode at the end.
- Press <kbd>Ctrl+Shift+B</kbd> in VSCode, or run `bin/run` in terminal, to launch the Ema dev server, and navigate to http://localhost:8081/

All but the final step need to be done only once. Check [the Ema tutorial](https://ema.srid.ca/start/tutorial) next.
All but the final step need to be done only once. Check [the Ema tutorial](https://ema.srid.ca/tutorial) next.

## Note

Expand All @@ -24,11 +24,11 @@ All but the final step need to be done only once. Check [the Ema tutorial](https
- Configuration:
- To change the port (or the Ema CLI arguments, used by `bin/run`), see `./.ghcid` (if you leave out `--port` a random port will be used)
- To update Ema to the latest Git revision, run `nix flake lock --update-input ema` or just `nix flake update` (the latter updates all Nix inputs)
- Be sure to check https://ema.srid.ca/guide/upgrade for changes needed.
- To add/remove Haskell dependencies, see the .cabal file. If a dependency is unavailable in nixpkgs, you can override it (to point to say a Git repo) in the `source-overrides` (or `overrides` if you need more power) attribute of flake.nix. You can imitate the manner in which the `ema` package itself is overridden.
- Be sure to check https://ema.srid.ca/start/upgrade for changes needed.
- To add/remove Haskell dependencies, see https://zero-to-flakes.com/haskell-flake/dependency/
- To generate the site, run:
```sh
mkdir /tmp/site
mkdir /tmp/site
nix run . -- gen /tmp/site
```
- You might want to change or remove the `<base>` tag in `Main.hs` depending on where you will be deploying the site.
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# This is a modular Nix flake
# Learn about it here: https://zero-to-flakes.com/
{
description = "Ema template app";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
};
outputs = { self, nixpkgs, flake-parts, haskell-flake, ... }:
flake-parts.lib.mkFlake { inherit self; } {
outputs = inputs@{ self, nixpkgs, flake-parts, haskell-flake, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [
haskell-flake.flakeModule
];
perSystem = { self', config, inputs', pkgs, lib, ... }: {
perSystem = { self', inputs', pkgs, lib, ... }: {
# "haskellProjects" comes from https://github.com/srid/haskell-flake
haskellProjects.default = {
packages.fpindia-site.root = ./.;
buildTools = hp: {
devShell.tools = hp: {
inherit (pkgs)
treefmt
nixpkgs-fmt
Expand All @@ -26,9 +27,10 @@
fourmolu
tailwind;
};
overrides = self: super: { };
# Want to override Haskell dependencies?
# See https://zero-to-flakes.com/haskell-flake/dependency
};
packages.default = config.packages.fpindia-site;
packages.default = self'.packages.fpindia-site;
apps.tailwind-run.program = "${lib.getExe pkgs.haskellPackages.tailwind}";
};
};
Expand Down
13 changes: 1 addition & 12 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
# TODO: Remove this after https://github.com/srid/haskell-template/issues/23

(import
(
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/b4a34015c698c7793d592d66adbab377907a2be8.tar.gz";
sha256 = "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=";
}
)
{
src = ./.;
}).shellNix
(builtins.getFlake ("git+file://" + toString ./.)).devShells.${builtins.currentSystem}.default

0 comments on commit f9643f2

Please sign in to comment.