Skip to content

Commit

Permalink
refactor: flake for better docs support
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelroses committed Feb 10, 2024
1 parent c07dbb7 commit 4a7e37f
Show file tree
Hide file tree
Showing 34 changed files with 29 additions and 29 deletions.
9 changes: 5 additions & 4 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@
-[Lilith](../hosts/lilith/) A NixOS ISO image that can be quickly deployed and accessed via ssh
- 🪄 [Luz](../hosts/luz/) A server configuration for some of my infrastructure
- 𖤍 [Valkyrie](../hosts/valkyrie/) A WSL2 machine
- ⚠️ [Tatsumaki](../hosts/tatsumaki/) A WIP macOS host
- 📖 [lib](../lib/) Useful repeated functions
- 💮 [Tatsumaki](../hosts/tatsumaki/) A WIP macOS host
- 📚 [lib](../lib/) Useful repeated functions
- 🧩 [flake](../flake/) NixOS parts breaking down the complex configuration into smaller more manageable chunks
- 📝 [docs](../docs/) Documentation for the configuration which can be found [here](https://isabelroses.github.io/dotfiles/)
- 🔌 [modules](../modules/)
- [base](../modules/base/) The base configuration settings, which are common between all systems
- [options](../modules/options/) Selectable settings that can be used to toggle certain settings
- [extra](../modules/extra) Extra configuration modules, for home-manager and NixOS
- [options](../modules/base/options/) Selectable settings that can be used to toggle certain settings
- [extra](../modules/extra) Extra configuration modules, for home-manager and Nix Darwin and NixOS
- [profiles](../modules/profiles/) System type configurations (e.g. laptop, servers, desktop)

### Install Notes
Expand Down
25 changes: 12 additions & 13 deletions flake/pkgs/docs/default.nix → docs/default.nix
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
# All credits to @nekowinston for this script
# See https://github.com/nekowinston/nur
# modfied from https://github.com/nekowinston/nur/blob/49cfefd3c252f4c56725df01f817d1a8b93447d8/docs/default.nix
{
lib,
pkgs,
...
}: let
inherit (lib) mkForce filterAttrs scrubDerivations removePrefix;

mkEval = module:
lib.evalModules {
modules = [
module
{
_module = {
pkgs = lib.mkForce (lib.scrubDerivations "pkgs" pkgs);
pkgs = mkForce (scrubDerivations "pkgs" pkgs);
check = false;
};
}
];
specialArgs = {inherit pkgs;};
};

css = ./pandoc.css;

goBack = ../../..;

mkDoc = name: options: let
doc = pkgs.nixosOptionsDoc {
options = lib.filterAttrs (n: _: n != "_module") options;
options = filterAttrs (n: _: n != "_module") options;
documentType = "none";
transformOptions = opt:
opt
// {
declarations =
map
(decl:
if lib.hasPrefix (toString (goBack + /.)) (toString decl)
if lib.hasPrefix (toString ../.) (toString decl)
then let
subpath = lib.removePrefix "/" (lib.removePrefix (toString (goBack + /.)) (toString decl));
subpath = removePrefix "/" (removePrefix (toString ../.) (toString decl));
in {
url = "https://github.com/isabelroses/dotfiles/tree/main/${subpath}";
name = subpath;
Expand All @@ -56,19 +54,20 @@
convert = md:
pkgs.runCommand "isabelroses-dotfiles.html" {nativeBuildInputs = with pkgs; [pandoc texinfo];} ''
mkdir $out
cp ${css} style.css
cp ${./pandoc.css} style.css
pandoc -o file.texi ${builtins.concatStringsSep " " md}
texi2any ./file.texi --html --split=chapter --css-include=./style.css --document-language=en -o $out
'';

modulesPath = goBack + /modules;
modulesPath = ../modules;
extraModulesPath = modulesPath + /extra;

# interalEval = mkEval (import (modulesPath + /options));
# internalEval = mkEval (import (modulesPath + /base));
nixosEval = mkEval (import (extraModulesPath + /nixos));
darwinEval = mkEval (import (extraModulesPath + /darwin));
hmEval = mkEval (import (extraModulesPath + /home-manager));
# internal = mkDoc "internal" interalEval.options;

# internal = mkDoc "internal" internalEval.options.modules;
nixos = mkDoc "nixos" nixosEval.options;
darwin = mkDoc "darwin" darwinEval.options;
hm = mkDoc "home-manager" hmEval.options;
Expand Down
File renamed without changes.
6 changes: 4 additions & 2 deletions flake/modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
in {
flake = {
nixosModules = {
wakapi = mkModule /modules/extra/nixos/wakapi;
internal = mkModule /modules/base;

wakapi = mkModule /modules/extra/nixos/wakapi.nix;

# i do not provide a default module, so throw an error
default = builtins.throw "There is no default module.";
Expand All @@ -18,7 +20,7 @@ in {
};

homeManagerModules = {
gtklock = mkModule /modules/extra/home-manager/gtklock;
gtklock = mkModule /modules/extra/home-manager/gtklock.nix;

default = builtins.throw "There is no default module.";
};
Expand Down
2 changes: 1 addition & 1 deletion flake/pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ _: {
...
}: {
packages = let
docs = pkgs.callPackage ./docs {};
docs = pkgs.callPackage ../../docs {};
in {
# docs-md = docs.md;
docs-html = docs.html;
Expand Down
5 changes: 1 addition & 4 deletions hosts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
# base modules, are the base of this system configuration and are shared across all systems (so the basics)
base = modulePath + /base;

# options module, these allow for quick configuration
options = modulePath + /options;

# profiles module, these are sensible defaults for given hardware sets
# or meta profiles that are used to configure the system based on the requirements of the given machine
profilesPath = modulePath + /profiles; # the base directory for the types module
Expand All @@ -35,7 +32,7 @@
homes = ../home; # home-manager configurations

# a list of shared modules
shared = [base options homes];
shared = [base homes];

# extra specialArgs that are on all machines
sharedArgs = {inherit lib;};
Expand Down
3 changes: 2 additions & 1 deletion modules/base/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
_: {
{
imports = [
./host # host configurations
./gaming # super cool procrastinations related things
./options # options module, these allow for quick configuration
./secrets # shhh
./services # allows for per-system system services to be enabled
];
Expand Down
2 changes: 1 addition & 1 deletion modules/base/host/hardware/media/sound/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
lib,
config,
pkgs,
config,
inputs,
...
}: let
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion modules/extra/home-manager/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
imports = [
./gtklock
./gtklock.nix
];
}
File renamed without changes.
4 changes: 2 additions & 2 deletions modules/extra/nixos/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_: {
{
imports = [
./wakapi
./wakapi.nix
];
}
File renamed without changes.

0 comments on commit 4a7e37f

Please sign in to comment.