From 821d5cb78e5681afce80aba5bc65dc0a8f9a3a9f Mon Sep 17 00:00:00 2001 From: Swarsel Date: Wed, 24 Jul 2024 19:43:16 +0200 Subject: [PATCH] feat: add stylix as custom module --- SwarselSystems.org | 53 +++++++++--- index.html | 135 +++++++++++++++++++------------ modules/home/default.nix | 1 + modules/home/hardware.nix | 17 ++++ profiles/common/home/stylix.nix | 6 +- profiles/common/home/waybar.nix | 3 +- profiles/common/nixos/stylix.nix | 8 +- profiles/fourside/home.nix | 1 - 8 files changed, 157 insertions(+), 67 deletions(-) create mode 100644 modules/home/hardware.nix diff --git a/SwarselSystems.org b/SwarselSystems.org index 8531b46..03069e8 100644 --- a/SwarselSystems.org +++ b/SwarselSystems.org @@ -2275,7 +2275,6 @@ This is basically just adjusted to the core count, path to the =hwmon= (this was # waybar config - TEMPLATE - update for cores and temp programs.waybar.settings.mainBar = { - cpu.format = "{icon0} {icon1} {icon2} {icon3} {icon4} {icon5} {icon6} {icon7}"; # temperature.hwmon-path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon4/temp1_input"; temperature.hwmon-path.abs = "/sys/devices/platform/thinkpad_hwmon/hwmon/"; temperature.input-filename = "temp1_input"; @@ -4467,6 +4466,7 @@ Modules that need to be loaded on the NixOS level. Note that these will not be a #+BEGIN_src nix :tangle modules/home/default.nix { laptop = import ./laptop.nix; + hardware = import ./hardware.nix; monitors = import ./monitors.nix; input = import ./input.nix; nixos = import ./nixos.nix; @@ -4490,6 +4490,28 @@ Modules that need to be loaded on the NixOS level. Note that these will not be a } #+end_src +***** Hardware + +#+begin_src nix :tangle modules/home/hardware.nix + { lib, config, ... }: + +let + generateIcons = n: lib.concatStringsSep " " (builtins.map (x: "{icon" + toString x + "}") (lib.range 0 (n - 1))); +in + { + options.swarselsystems.cpuCount = lib.mkOption { + type = lib.types.int; + default = 8; + }; + options.swarselsystems.cpuString = lib.mkOption { + type = lib.types.str; + default = generateIcons config.swarselsystems.cpuCount; + description = "The generated icons string for use by Waybar."; + internal = true; + }; + } +#+end_src + ***** Monitors #+begin_src nix :tangle modules/home/monitors.nix @@ -5083,13 +5105,19 @@ By default, [[https://github.com/danth/stylix][stylix]] wants to style GRUB as w =theme= is defined in [[#h:5bc1b0c9-dc59-4c81-b5b5-e60699deda78][Theme (stylix)]]. #+begin_src nix :noweb yes :tangle profiles/common/nixos/stylix.nix - { pkgs, ... }: - { - stylix = { - <> - targets.grub.enable = false; # the styling makes grub more ugly - }; - } + { pkgs, home-manager, ... }: + { + stylix = { + <> + targets.grub.enable = false; # the styling makes grub more ugly + }; + home-manager.users.swarsel = { + stylix.targets = { + emacs.enable = false; + waybar.enable = false; + }; + }; + } #+end_src *** System Packages @@ -6024,8 +6052,10 @@ This section has been notably empty ever since switching to stylix. Only Emacs i { stylix = lib.mkIf (!config.swarselsystems.isNixos) { <> - targets.emacs.enable = false; - targets.waybar.enable = false; + targets = { + emacs.enable = false; + waybar.enable = false; + }; }; } #+end_src @@ -6771,7 +6801,7 @@ The rest of this configuration is found here: #+begin_src nix :tangle profiles/common/home/waybar.nix - { ... }: + { config, ... }: { programs.waybar = { @@ -6910,6 +6940,7 @@ The rest of this configuration is found here: tooltip-format = "Memory: {used:0.1f}G/{total:0.1f}G\nSwap: {swapUsed}G/{swapTotal}G"; }; cpu = { + format = config.swarselsystems.cpuString; min-length = 6; interval = 5; format-icons = [ "▁" "▂" "▃" "▄" "▅" "▆" "▇" "█" ]; diff --git a/index.html b/index.html index be722f4..150aa28 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + SwarselSystems: NixOS + Emacs Configuration @@ -223,7 +223,7 @@ -
  • 3.2. Overlays, packages, and modules +
  • 3.2. Overlays, packages, and modules
  • 3.3. Common NixOS @@ -253,7 +253,7 @@
  • 3.3.1. Imports, enable home-manager module
  • 3.3.2. General
  • 3.3.3. sops
  • -
  • 3.3.4. Theme (stylix)
  • +
  • 3.3.4. Theme (stylix)
  • 3.3.5. System Packages
  • 3.3.6. Programs (including zsh setup)
  • 3.3.7. Services
  • @@ -263,7 +263,7 @@
  • 3.4. Common Home-Manager
      -
    • 3.4.1. Imports
    • +
    • 3.4.1. Imports
    • 3.4.2. Installed packages
    • 3.4.3. sops
    • 3.4.4. SSH Machines
    • @@ -272,7 +272,7 @@
    • 3.4.7. Linking dotfiles
    • 3.4.8. Sourcing environment variables
    • 3.4.9. Programs
    • -
    • 3.4.10. nix-index
    • +
    • 3.4.10. nix-index
    • 3.4.11. password-store
    • 3.4.12. direnv
    • 3.4.13. eza
    • @@ -339,7 +339,7 @@
      • 4.4.1. Org Mode
      • 4.4.2. Nix Mode
      • -
      • 4.4.3. nixpkgs-fmt
      • +
      • 4.4.3. nixpkgs-fmt
      • 4.4.4. Markdown Mode
      • 4.4.5. Olivetti
      • 4.4.6. darkroom
      • @@ -399,7 +399,7 @@

        -This file has 42234 words spanning 11394 lines and was last revised on 2024-07-24 18:31:42 +0200. +This file has 42312 words spanning 11425 lines and was last revised on 2024-07-24 19:14:57 +0200.

        @@ -449,7 +449,7 @@ This section defines my Emacs configuration. For a while, I considered to use ry

        -My emacs is built using the emacs-overlay nix flake, which builds a bleeding edge emacs on wayland (pgtk) with utilities like treesitter support. By executing the below source block, the current build setting can be updated at any time, and you can see my most up-to-date build options (last updated: 2024-07-24 18:31:42 +0200) +My emacs is built using the emacs-overlay nix flake, which builds a bleeding edge emacs on wayland (pgtk) with utilities like treesitter support. By executing the below source block, the current build setting can be updated at any time, and you can see my most up-to-date build options (last updated: 2024-07-24 19:14:57 +0200)

      @@ -1071,8 +1071,8 @@ mixedModules = [ -
      -

      2.3.3. General (outputs)

      +
      +

      2.3.3. General (outputs)

      @@ -2463,7 +2463,7 @@ in
       
       
       
      -
    • Home-manager only
      +
    • Home-manager only
      1. Home manager
        @@ -3082,7 +3082,6 @@ This is basically just adjusted to the core count, path to the hwmon
    • -
      -

      3.2. Overlays, packages, and modules

      +
      +

      3.2. Overlays, packages, and modules

      In this section I define packages that I manually want to nixpkgs. This can be useful for packages that are currently awaiting a PR or public packages that I do not want to maintain. @@ -5567,8 +5566,8 @@ These are for packages that are on nixpkgs, but do not fit my usecase, meaning I This is simply a mirror of the most recent stable branch of nixpkgs. Useful for packages that are broken on nixpkgs, but do not need to be on bleeding edge anyways.

      -
      -

      3.2.1. Packages

      +
      +

      3.2.1. Packages

      @@ -5578,8 +5577,8 @@ _ : rec { }
       
      -
      -

      3.2.2. Overlays

      +
      +

      3.2.2. Overlays

      @@ -5612,15 +5611,15 @@ _ : rec { }
       
      -
      -

      3.2.3. Modules

      +
      +

      3.2.3. Modules

      In this section I define custom modules under the swarsel attribute. These are mostly used to define settings specific to a host. I keep these settings confined to either home-manager or nixos to maintain compatibility with non-NixOS machines.

        -
      1. NixOS
        +
      2. NixOS

        Modules that need to be loaded on the NixOS level. Note that these will not be available on systems that are not running NixOS @@ -5634,11 +5633,12 @@ Modules that need to be loaded on the NixOS level. Note that these will not be a

      -
    • home-manager
      +
    • home-manager
      {
         laptop = import ./laptop.nix;
      +  hardware = import ./hardware.nix;
         monitors = import ./monitors.nix;
         input = import ./input.nix;
         nixos = import ./nixos.nix;
      @@ -5647,7 +5647,7 @@ Modules that need to be loaded on the NixOS level. Note that these will not be a
       
        -
      1. Laptop
        +
      2. Laptop
        { lib, config, ... }:
        @@ -5666,9 +5666,33 @@ Modules that need to be loaded on the NixOS level. Note that these will not be a
         
      3. -
      4. Monitors
        +
      5. Hardware
        +
          { lib, config, ... }:
        +
        +let
        +  generateIcons = n: lib.concatStringsSep " " (builtins.map (x: "{icon" + toString x + "}") (lib.range 0 (n - 1)));
        +in
        +  {
        +    options.swarselsystems.cpuCount = lib.mkOption {
        +        type = lib.types.int;
        +        default = 8;
        +      };
        +    options.swarselsystems.cpuString = lib.mkOption {
        +        type = lib.types.str;
        +        default = generateIcons config.swarselsystems.cpuCount;
        +        description = "The generated icons string for use by Waybar.";
        +        internal = true;
        +      };
        +    }
        +
        +
        +
        +
      6. +
      7. Monitors
        +
        +
        { lib, config, ... }:
         let
           inherit (lib) mkOption types;
        @@ -5683,8 +5707,8 @@ in
         
      8. -
      9. Input
        -
        +
      10. Input
        +
        { lib, config, ... }:
         let
        @@ -5719,8 +5743,8 @@ in
         
      11. -
      12. Nixos
        -
        +
      13. Nixos
        +
         { lib, config, ... }:
        @@ -6281,8 +6305,8 @@ I use sops-nix to handle secrets that I want to have available on my machines at
         
    • -
      -

      3.3.4. Theme (stylix)

      +
      +

      3.3.4. Theme (stylix)

      By default, stylix wants to style GRUB as well. However, I think that looks horrible. @@ -6290,7 +6314,7 @@ By default, stylix wants to style

      -
      { pkgs, ... }:
      +
      { pkgs, home-manager, ... }:
       {
         stylix = {
       
      @@ -6340,6 +6364,12 @@ By default, stylix wants to style
       
           targets.grub.enable = false; # the styling makes grub more ugly
         };
      +  home-manager.users.swarsel = {
      +    stylix.targets = {
      +      emacs.enable = false;
      +      waybar.enable = false;
      +    };
      +  };
       }
       
      @@ -6458,7 +6488,7 @@ Some programs profit from being installed through dedicated NixOS settings on sy
        -
      1. zsh
        +
      2. zsh

        Do not touch this. @@ -6476,7 +6506,7 @@ Do not touch this.

      -
    • syncthing
      +
    • syncthing
      @@ -6554,7 +6584,7 @@ Enables the blueman service including the nice system tray icon.
       
    • -
    • Network devices
      +
    • Network devices

      In this section we enable compatibility with several network devices I have at home, mainly printers and scanners. @@ -6606,7 +6636,7 @@ services.printing = {

    • -
    • Avahi (device discovery)
      +
    • Avahi (device discovery)

      Avahi is the service used for the network discovery. @@ -6760,8 +6790,8 @@ This section houses the greetd related settings. I do not really want to use a d

      3.4. Common Home-Manager

      -
      -

      3.4.1. Imports

      +
      +

      3.4.1. Imports

      This section sets up all the imports that are used in the home-manager section. @@ -7388,8 +7418,10 @@ This section has been notably empty ever since switching to stylix. Only Emacs i }; }; - targets.emacs.enable = false; - targets.waybar.enable = false; + targets = { + emacs.enable = false; + waybar.enable = false; + }; }; } @@ -7567,8 +7599,8 @@ This section is for programs that require no further configuration. zsh Integrat

    • -
      -

      3.4.10. nix-index

      +
      +

      3.4.10. nix-index

      nix-index provides a way to find out which packages are provided by which derivations. By default it also comes with a replacement for command-not-found.sh, however, the implementation is based on a channel based setup. I like consistency, so I replace the command with one that provides a flakes-based output. @@ -8187,7 +8219,7 @@ The rest of this configuration is found here:

      -{ ... }:
      +{ config, ... }:
       {
       programs.waybar = {
       
      @@ -8326,6 +8358,7 @@ programs.waybar = {
               tooltip-format = "Memory: {used:0.1f}G/{total:0.1f}G\nSwap: {swapUsed}G/{swapTotal}G";
             };
             cpu = {
      +        format = config.swarselsystems.cpuString;
               min-length = 6;
               interval = 5;
               format-icons = [ "▁" "▂" "▃" "▄" "▅" "▆" "▇" "█" ];
      @@ -9911,7 +9944,7 @@ The standard Emacs behaviour for the Python process shell is a bit annoying. Thi
       
      -
    • Nix common prefix bracketer
      +
    • Nix common prefix bracketer

      This function searches for common delimiters in region and removes them, summarizing all captured lines by it. @@ -9944,7 +9977,7 @@ This function searches for common delimiters in region and removes them, summari

    • -
    • Nix formatters
      +
    • Nix formatters

      This formats the org code block at point in accordance to the nixpkgs-fmt formatter @@ -11517,8 +11550,8 @@ This adds a rudimentary nix-mode to Emacs. I have not really tried this out, as

    • -
      -

      4.4.3. nixpkgs-fmt

      +
      +

      4.4.3. nixpkgs-fmt

      Adds functions for formatting nix code. @@ -13533,7 +13566,7 @@ My laptop, sadly soon to be replaced by a new one, since most basic functions ar

      Author: Leon Schwarzäugl

      -

      Created: 2024-07-24 Mi 18:31

      +

      Created: 2024-07-24 Mi 19:15

      Validate

      diff --git a/modules/home/default.nix b/modules/home/default.nix index 266887d..fcb5910 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -1,5 +1,6 @@ { laptop = import ./laptop.nix; + hardware = import ./hardware.nix; monitors = import ./monitors.nix; input = import ./input.nix; nixos = import ./nixos.nix; diff --git a/modules/home/hardware.nix b/modules/home/hardware.nix new file mode 100644 index 0000000..b120941 --- /dev/null +++ b/modules/home/hardware.nix @@ -0,0 +1,17 @@ +{ lib, config, ... }: + +let + generateIcons = n: lib.concatStringsSep " " (builtins.map (x: "{icon" + toString x + "}") (lib.range 0 (n - 1))); +in +{ + options.swarselsystems.cpuCount = lib.mkOption { + type = lib.types.int; + default = 8; + }; + options.swarselsystems.cpuString = lib.mkOption { + type = lib.types.str; + default = generateIcons config.swarselsystems.cpuCount; + description = "The generated icons string for use by Waybar."; + internal = true; + }; +} diff --git a/profiles/common/home/stylix.nix b/profiles/common/home/stylix.nix index dc683e1..7312388 100644 --- a/profiles/common/home/stylix.nix +++ b/profiles/common/home/stylix.nix @@ -46,7 +46,9 @@ }; }; - targets.emacs.enable = false; - targets.waybar.enable = false; + targets = { + emacs.enable = false; + waybar.enable = false; + }; }; } diff --git a/profiles/common/home/waybar.nix b/profiles/common/home/waybar.nix index 80476dd..9342b4d 100644 --- a/profiles/common/home/waybar.nix +++ b/profiles/common/home/waybar.nix @@ -1,4 +1,4 @@ -{ ... }: +{ config, ... }: { programs.waybar = { @@ -137,6 +137,7 @@ tooltip-format = "Memory: {used:0.1f}G/{total:0.1f}G\nSwap: {swapUsed}G/{swapTotal}G"; }; cpu = { + format = config.swarselsystems.cpuString; min-length = 6; interval = 5; format-icons = [ "▁" "▂" "▃" "▄" "▅" "▆" "▇" "█" ]; diff --git a/profiles/common/nixos/stylix.nix b/profiles/common/nixos/stylix.nix index bd273b3..bcb96eb 100644 --- a/profiles/common/nixos/stylix.nix +++ b/profiles/common/nixos/stylix.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, home-manager, ... }: { stylix = { @@ -48,4 +48,10 @@ targets.grub.enable = false; # the styling makes grub more ugly }; + home-manager.users.swarsel = { + stylix.targets = { + emacs.enable = false; + waybar.enable = false; + }; + }; } diff --git a/profiles/fourside/home.nix b/profiles/fourside/home.nix index f1bc192..a6d1b3c 100644 --- a/profiles/fourside/home.nix +++ b/profiles/fourside/home.nix @@ -19,7 +19,6 @@ # waybar config - TEMPLATE - update for cores and temp programs.waybar.settings.mainBar = { - cpu.format = "{icon0} {icon1} {icon2} {icon3} {icon4} {icon5} {icon6} {icon7}"; # temperature.hwmon-path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon4/temp1_input"; temperature.hwmon-path.abs = "/sys/devices/platform/thinkpad_hwmon/hwmon/"; temperature.input-filename = "temp1_input";