Skip to content

Commit 3d4c1be

Browse files
author
Andreas Hindborg
committed
build: add nix package and docs in nix flake
1 parent 6eed0ff commit 3d4c1be

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

flake.nix

+43-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
# To use get a shell ready to build the website run `nix develop`.
2+
#
3+
# To set up automatic rendering of the HTML in the development shell, run:
4+
#
5+
# python3 pre.py
6+
# mdbook watch
7+
#
8+
# If you also want to serve the HTML from a local webserver, run
9+
#
10+
# python3 pre.py
11+
# mdbook serve
12+
#
13+
# To build the book:
14+
#
15+
# nix build .\#default
16+
#
17+
# The build artifacts are available through the symlink `result` in the current
18+
# working directory directory.
19+
#
20+
# Note: flakes and the `nix` command are experimental and must be enabled
21+
# explicitly [1][2]. Also see the NixOS Wiki entry on flakes [3].
22+
#
23+
# [1] https://nix.dev/manual/nix/2.17/contributing/experimental-features#xp-feature-nix-command
24+
# [2] https://nix.dev/manual/nix/2.17/contributing/experimental-features#xp-feature-flakes
25+
# [3] https://nixos.wiki/wiki/Flakes
126

227
{
328
description = "Shell for building rust-for-linux.com";
@@ -14,12 +39,26 @@
1439
system:
1540
let
1641
pkgs = nixpkgs.legacyPackages.${system};
17-
in
18-
{
19-
devShells.default = pkgs.mkShell { packages = with pkgs; [
42+
buildDeps = with pkgs; [
2043
python3
2144
mdbook
22-
]; };
45+
];
46+
in
47+
{
48+
devShells.default = pkgs.mkShell { packages = buildDeps; };
49+
packages.default = pkgs.stdenv.mkDerivation {
50+
name = "rust-for-linux.com";
51+
nativeBuildInputs = buildDeps;
52+
src = ./.;
53+
buildPhase = ''
54+
python3 pre.py
55+
mdbook build
56+
python3 post.py
57+
'';
58+
installPhase = ''
59+
cp -r book $out
60+
'';
61+
};
2362
}
2463
);
2564
}

0 commit comments

Comments
 (0)