11.stylix/flake/dev-shell.nix
Matt Sturgeon 82d9424fff
doc: init server; nix run .#docs (#1328)
Adds:

- `serve-docs` to the default devShell
- `packages.serve-docs`
- `apps.docs`

Having `apps.docs` defined causes `nix run .#docs` to run the "app"
instead of `packages.docs`. `nix build .#docs` will still build the
"package", not the "app".

The `serve-docs` script added to the devShell runs `nix run .#docs`
instead of having `packages.serve-docs` in its closure. This avoids the
devShell actually building the docs.

Added a note to `doc/src/modules.md`.

Link: https://github.com/nix-community/stylix/pull/1328

Reviewed-by: awwpotato <awwpotato@voidq.com>
Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
2025-06-03 19:01:51 +02:00

64 lines
1.8 KiB
Nix

{
perSystem =
{
pkgs,
config,
inputs',
...
}:
let
stylix-check = pkgs.writeShellApplication {
name = "stylix-check";
runtimeInputs = with pkgs; [
nix
nix-fast-build
];
text = ''
cores="$(nproc)"
system="$(nix eval --expr builtins.currentSystem --impure --raw)"
nix-fast-build \
--eval-max-memory-size 512 \
--eval-workers "$cores" \
--flake ".#checks.$system" \
--no-link \
--skip-cached \
"$@"
'';
};
# The shell should not directly depend on `packages.serve-docs`, because
# that'd build the docs before entering the shell. Instead, we want to
# build the docs only when running 'serve-docs'.
#
# For a similar reason, we can't use `self` as a reference to the flake:
# `self` represents the flake as it was when the devshell was evaluated,
# not the local flake worktree that has possibly been modified since
# entering the devshell.
build-and-run-docs = pkgs.writeShellScriptBin "serve-docs" ''
nix run .#docs
'';
in
{
devShells = {
default = pkgs.mkShell {
# Install git-hooks when activating the shell
shellHook = config.pre-commit.installationScript;
packages =
[
stylix-check
build-and-run-docs
inputs'.home-manager.packages.default
config.formatter
]
++ config.pre-commit.settings.enabledPackages
++ config.formatter.runtimeInputs;
};
ghc = pkgs.mkShell {
inputsFrom = [ config.devShells.default ];
packages = [ pkgs.ghc ];
};
};
};
}