Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: nix-flake-check

on:
pull_request:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.2

- name: "Install Nix️"
uses: cachix/install-nix-action@v16


- name: "Why am I dirty?"
run: git status

- name: "Nix Flake Check"
run: nix -L flake check
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ You can also use `tut` in posts. See `posts/2016-09-30-subtype-typeclasses.md` f

### Previewing your changes

#### Bundler

To preview your changes, you have to install [Bundler](https://bundler.io/) first.
To download and set up all necessary dependencies, run

```bash
```console
$ bundle install
... lots of text ...
Bundle complete! 1 Gemfile dependency, 81 gems now installed.
Expand All @@ -38,12 +40,55 @@ Bundled gems are installed into `./vendor/bundle`

Then, you can generate the site by running

```
```console
$ bundle exec jekyll serve -wl --baseurl ''
```

The generated site will end up in the `_site` directory.

#### Nix

A fully configured Jekyll is available as a Nix app. Flakes required:

```console
$ nix run github:typelevel/typelevel.github.com#jekyll build
warning: Git tree '/Users/ross.baker/src/typelevel.github.com' is dirty
Configuration file: /Users/ross.baker/src/typelevel.github.com/_config.yml
Source: /Users/ross.baker/src/typelevel.github.com
Destination: /Users/ross.baker/src/typelevel.github.com/_site
Incremental build: disabled. Enable with --incremental
Generating...
done in 3.635 seconds.
Auto-regeneration: disabled. Use --watch to enable.
```

There is also a devshell for direct invocation, and a convenient alias:

```console
$ nix develop github:typelevel/typelevel.github.com
🔨 Welcome to typelevel-org-shell

[general commands]

jekyll - a jekyll bundled with this site's dependencies
menu - prints this menu
tl-preview - preview the Jekyll site

$ tl-preview
Configuration file: /home/you/src/typelevel.github.com/_config.yml
Source: /home/you/src/typelevel.github.com
Destination: /home/you/src/typelevel.github.com/_site
Incremental build: disabled. Enable with --incremental
Generating...
done in 3.336 seconds.
Auto-regeneration: enabled for '/home/you/src/typelevel.github.com'
LiveReload address: http://127.0.0.1:35729
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.
```



## License

Unless otherwise noted, all website content is licensed under a [Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/deed.en_US).
Expand Down
59 changes: 59 additions & 0 deletions flake.lock

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

63 changes: 63 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
description = "Virtual environment for typelevel.org site";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
devshell.url = "github:numtide/devshell";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils, devshell, ... }:
let
forSystem = system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlay ];
};

gems = pkgs.bundlerEnv {
name = "typelevel-org-bundler-env";
inherit (pkgs) ruby;
gemdir = ./.;
};
in
{
apps.jekyll = {
type = "app";
program = "${gems}/bin/jekyll";
};

checks = {
build-site = pkgs.stdenv.mkDerivation {
name = "build-site";
buildInputs = [ gems pkgs.glibcLocales ];
src = ./.;
buildPhase = ''
export LANG=en_US.UTF-8
${gems}/bin/jekyll build
cp -a _site $out
'';
dontInstall = true;
};
};

devShell = pkgs.devshell.mkShell {
name = "typelevel-org-shell";
commands = [
{
name = "jekyll";
help = "a jekyll bundled with this site's dependencies";
command = "${gems}/bin/jekyll $@";
}
{
name = "tl-preview";
help = "preview the Jekyll site";
command = "${gems}/bin/jekyll serve -wl --baseurl ''";
}
];
};
};
in
flake-utils.lib.eachDefaultSystem forSystem;
}
Loading