From 2cd801aa2b2b6fc50df6ca8782b86d78619f631b Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Mon, 13 Nov 2023 04:31:54 +0100 Subject: [PATCH] Add module documentation --- README.md | 18 +++++----- history.md => docs/history.md | 0 .../2023-11-08-neovim-zathura-and-anyrun.png | Bin {img => docs/img}/2023-11-08-neovim.png | Bin {img => docs/img}/2023-11-08-poweroff.png | Bin home/features/wayland/hyprland/default.nix | 2 +- home/tethys.nix | 12 +++---- modules/README.md | 34 ++++++++++++++++++ modules/common/lua-colorscheme.nix | 2 +- modules/common/toggles.nix | 9 +++++ modules/home-manager/eww-hyprland.nix | 6 ++-- modules/home-manager/monitors.nix | 2 +- 12 files changed, 66 insertions(+), 19 deletions(-) rename history.md => docs/history.md (100%) rename {img => docs/img}/2023-11-08-neovim-zathura-and-anyrun.png (100%) rename {img => docs/img}/2023-11-08-neovim.png (100%) rename {img => docs/img}/2023-11-08-poweroff.png (100%) create mode 100644 modules/README.md diff --git a/README.md b/README.md index 4ceb307..8411f07 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ In case you are not familiar with nix/nixos, this is a collection of configuration files which build all my systems in a declarative manner. The tool used to configure the global system is called [nixos](https://nixos.org/), and the one used to configure the individual users is called [home-manager](https://github.com/nix-community/home-manager). -> A [visual history](./history.md) of my setup is in the works! +> A [visual history](./docs/history.md) of my setup is in the works! ## Features this repository includes: @@ -25,17 +25,19 @@ This repo's structure is based on the concept of hosts - individual machines con | Location | Description | | ---------------------------- | ------------------------------------------------------------------ | | [common](./common) | Configuration loaded on both nixos and home-manager | -| [dotfiles](./dotfiles) | Contains some of the bigger dotfile dirs. Will eventually be moved | -| [hosts/nixos](./hosts/nixos) | Nixos configurations | -| [home](./home) | Home manager configurations | -| [pkgs](./pkgs) | Nix packages | -| [overlays](./overlays) | Nix overlays | | [devshells](./devshells) | Nix shells | -| [stylua.toml](./stylua.toml) | Lua formatter config for the repo | +| [docs](./docs) | Additional documentation regarding my setup | +| [dotfiles](./dotfiles) | Contains some of the bigger dotfile dirs. Will eventually be moved | +| [home](./home) | Home manager configurations | +| [hosts/nixos](./hosts/nixos) | Nixos configurations | +| [modules](./modules) | Custom generic/nixos/home-manager modules | +| [overlays](./overlays) | Nix overlays | +| [pkgs](./pkgs) | Nix packages | | [flake.nix](./flake.nix) | Nix flake entrypoint! | -| [shell.nix](./shell.nix) | Bootstrapping nix shell | | [nixpkgs.nix](./nixpkgs.nix) | Pinned nixpkgs for bootstrapping | | [secrets.nix](./secrets.nix) | Agenix entrypoint | +| [shell.nix](./shell.nix) | Bootstrapping nix shell | +| [stylua.toml](./stylua.toml) | Lua formatter config for the repo | ## Points of interest diff --git a/history.md b/docs/history.md similarity index 100% rename from history.md rename to docs/history.md diff --git a/img/2023-11-08-neovim-zathura-and-anyrun.png b/docs/img/2023-11-08-neovim-zathura-and-anyrun.png similarity index 100% rename from img/2023-11-08-neovim-zathura-and-anyrun.png rename to docs/img/2023-11-08-neovim-zathura-and-anyrun.png diff --git a/img/2023-11-08-neovim.png b/docs/img/2023-11-08-neovim.png similarity index 100% rename from img/2023-11-08-neovim.png rename to docs/img/2023-11-08-neovim.png diff --git a/img/2023-11-08-poweroff.png b/docs/img/2023-11-08-poweroff.png similarity index 100% rename from img/2023-11-08-poweroff.png rename to docs/img/2023-11-08-poweroff.png diff --git a/home/features/wayland/hyprland/default.nix b/home/features/wayland/hyprland/default.nix index 40098ea..85f5b78 100644 --- a/home/features/wayland/hyprland/default.nix +++ b/home/features/wayland/hyprland/default.nix @@ -1,7 +1,7 @@ { pkgs, lib, config, inputs, ... }: let - enabledMonitors = lib.filter (m: m.enabled) config.monitors; + enabledMonitors = lib.filter (m: m.enabled) config.satellite.monitors; hyprland-monitors = lib.concatStringsSep "\n" (lib.forEach enabledMonitors (m: '' monitor=${m.name},${toString m.width}x${toString m.height}@${toString m.refreshRate},${toString m.x}x${toString m.y},1 ${lib.optionalString (m.workspace != null) "workspace=${m.name},${m.workspace}"} diff --git a/home/tethys.nix b/home/tethys.nix index d2564eb..025c877 100644 --- a/home/tethys.nix +++ b/home/tethys.nix @@ -59,11 +59,11 @@ # App state which I should be able to delete at any point at.cache.path = "/persist/local/cache"; }; - }; - monitors = [{ - name = "eDP-1"; - width = 1920; - height = 1080; - }]; + monitors = [{ + name = "eDP-1"; + width = 1920; + height = 1080; + }]; + }; } diff --git a/modules/README.md b/modules/README.md new file mode 100644 index 0000000..eecd73b --- /dev/null +++ b/modules/README.md @@ -0,0 +1,34 @@ +# Modules + +This directory contains custom module definitions used throughout my config. + +## File structure + +| Directory | Description | +| ------------------------------ | -------------------------------------------------------------- | +| [common](./common) | Modules usable in both HM and nixos (and perhaps other places) | +| [nixos](./nixos) | Nixos specific functinality | +| [home-manager](./home-manager) | Home manager specific functionality | + +## Common modules + +| Name | Attribute | Description | Dependencies | +| ----------------------------------------------- | --------------------------- | ---------------------------------------- | ----------------------------------------- | +| [lua-colorscheme](./common/lua-colorscheme.nix) | `satellite.colorscheme.lua` | Base16 theme to lua module generation | [stylix](https://github.com/danth/stylix) | +| [theming](./common/theming.nix) | `satellite.theming` | Base16 theming helpers and configuration | [stylix](https://github.com/danth/stylix) | +| [toggles](./common/toggles.nix) | `satellite.toggles` | Generic interface for feature flags | | + +## Nixos modules + +There are no nixos modules at the moment! + +## Home-manager modules + +| Name | Attribute | Description | Dependencies | +| ------------------------------------------------- | ----------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------- | +| [discord](./home-manager/discord.nix) | `programs.discord` | Additional discord options | | +| [eww-hyprland](./home-manager/eww-hyprland.nix) | `programs.eww-hyprland` | `eww` service for `hyprland` | | +| [hyprpaper](./home-manager/hyprpaper.nix) | `services.hyprpaper` | Wallpaper service for `hyprland` | | +| [monitors](./home-manager/monitors.nix) | `satellite.monitors` | WM generic monitor configuration | | +| [persistence](./home-manager/persistence.nix) | `satellite.persistence` | Syntactic wrapper around impermanence | [impermanence](https://github.com/nix-community/impermanence) | +| [satellite-dev](./home-manager/satellite-dev.nix) | `satellite.dev` | Helpers for managing dotfiles which are actively under development | | diff --git a/modules/common/lua-colorscheme.nix b/modules/common/lua-colorscheme.nix index 26b93ff..87474e9 100644 --- a/modules/common/lua-colorscheme.nix +++ b/modules/common/lua-colorscheme.nix @@ -5,7 +5,7 @@ description = "Lua file containing the current colorscheme"; }; - config.satellite.colorscheme.lua = '' + config.satellite.colorscheme.lua = /* lua */ '' return { name = "${config.lib.stylix.scheme.scheme}", base00 = "${config.lib.stylix.scheme.base00}", diff --git a/modules/common/toggles.nix b/modules/common/toggles.nix index 7f6e005..e4d4ee6 100644 --- a/modules/common/toggles.nix +++ b/modules/common/toggles.nix @@ -1,3 +1,12 @@ +# Generic interface for working with feature flags! +# +# For instance, my neovim config sets `programs.neovim.enable` to `false`, +# so other modules cannot detect whether it is on or off without doing weird +# tricks like checking if certain attributes have been set. +# +# Instead, the neovim config sets `satellite.toggles.neovim.enable` to `true`, +# which can then be read from places like the firefox config to trigger things +# like installing the `firenvim` extension. { lib, ... }: { options.satellite.toggles = lib.mkOption { diff --git a/modules/home-manager/eww-hyprland.nix b/modules/home-manager/eww-hyprland.nix index 2c3adbf..17b9705 100644 --- a/modules/home-manager/eww-hyprland.nix +++ b/modules/home-manager/eww-hyprland.nix @@ -1,10 +1,12 @@ +# A big chunk of this was taken from fuxefan's config: +# https://github.com/fufexan/dotfiles/blob/main/home/programs/eww/default.nix { config , pkgs , lib , ... }: let - reload_script = pkgs.writeShellScript "reload_eww" '' + reloadScript = pkgs.writeShellScript "reload_eww" '' systemctl --user restart eww.service ''; @@ -51,7 +53,7 @@ in onChange = if cfg.autoReload - then reload_script.outPath + then reloadScript.outPath else ""; }; diff --git a/modules/home-manager/monitors.nix b/modules/home-manager/monitors.nix index 4954760..731be8c 100644 --- a/modules/home-manager/monitors.nix +++ b/modules/home-manager/monitors.nix @@ -2,7 +2,7 @@ # This is meant to provide a wm-independent way of specifying the monitor configuration of each machine. { lib, ... }: { - options.monitors = lib.mkOption { + options.satellite.monitors = lib.mkOption { type = lib.types.listOf (lib.types.submodule { options = { name = lib.mkOption {