Skip to content

Commit

Permalink
move devmode helper into flake
Browse files Browse the repository at this point in the history
this cleans up the top-level directory and hopefully makes the setup
slightly more obvious

Co-authored-by: Alejandro Sanchez Medina <alejandrosanchzmedina@gmail.com>
  • Loading branch information
fricklerhandwerk and alejandrosame committed Oct 18, 2023
1 parent 8c657ff commit 42add65
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Official documentation for getting things done with Nix.

## 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.

Expand Down
46 changes: 34 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = { self, nixpkgs, flake-utils}:
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
Expand All @@ -15,7 +15,36 @@
(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 {
name = "nix-dev";
src = self;
Expand All @@ -39,17 +68,10 @@
};

devShells.default = pkgs.mkShell {
buildInputs = with pkgs.python310.pkgs; [
inputsFrom = [ self.packages.${system}.default ];
packages = with pkgs.python310.pkgs; [
black
livereload
linkify-it-py
myst-parser
sphinx
sphinx-book-theme
sphinx-copybutton
sphinx-design
sphinx-notfound-page
sphinx-sitemap
devmode
];
};
}
Expand Down
1 change: 0 additions & 1 deletion live

This file was deleted.

13 changes: 0 additions & 13 deletions live.py

This file was deleted.

0 comments on commit 42add65

Please sign in to comment.