add devmode for live preview

This commit is contained in:
Valentin Gagarin 2024-11-13 15:24:41 +01:00 committed by Valentin Gagarin
parent 897acd2a5c
commit f837b436d7
3 changed files with 23 additions and 7 deletions

View file

@ -15,18 +15,15 @@ Structured content is managed through Nix expressions, and copy is written in [C
- [Install Nix](https://nix.dev/install-nix)
- [Set up `direnv`](https://github.com/nix-community/nix-direnv#installation)
- Run `direnv allow` in the directory where repository is stored on your machine
- Edit any of the files, see [repository layout](#repository-layout) for guidance
- Build and view the web site
- Start a live preview in a different terminal:
```bash
xdg-open $(nix-build -A build --no-out-link)/index.html
devmode
```
or
This will open your default web browser and automatically reload the page when the source changes.
```fish
open (nix-build -A build --no-out-link)/index.html
```
- Edit any of the files, see [repository layout](#repository-layout) for guidance
# Repository layout

View file

@ -14,6 +14,12 @@ let
in
new // { types = prev.recursiveUpdate prev.types new.types; };
lib'' = lib.extend lib';
# TODO: update when the PR to expose `pkgs.devmode` is merged
# https://github.com/NixOS/nixpkgs/pull/354556
devmode = pkgs.callPackage "${sources.devmode-reusable}/pkgs/by-name/de/devmode/package.nix" {
buildArgs = "${toString ./.} -A build";
open = "/index.html";
};
in
rec {
lib = import ./lib.nix { inherit lib; };
@ -36,6 +42,7 @@ rec {
packages = with pkgs; [
cmark
npins
devmode
];
};
}

View file

@ -1,5 +1,17 @@
{
"pins": {
"devmode-reusable": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "fricklerhandwerk",
"repo": "nixpkgs"
},
"branch": "refactor-devmode",
"revision": "f0746a6690939987734d6519a2e3daf28ed36d87",
"url": "https://github.com/fricklerhandwerk/nixpkgs/archive/f0746a6690939987734d6519a2e3daf28ed36d87.tar.gz",
"hash": "011kg3c2mfy7y808llpmq3hf6vv6rlazx8m11w41pnym4kwr3ivz"
},
"nixpkgs": {
"type": "Channel",
"name": "nixpkgs-unstable",