From 573f2c459e9cba0de67f64acab7bd5777b707f91 Mon Sep 17 00:00:00 2001 From: Martin Berg Alstad Date: Sun, 5 Jan 2025 20:36:01 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=91=20Treefmt=20formatter=20for=20nix,?= =?UTF-8?q?=20json,=20css,=20sh=20and=20more?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierrc.toml | 1 + fmt | 6 +- home-manager/hyprland/swaync/mocha.css | 445 +++++++++++------- .../hyprland/waybar/config/config.jsonc | 27 +- home-manager/hyprland/waybar/config/style.css | 80 ++-- home-manager/wlogout/style.css | 48 +- modules/development.nix | 7 +- modules/steam.nix | 8 +- modules/stylix.nix | 22 +- test | 2 +- treefmt.toml | 18 + 11 files changed, 390 insertions(+), 274 deletions(-) create mode 100644 .prettierrc.toml create mode 100644 treefmt.toml diff --git a/.prettierrc.toml b/.prettierrc.toml new file mode 100644 index 0000000..66c04fd --- /dev/null +++ b/.prettierrc.toml @@ -0,0 +1 @@ +trailingComma = "none" diff --git a/fmt b/fmt index 6a26024..30cdffa 100755 --- a/fmt +++ b/fmt @@ -1,5 +1,5 @@ #!/usr/bin/env sh -# Format all .nix files using the new default nix formatter -# TODO doesn't work when run using ./fmt -nix fmt ./**.nix +# Format all files matched by treefmt.toml + +treefmt --on-unmatched info diff --git a/home-manager/hyprland/swaync/mocha.css b/home-manager/hyprland/swaync/mocha.css index 2f4afb9..1a5acea 100644 --- a/home-manager/hyprland/swaync/mocha.css +++ b/home-manager/hyprland/swaync/mocha.css @@ -1,344 +1,453 @@ /* TODO Variables */ * { - all: unset; - font-size: 14px; - font-family: "JetBrains Mono", monospace; - transition: 200ms; + all: unset; + font-size: 14px; + font-family: "JetBrains Mono", monospace; + transition: 200ms; } trough highlight { - background: #cdd6f4; + background: #cdd6f4; } scale trough { - margin: 0 1rem; - background-color: #313244; - min-height: 8px; - min-width: 70px; + margin: 0 1rem; + background-color: #313244; + min-height: 8px; + min-width: 70px; } slider { - background-color: #89b4fa; + background-color: #89b4fa; } .floating-notifications.background .notification-row .notification-background { - box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.8), inset 0 0 0 1px #313244; - border-radius: 12.6px; - margin: 18px; - background-color: #1e1e2e; - color: #cdd6f4; - padding: 0; + box-shadow: + 0 0 8px 0 rgba(0, 0, 0, 0.8), + inset 0 0 0 1px #313244; + border-radius: 12.6px; + margin: 18px; + background-color: #1e1e2e; + color: #cdd6f4; + padding: 0; } -.floating-notifications.background .notification-row .notification-background .notification { - padding: 7px; - border-radius: 12.6px; +.floating-notifications.background + .notification-row + .notification-background + .notification { + padding: 7px; + border-radius: 12.6px; } -.floating-notifications.background .notification-row .notification-background .notification.critical { - box-shadow: inset 0 0 7px 0 #f38ba8; +.floating-notifications.background + .notification-row + .notification-background + .notification.critical { + box-shadow: inset 0 0 7px 0 #f38ba8; } -.floating-notifications.background .notification-row .notification-background .notification .notification-content { - margin: 7px; +.floating-notifications.background + .notification-row + .notification-background + .notification + .notification-content { + margin: 7px; } -.floating-notifications.background .notification-row .notification-background .notification .notification-content .summary { - color: #cdd6f4; +.floating-notifications.background + .notification-row + .notification-background + .notification + .notification-content + .summary { + color: #cdd6f4; } -.floating-notifications.background .notification-row .notification-background .notification .notification-content .time { - color: #a6adc8; +.floating-notifications.background + .notification-row + .notification-background + .notification + .notification-content + .time { + color: #a6adc8; } -.floating-notifications.background .notification-row .notification-background .notification .notification-content .body { - color: #cdd6f4; +.floating-notifications.background + .notification-row + .notification-background + .notification + .notification-content + .body { + color: #cdd6f4; } -.floating-notifications.background .notification-row .notification-background .notification > *:last-child > * { - min-height: 3.4em; +.floating-notifications.background + .notification-row + .notification-background + .notification + > *:last-child + > * { + min-height: 3.4em; } -.floating-notifications.background .notification-row .notification-background .notification > *:last-child > * .notification-action { - border-radius: 7px; - color: #cdd6f4; - background-color: #313244; - box-shadow: inset 0 0 0 1px #45475a; - margin: 7px; +.floating-notifications.background + .notification-row + .notification-background + .notification + > *:last-child + > * + .notification-action { + border-radius: 7px; + color: #cdd6f4; + background-color: #313244; + box-shadow: inset 0 0 0 1px #45475a; + margin: 7px; } -.floating-notifications.background .notification-row .notification-background .notification > *:last-child > * .notification-action:hover { - box-shadow: inset 0 0 0 1px #45475a; - background-color: #313244; - color: #cdd6f4; +.floating-notifications.background + .notification-row + .notification-background + .notification + > *:last-child + > * + .notification-action:hover { + box-shadow: inset 0 0 0 1px #45475a; + background-color: #313244; + color: #cdd6f4; } -.floating-notifications.background .notification-row .notification-background .notification > *:last-child > * .notification-action:active { - box-shadow: inset 0 0 0 1px #45475a; - background-color: #74c7ec; - color: #cdd6f4; +.floating-notifications.background + .notification-row + .notification-background + .notification + > *:last-child + > * + .notification-action:active { + box-shadow: inset 0 0 0 1px #45475a; + background-color: #74c7ec; + color: #cdd6f4; } /* Close Button */ -.floating-notifications.background .notification-row .notification-background .close-button { - margin: 7px; - padding: 2px; - border-radius: 6.3px; - color: #1e1e2e; - background-color: #f38ba8; +.floating-notifications.background + .notification-row + .notification-background + .close-button { + margin: 7px; + padding: 2px; + border-radius: 6.3px; + color: #1e1e2e; + background-color: #f38ba8; } -.floating-notifications.background .notification-row .notification-background .close-button:hover { - background-color: #eba0ac; - color: #1e1e2e; +.floating-notifications.background + .notification-row + .notification-background + .close-button:hover { + background-color: #eba0ac; + color: #1e1e2e; } -.floating-notifications.background .notification-row .notification-background .close-button:active { - background-color: #f38ba8; - color: #1e1e2e; +.floating-notifications.background + .notification-row + .notification-background + .close-button:active { + background-color: #f38ba8; + color: #1e1e2e; } .control-center { - box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.8), inset 0 0 0 1px #313244; - border-radius: 12.6px; - margin: 18px; - background-color: #1e1e2e; - color: #cdd6f4; - padding: 14px; + box-shadow: + 0 0 8px 0 rgba(0, 0, 0, 0.8), + inset 0 0 0 1px #313244; + border-radius: 12.6px; + margin: 18px; + background-color: #1e1e2e; + color: #cdd6f4; + padding: 14px; } .control-center .widget-title > label { - color: #cdd6f4; - font-size: 1.3em; + color: #cdd6f4; + font-size: 1.3em; } .control-center .widget-title button { - border-radius: 7px; - color: #cdd6f4; - background-color: #313244; - box-shadow: inset 0 0 0 1px #45475a; - padding: 8px; + border-radius: 7px; + color: #cdd6f4; + background-color: #313244; + box-shadow: inset 0 0 0 1px #45475a; + padding: 8px; } .control-center .widget-title button:hover { - box-shadow: inset 0 0 0 1px #45475a; - background-color: #585b70; - color: #cdd6f4; + box-shadow: inset 0 0 0 1px #45475a; + background-color: #585b70; + color: #cdd6f4; } .control-center .widget-title button:active { - box-shadow: inset 0 0 0 1px #45475a; - background-color: #74c7ec; - color: #1e1e2e; + box-shadow: inset 0 0 0 1px #45475a; + background-color: #74c7ec; + color: #1e1e2e; } .control-center .notification-row .notification-background { - border-radius: 7px; - color: #cdd6f4; - background-color: #313244; - box-shadow: inset 0 0 0 1px #45475a; - margin-top: 14px; + border-radius: 7px; + color: #cdd6f4; + background-color: #313244; + box-shadow: inset 0 0 0 1px #45475a; + margin-top: 14px; } .control-center .notification-row .notification-background .notification { - padding: 7px; - border-radius: 7px; + padding: 7px; + border-radius: 7px; } -.control-center .notification-row .notification-background .notification.critical { - box-shadow: inset 0 0 7px 0 #f38ba8; +.control-center + .notification-row + .notification-background + .notification.critical { + box-shadow: inset 0 0 7px 0 #f38ba8; } -.control-center .notification-row .notification-background .notification .notification-content { - margin: 7px; +.control-center + .notification-row + .notification-background + .notification + .notification-content { + margin: 7px; } -.control-center .notification-row .notification-background .notification .notification-content .summary { - color: #cdd6f4; +.control-center + .notification-row + .notification-background + .notification + .notification-content + .summary { + color: #cdd6f4; } -.control-center .notification-row .notification-background .notification .notification-content .time { - color: #a6adc8; +.control-center + .notification-row + .notification-background + .notification + .notification-content + .time { + color: #a6adc8; } -.control-center .notification-row .notification-background .notification .notification-content .body { - color: #cdd6f4; +.control-center + .notification-row + .notification-background + .notification + .notification-content + .body { + color: #cdd6f4; } -.control-center .notification-row .notification-background .notification > *:last-child > * { - min-height: 3.4em; +.control-center + .notification-row + .notification-background + .notification + > *:last-child + > * { + min-height: 3.4em; } -.control-center .notification-row .notification-background .notification > *:last-child > * .notification-action { - border-radius: 7px; - color: #cdd6f4; - background-color: #11111b; - box-shadow: inset 0 0 0 1px #45475a; - margin: 7px; +.control-center + .notification-row + .notification-background + .notification + > *:last-child + > * + .notification-action { + border-radius: 7px; + color: #cdd6f4; + background-color: #11111b; + box-shadow: inset 0 0 0 1px #45475a; + margin: 7px; } -.control-center .notification-row .notification-background .notification > *:last-child > * .notification-action:hover { - box-shadow: inset 0 0 0 1px #45475a; - background-color: #313244; - color: #cdd6f4; +.control-center + .notification-row + .notification-background + .notification + > *:last-child + > * + .notification-action:hover { + box-shadow: inset 0 0 0 1px #45475a; + background-color: #313244; + color: #cdd6f4; } -.control-center .notification-row .notification-background .notification > *:last-child > * .notification-action:active { - box-shadow: inset 0 0 0 1px #45475a; - background-color: #74c7ec; - color: #cdd6f4; +.control-center + .notification-row + .notification-background + .notification + > *:last-child + > * + .notification-action:active { + box-shadow: inset 0 0 0 1px #45475a; + background-color: #74c7ec; + color: #cdd6f4; } .control-center .notification-row .notification-background .close-button { - margin: 7px; - padding: 2px; - border-radius: 6.3px; - color: #1e1e2e; - background-color: #eba0ac; + margin: 7px; + padding: 2px; + border-radius: 6.3px; + color: #1e1e2e; + background-color: #eba0ac; } .close-button { - border-radius: 6.3px; + border-radius: 6.3px; } .control-center .notification-row .notification-background .close-button:hover { - background-color: #f38ba8; - color: #1e1e2e; + background-color: #f38ba8; + color: #1e1e2e; } -.control-center .notification-row .notification-background .close-button:active { - background-color: #f38ba8; - color: #1e1e2e; +.control-center + .notification-row + .notification-background + .close-button:active { + background-color: #f38ba8; + color: #1e1e2e; } .control-center .notification-row .notification-background:hover { - box-shadow: inset 0 0 0 1px #45475a; - background-color: #7f849c; - color: #cdd6f4; + box-shadow: inset 0 0 0 1px #45475a; + background-color: #7f849c; + color: #cdd6f4; } .control-center .notification-row .notification-background:active { - box-shadow: inset 0 0 0 1px #45475a; - background-color: #74c7ec; - color: #cdd6f4; + box-shadow: inset 0 0 0 1px #45475a; + background-color: #74c7ec; + color: #cdd6f4; } .notification.critical progress { - background-color: #f38ba8; + background-color: #f38ba8; } .notification.low progress, .notification.normal progress { - background-color: #89b4fa; + background-color: #89b4fa; } .control-center-dnd { - margin-top: 5px; - border-radius: 8px; - background: #313244; - border: 1px solid #45475a; - box-shadow: none; + margin-top: 5px; + border-radius: 8px; + background: #313244; + border: 1px solid #45475a; + box-shadow: none; } .control-center-dnd:checked { - background: #313244; + background: #313244; } .control-center-dnd slider { - background: #45475a; - border-radius: 8px; + background: #45475a; + border-radius: 8px; } .widget-dnd { - margin: 0px; - font-size: 1.1rem; + margin: 0px; + font-size: 1.1rem; } .widget-dnd > switch { - font-size: initial; - border-radius: 8px; - background: #313244; - border: 1px solid #45475a; - box-shadow: none; + font-size: initial; + border-radius: 8px; + background: #313244; + border: 1px solid #45475a; + box-shadow: none; } .widget-dnd > switch:checked { - background: #313244; + background: #313244; } .widget-dnd > switch slider { - background: #45475a; - border-radius: 8px; - border: 1px solid #6c7086; + background: #45475a; + border-radius: 8px; + border: 1px solid #6c7086; } .widget-mpris .widget-mpris-player { - background: #313244; - padding: 7px; + background: #313244; + padding: 7px; } .widget-mpris .widget-mpris-title { - font-size: 1.2rem; + font-size: 1.2rem; } .widget-mpris .widget-mpris-subtitle { - font-size: 0.8rem; + font-size: 0.8rem; } .widget-menubar > box > .menu-button-bar > button > label { - font-size: 3rem; - padding: 0.5rem 2rem; + font-size: 3rem; + padding: 0.5rem 2rem; } .widget-menubar > box > .menu-button-bar > :last-child { - color: #f38ba8; + color: #f38ba8; } .power-buttons button:hover, .powermode-buttons button:hover, .screenshot-buttons button:hover { - background: #313244; + background: #313244; } .control-center .widget-label > label { - color: #cdd6f4; - font-size: 2rem; + color: #cdd6f4; + font-size: 2rem; } .widget-buttons-grid { - padding-top: 1rem; + padding-top: 1rem; } .widget-buttons-grid > flowbox > flowboxchild > button label { - font-size: 2.5rem; + font-size: 2.5rem; } .widget-volume { - padding-top: 1rem; + padding-top: 1rem; } .widget-volume label { - font-size: 1.5rem; - color: #74c7ec; + font-size: 1.5rem; + color: #74c7ec; } .widget-volume trough highlight { - background: #74c7ec; + background: #74c7ec; } .widget-backlight trough highlight { - background: #f9e2af; + background: #f9e2af; } .widget-backlight label { - font-size: 1.5rem; - color: #f9e2af; + font-size: 1.5rem; + color: #f9e2af; } .widget-backlight .KB { - padding-bottom: 1rem; + padding-bottom: 1rem; } .image { - padding-right: 0.5rem; + padding-right: 0.5rem; } diff --git a/home-manager/hyprland/waybar/config/config.jsonc b/home-manager/hyprland/waybar/config/config.jsonc index 1c82813..a9a78cb 100644 --- a/home-manager/hyprland/waybar/config/config.jsonc +++ b/home-manager/hyprland/waybar/config/config.jsonc @@ -5,13 +5,8 @@ // Waybar position (top|bottom|left|right) // "width": 1280, // Waybar width // Choose the order of the modules - "modules-left": [ - "hyprland/workspaces", - "custom/music" - ], - "modules-center": [ - "hyprland/window" - ], + "modules-left": ["hyprland/workspaces", "custom/music"], + "modules-center": ["hyprland/window"], "modules-right": [ "hyprland/language", "wireplumber", @@ -60,28 +55,14 @@ "backlight": { "device": "intel_backlight", "format": "{icon}", - "format-icons": [ - "", - "", - "", - "", - "", - "", - "", - "", - "" - ] + "format-icons": ["", "", "", "", "", "", "", "", ""] }, "wireplumber": { // "scroll-step": 1, // %, can be a float "format": "{icon} {volume}%", "format-muted": " ", "format-icons": { - "default": [ - "", - " ", - " " - ] + "default": ["", " ", " "] }, "on-click": "pavucontrol" }, diff --git a/home-manager/hyprland/waybar/config/style.css b/home-manager/hyprland/waybar/config/style.css index 69d7c6a..77d2de3 100644 --- a/home-manager/hyprland/waybar/config/style.css +++ b/home-manager/hyprland/waybar/config/style.css @@ -1,37 +1,37 @@ @import "mocha.css"; * { - font-family: JetBrainsMono Nerd Font; - font-size: 15px; - min-height: 0; + font-family: JetBrainsMono Nerd Font; + font-size: 15px; + min-height: 0; } #waybar { - background: transparent; - color: @text; - margin: 5px 5px; + background: transparent; + color: @text; + margin: 5px 5px; } #workspaces { - border-radius: 1rem; - background-color: @surface0; - margin: 5px 5px 5px 1rem; + border-radius: 1rem; + background-color: @surface0; + margin: 5px 5px 5px 1rem; } #workspaces button { - color: @lavender; - border-radius: 1rem; - padding: 0.4rem; + color: @lavender; + border-radius: 1rem; + padding: 0.4rem; } #workspaces button.active { - color: @sky; - border-radius: 1rem; + color: @sky; + border-radius: 1rem; } #workspaces button:hover { - color: @sapphire; - border-radius: 1rem; + color: @sapphire; + border-radius: 1rem; } #language, @@ -44,61 +44,61 @@ #wireplumber, #custom-lock, #custom-power { - background-color: @surface0; - padding: 0.5rem 1rem; - margin: 5px 0; + background-color: @surface0; + padding: 0.5rem 1rem; + margin: 5px 0; } #clock { - color: @blue; + color: @blue; } #backlight { - color: @yellow; + color: @yellow; } #backlight { - border-radius: 0; + border-radius: 0; } #language { - color: @red; - border-radius: 1rem 0 0 1rem; - margin-left: 1rem; + color: @red; + border-radius: 1rem 0 0 1rem; + margin-left: 1rem; } #wireplumber { - color: @maroon; + color: @maroon; } #custom-music { - color: @mauve; - border-radius: 1rem; + color: @mauve; + border-radius: 1rem; } #window { - color: @mauve; - border-radius: 1rem; + color: @mauve; + border-radius: 1rem; } #custom-lock { - border-radius: 1rem 0 0 1rem; - color: @lavender; + border-radius: 1rem 0 0 1rem; + color: @lavender; } #custom-power { - margin-right: 1rem; - border-radius: 0 1rem 1rem 0; - color: @red; + margin-right: 1rem; + border-radius: 0 1rem 1rem 0; + color: @red; } #custom-notification { - margin-right: 1rem; - border-radius: 0 1rem 1rem 0; - color: @sapphire; + margin-right: 1rem; + border-radius: 0 1rem 1rem 0; + color: @sapphire; } #tray { - margin-right: 1rem; - border-radius: 1rem; + margin-right: 1rem; + border-radius: 1rem; } diff --git a/home-manager/wlogout/style.css b/home-manager/wlogout/style.css index e3b65e7..54752da 100644 --- a/home-manager/wlogout/style.css +++ b/home-manager/wlogout/style.css @@ -1,51 +1,53 @@ * { - background-image: none; - box-shadow: none; + background-image: none; + box-shadow: none; } window { - background-color: rgba(30, 30, 46, 0.90); + background-color: rgba(30, 30, 46, 0.9); } button { - border-radius: 0; - border-color: #f5c2e7; - text-decoration-color: #cdd6f4; - color: #cdd6f4; - background-color: #181825; - border-style: solid; - border-width: 1px; - background-repeat: no-repeat; - background-position: center; - background-size: 25%; + border-radius: 0; + border-color: #f5c2e7; + text-decoration-color: #cdd6f4; + color: #cdd6f4; + background-color: #181825; + border-style: solid; + border-width: 1px; + background-repeat: no-repeat; + background-position: center; + background-size: 25%; } -button:focus, button:active, button:hover { - /* 20% Overlay 2, 80% mantle */ - background-color: rgb(48, 50, 66); - outline-style: none; +button:focus, +button:active, +button:hover { + /* 20% Overlay 2, 80% mantle */ + background-color: rgb(48, 50, 66); + outline-style: none; } #lock { - background-image: url("./lock.svg"); + background-image: url("./lock.svg"); } #logout { - background-image: url("./logout.svg"); + background-image: url("./logout.svg"); } #suspend { - background-image: url("./suspend.svg"); + background-image: url("./suspend.svg"); } #hibernate { - background-image: url("./hibernate.svg"); + background-image: url("./hibernate.svg"); } #shutdown { - background-image: url("./shutdown.svg"); + background-image: url("./shutdown.svg"); } #reboot { - background-image: url("./reboot.svg"); + background-image: url("./reboot.svg"); } diff --git a/modules/development.nix b/modules/development.nix index c45b96a..9c3d445 100644 --- a/modules/development.nix +++ b/modules/development.nix @@ -12,8 +12,13 @@ nodejs pnpm gcc # Required for C, Rust and others - # Formatters + # Language servers nixd + # Formatters + nixfmt-rfc-style + treefmt + nodePackages.prettier + shfmt ]; virtualisation.docker = { diff --git a/modules/steam.nix b/modules/steam.nix index 14b5c3a..6a9bb65 100644 --- a/modules/steam.nix +++ b/modules/steam.nix @@ -2,9 +2,9 @@ { programs.steam = { - enable = true; - remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play - dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server - localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers + enable = true; + remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play + dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server + localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers }; } diff --git a/modules/stylix.nix b/modules/stylix.nix index 2d05701..7ec6622 100644 --- a/modules/stylix.nix +++ b/modules/stylix.nix @@ -1,16 +1,16 @@ { pkgs, ... }: { - stylix = { - enable = true; - image = ../catppuccin.png; - base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml"; - polarity = "dark"; - opacity.terminal = 0.8; - override = { - base02 = "b0b0b0"; # Comments in shell - base03 = "b0b0b0"; # Comments in nvim - base04 = "b0b0b0"; # Secondary text in shell - }; + stylix = { + enable = true; + image = ../catppuccin.png; + base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml"; + polarity = "dark"; + opacity.terminal = 0.8; + override = { + base02 = "b0b0b0"; # Comments in shell + base03 = "b0b0b0"; # Comments in nvim + base04 = "b0b0b0"; # Secondary text in shell }; + }; } diff --git a/test b/test index a8cc239..43bcfe1 100755 --- a/test +++ b/test @@ -3,4 +3,4 @@ # Rebuild and switch the environment if successful git add . ./fmt -nh os test . +nh os test . "$@" diff --git a/treefmt.toml b/treefmt.toml new file mode 100644 index 0000000..12be96b --- /dev/null +++ b/treefmt.toml @@ -0,0 +1,18 @@ +[formatter.nixfmt-rfc-style] +command = "nixfmt" +includes = ["*.nix"] + +[formatter.prettier] +command = "prettier" +includes = ["*.css", "*.json", "*.jsonc", "*.yaml"] +options = ["--write"] + +[formatter.shell] +command = "shfmt" +includes = ["fmt", "test", "switch"] +excludes = [] +options = [ +"--indent", "2", +"--simplify", +"--write", +]