1
0
Fork 0
mirror of https://github.com/NixOS/nix.dev.git synced 2024-10-18 14:32:43 -04:00

move devmode helper into flake

this cleans up the top-level directory and hopefully makes the setup
slightly more obvious

Co-authored-by: Alejandro Sanchez Medina <alejandrosanchzmedina@gmail.com>
This commit is contained in:
fricklerhandwerk 2023-10-18 12:04:34 +02:00
parent 8c657ffcc1
commit 42add6566d
4 changed files with 35 additions and 27 deletions

View file

@ -7,7 +7,7 @@ Official documentation for getting things done with Nix.
## Contributing ## Contributing
Run `./live` and open a browser at <http://localhost:5500>. Run `nix-shell --run devmode` and open a browser at <http://localhost:5500>.
As you make changes your browser should auto-reload within a few seconds. As you make changes your browser should auto-reload within a few seconds.

View file

@ -4,7 +4,7 @@
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils}: outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
pkgs = import nixpkgs { pkgs = import nixpkgs {
@ -15,7 +15,36 @@
(import ./overlay.nix) (import ./overlay.nix)
]; ];
}; };
in { devmode =
let
pythonEnvironment = pkgs.python310.withPackages (ps: with ps; [
livereload
]);
script = ''
from livereload import Server, shell
server = Server()
build_docs = shell("nix build")
print("Doing an initial build of the docs...")
build_docs()
server.watch("source/*", build_docs)
server.watch("source/**/*", build_docs)
server.watch("_templates/*.html", build_docs)
server.serve(root="result/")
'';
in
pkgs.writeShellApplication {
name = "devmode";
runtimeInputs = [ pythonEnvironment ];
text = ''
python ${pkgs.writeText "live.py" script}
'';
};
in
{
packages.default = pkgs.stdenv.mkDerivation { packages.default = pkgs.stdenv.mkDerivation {
name = "nix-dev"; name = "nix-dev";
src = self; src = self;
@ -39,17 +68,10 @@
}; };
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
buildInputs = with pkgs.python310.pkgs; [ inputsFrom = [ self.packages.${system}.default ];
packages = with pkgs.python310.pkgs; [
black black
livereload devmode
linkify-it-py
myst-parser
sphinx
sphinx-book-theme
sphinx-copybutton
sphinx-design
sphinx-notfound-page
sphinx-sitemap
]; ];
}; };
} }

1
live
View file

@ -1 +0,0 @@
nix-shell --run "python live.py"

13
live.py
View file

@ -1,13 +0,0 @@
from livereload import Server, shell
server = Server()
build_docs = shell("make html")
print("Doing an initial build of the docs...")
build_docs()
server.watch("source/*", build_docs)
server.watch("source/**/*", build_docs)
server.watch("_templates/*.html", build_docs)
server.serve(root="build/html")