From dcb6afa492f93b52ef39d6e0bf696d45e7334387 Mon Sep 17 00:00:00 2001 From: valentin gagarin Date: Wed, 13 Nov 2024 15:24:41 +0100 Subject: [PATCH] add devmode for live preview --- README.md | 11 ++++------- default.nix | 7 +++++++ npins/sources.json | 12 ++++++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 845d52f8..64e781b8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/default.nix b/default.nix index daad6a00..fba35ba5 100644 --- a/default.nix +++ b/default.nix @@ -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 ]; }; } diff --git a/npins/sources.json b/npins/sources.json index ea60a220..ebb34b2e 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -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",