From 3fcadaf275c7ccb4892150993650b10fb6dec9ac Mon Sep 17 00:00:00 2001 From: zowoq <59103226+zowoq@users.noreply.github.com> Date: Sat, 25 May 2024 10:15:05 +1000 Subject: [PATCH] docs: refactor, move out of flake.nix also filter source to limit rebuilds --- .github/workflows/pages.yml | 2 +- dev/docs.nix | 27 +++++++++++++++++++++++++++ dev/shell.nix | 5 ----- flake.nix | 15 +++------------ 4 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 dev/docs.nix diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index aa74477..45d7d87 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -31,7 +31,7 @@ jobs: uses: actions/configure-pages@v5 - name: Build Pages run: | - nix build .#pages + nix build .#docs - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: diff --git a/dev/docs.nix b/dev/docs.nix new file mode 100644 index 0000000..4afdb8f --- /dev/null +++ b/dev/docs.nix @@ -0,0 +1,27 @@ +{ config, pkgs, ... }: +{ + devShells.mkdocs = pkgs.mkShellNoCC { + inputsFrom = [ + config.packages.docs + ]; + }; + packages = { + docs = pkgs.runCommand "docs" + { + buildInputs = [ + pkgs.python3.pkgs.mkdocs-material + ]; + files = pkgs.lib.fileset.toSource { + root = ../.; + fileset = pkgs.lib.fileset.unions [ + ../docs + ../mkdocs.yml + ]; + }; + } + '' + cd $files + mkdocs build --strict --site-dir $out + ''; + }; +} diff --git a/dev/shell.nix b/dev/shell.nix index a02bd89..70a3cab 100644 --- a/dev/shell.nix +++ b/dev/shell.nix @@ -11,11 +11,6 @@ ssh-to-age ]; }; - mkdocs = with pkgs; mkShellNoCC { - packages = [ - python3.pkgs.mkdocs-material - ]; - }; sotp = with pkgs; mkShellNoCC { packages = [ (buildGoModule rec { diff --git a/flake.nix b/flake.nix index fcc9865..f196bcf 100644 --- a/flake.nix +++ b/flake.nix @@ -55,9 +55,10 @@ inputs.treefmt-nix.flakeModule ]; - perSystem = { config, inputs', lib, pkgs, self', system, ... }: + perSystem = { inputs', lib, pkgs, self', system, ... }: { imports = [ + ./dev/docs.nix ./dev/shell.nix ./terraform/shell.nix ]; @@ -82,23 +83,13 @@ darwinConfigurations // devShells // { inherit (self') formatter; } // nixosConfigurations // pkgs.lib.optionalAttrs (system == "x86_64-linux") { - inherit (self'.packages) pages; + inherit (self'.packages) docs; nixpkgs-update-supervisor-test = pkgs.callPackage ./hosts/build02/supervisor_test.nix { }; nixosTests-buildbot = pkgs.nixosTests.buildbot; nixosTests-buildbot-nix-master = inputs'.buildbot-nix.checks.master; nixosTests-buildbot-nix-worker = inputs'.buildbot-nix.checks.worker; nixosTests-hydra = pkgs.nixosTests.hydra.hydra_unstable; }; - - packages = { - pages = pkgs.runCommand "pages" - { - buildInputs = [ config.devShells.mkdocs.nativeBuildInputs ]; - } '' - cd ${self} - mkdocs build --strict --site-dir $out - ''; - }; }; flake.darwinConfigurations =