From cf913c62a020ac1959f35a1984344bc48c94df5a Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Mon, 17 Jun 2024 21:17:17 +0200 Subject: [PATCH] nix refators and additions --- .config/waybar/config.cgt | 12 +++++- .config/waybar/style.css.cgt | 11 ++++++ .ssh/config | 3 ++ flake.lock | 6 +-- flake.nix | 19 +++++---- nix/cgnix/default.nix | 2 +- nix/default.nix | 1 + nix/jdtls-bundles.nix | 2 +- nix/mcdev.nix | 2 +- nix/mzte-nix.nix | 2 +- nix/nushell-plugins.nix | 2 +- nix/pkgs/default.nix | 6 +++ nix/pkgs/thumbnailers.nix | 77 ++++++++++++++++++++++++++++++++++++ 13 files changed, 127 insertions(+), 18 deletions(-) create mode 100644 nix/pkgs/default.nix create mode 100644 nix/pkgs/thumbnailers.nix diff --git a/.config/waybar/config.cgt b/.config/waybar/config.cgt index 63ebf60..7494e43 100644 --- a/.config/waybar/config.cgt +++ b/.config/waybar/config.cgt @@ -1,5 +1,7 @@ ; ;; vim: ft=fennel +(local format-icons ["▁" "▂" "▃" "▄" "▅" "▆" "▇" "█"]) + {:spacing 4 :layer :top ; @@ -8,6 +10,7 @@ :modules-left [:hyprland/workspaces :hyprland/window] ; :modules-right [:mpris + :cava :cpu :memory :pulseaudio @@ -16,6 +19,11 @@ :battery :clock :tray] + :cava {:hide_on_silence true + :bars 16 + :bar_delimiter 0 + :method :pipewire + : format-icons} :mpris {:format "{status_icon} {dynamic}" :interval 5 :dynamic-order [:title :artist :position :length] @@ -29,8 +37,8 @@ :format-alt "{:%Y-%m-%d}"} :cpu {:format (.. (faccumulate [s "" i 0 (- (cg.opt.system :nproc) 1)] (.. s "{icon" i "}")) " {usage}% ") - :format-icons ["▁" "▂" "▃" "▄" "▅" "▆" "▇" "█"] - :interval 2} + :interval 2 + : format-icons} :memory {:format "{}% "} :temperature {:hwmon-path "<% opt.cpu_temp_hwmon %>" :critical-threshold 80 diff --git a/.config/waybar/style.css.cgt b/.config/waybar/style.css.cgt index 4630f24..065a611 100644 --- a/.config/waybar/style.css.cgt +++ b/.config/waybar/style.css.cgt @@ -77,6 +77,17 @@ window#waybar.PCSX2 #window { background: @teal; } +#cava { + margin-top: 8px; + margin-left: 8px; + padding-left: 16px; + padding-right: 16px; + margin-bottom: 0; + transition: none; + color: @sapphire; + background: @surface0; +} + #mpris { margin-top: 8px; margin-left: 8px; diff --git a/.ssh/config b/.ssh/config index 1fda062..a04fda7 100644 --- a/.ssh/config +++ b/.ssh/config @@ -5,6 +5,9 @@ Host aur.archlinux.org Host github.com UpdateHostKeys yes +Host mzte.de + Port 22004 + Host * HostKeyAlgorithms=+ssh-rsa PubkeyAcceptedKeyTypes +ssh-rsa diff --git a/flake.lock b/flake.lock index 409ad87..ea52d31 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1718160348, - "narHash": "sha256-9YrUjdztqi4Gz8n3mBuqvCkMo4ojrA6nASwyIKWMpus=", + "lastModified": 1718318537, + "narHash": "sha256-4Zu0RYRcAY/VWuu6awwq4opuiD//ahpc2aFHg2CWqFY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "57d6973abba7ea108bac64ae7629e7431e0199b6", + "rev": "e9ee548d90ff586a6471b4ae80ae9cfcbceb3420", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 6fc8518..8f3272d 100644 --- a/flake.nix +++ b/flake.nix @@ -16,9 +16,11 @@ common = base-pkgs.callPackage ./lib/common-nix { }; root-mod = { config, pkgs, ... }: { - options.packages = nixpkgs.lib.mkOption { }; - options.dev-shells = nixpkgs.lib.mkOption { }; - options.nixpkgs.overlays = nixpkgs.lib.mkOption { default = []; }; + options.nixpkgs.overlays = nixpkgs.lib.mkOption { default = [ ]; }; + options.output = nixpkgs.lib.mkOption { + default = { }; + type = with nixpkgs.lib.types; attrsOf anything; + }; config._module.args = rec { pkgs = base-pkgs.appendOverlays config.nixpkgs.overlays; @@ -28,7 +30,7 @@ }; # devshell for the dotfiles - config.dev-shells.default = nixpkgs.legacyPackages.${system}.mkShell { + config.output.devShells.default = nixpkgs.legacyPackages.${system}.mkShell { buildInputs = with pkgs; [ # packages required to build scripts @@ -57,6 +59,10 @@ "run-confgen" ]; }; + + config.output.mzteinit = base-pkgs.callPackage ./scripts/mzteinit/package.nix { }; + + config.output.overlay = final: prev: config.output.packages; }; modopt = nixpkgs.lib.evalModules { @@ -64,10 +70,7 @@ specialArgs = { inherit common; }; }; in - { + modopt.config.output // { config = modopt; - mzteinit = base-pkgs.callPackage ./scripts/mzteinit/package.nix { }; - packages = modopt.config.packages; - devShells = modopt.config.dev-shells; }); } diff --git a/nix/cgnix/default.nix b/nix/cgnix/default.nix index 714181b..1fc5730 100644 --- a/nix/cgnix/default.nix +++ b/nix/cgnix/default.nix @@ -20,7 +20,7 @@ in config.cgnix.entries."fennel.lua" = "${pkgs.luajitPackages.fennel}/share/lua/5.1/fennel.lua"; - config.packages.cgnix = pkgs.writeTextFile { + config.output.packages.cgnix = pkgs.writeTextFile { name = "nix.lua"; text = '' return { diff --git a/nix/default.nix b/nix/default.nix index 7f8fae8..4db01eb 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -2,6 +2,7 @@ { imports = [ ./cgnix + ./pkgs ./jdtls-bundles.nix ./mcdev.nix ./mzte-nix.nix diff --git a/nix/jdtls-bundles.nix b/nix/jdtls-bundles.nix index 633b1b5..e65055e 100644 --- a/nix/jdtls-bundles.nix +++ b/nix/jdtls-bundles.nix @@ -1,6 +1,6 @@ { pkgs, ... }: { - config.packages.jdtls-bundles = pkgs.linkFarm "jdtls-bundles" [ + output.packages.jdtls-bundles = pkgs.linkFarm "jdtls-bundles" [ { name = "java-debug.jar"; path = pkgs.fetchurl { diff --git a/nix/mcdev.nix b/nix/mcdev.nix index 1ef0c50..cbfb45b 100644 --- a/nix/mcdev.nix +++ b/nix/mcdev.nix @@ -19,7 +19,7 @@ let ]; in { - dev-shells = builtins.mapAttrs + output.devShells = builtins.mapAttrs (_: extra-pkgs: let shpgks = libs ++ xorg-libs ++ extra-pkgs; diff --git a/nix/mzte-nix.nix b/nix/mzte-nix.nix index 3b6c22e..a9ea146 100644 --- a/nix/mzte-nix.nix +++ b/nix/mzte-nix.nix @@ -45,7 +45,7 @@ in (flakePkg "github:zhaofengli/attic") ]; - config.packages.mzte-nix = pkgs.symlinkJoin { + config.output.packages.mzte-nix = pkgs.symlinkJoin { name = "mzte-nix"; paths = lib.concatMap (p: map (o: p.${o}) p.outputs) config.mzte-nix-packages; }; diff --git a/nix/nushell-plugins.nix b/nix/nushell-plugins.nix index 559dad4..be11b86 100644 --- a/nix/nushell-plugins.nix +++ b/nix/nushell-plugins.nix @@ -40,7 +40,7 @@ }) ]; - config.packages.nushell-plugins = + config.output.packages.nushell-plugins = let pluginName = d: lib.removePrefix "nu-plugin-" d.name; in diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix new file mode 100644 index 0000000..f1c7d13 --- /dev/null +++ b/nix/pkgs/default.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + imports = [ + ./thumbnailers.nix + ]; +} diff --git a/nix/pkgs/thumbnailers.nix b/nix/pkgs/thumbnailers.nix new file mode 100644 index 0000000..35a63ac --- /dev/null +++ b/nix/pkgs/thumbnailers.nix @@ -0,0 +1,77 @@ +# A collection of tumbler-compatible thumbnailer scripts for: +# - Text +# - OpenSCAD and STL models + +{ pkgs, ... }: +let + mkThumbnailerEntry = { name, mime, exec }: pkgs.writeTextDir + "share/thumbnailers/${name}.thumbnailer" + '' + [Thumbnailer Entry] + Version=1.0 + Encoding=UTF-8 + Type=X-Thumbnailer + Name=${name} + MimeType=${mime} + Exec=${exec} + ''; +in +{ + # See https://docs.xfce.org/xfce/tumbler/available_plugins#customized_thumbnailer_for_text-based_documents + output.packages.mzte-thumbnailer-text = + let + textthumb = pkgs.writeShellScript "textthumb" '' + iFile=$(<"$1") + tempFile=$(mktemp) && { + echo "''${iFile:0:1600}" > "$tempFile" + + ${pkgs.imagemagick}/bin/convert \ + -size 210x290 \ + -background white \ + -pointsize 5 \ + -border 10x10 \ + -bordercolor "#CCC" \ + -font ${pkgs.dejavu_fonts.minimal}/share/fonts/truetype/DejaVuSans.ttf \ + caption:@"$tempFile" \ + "$2" + + rm "$tempFile" + } + ''; + in + mkThumbnailerEntry { + name = "mzte-thumbnailer-text"; + mime = "text/plain;text/x-log;text/html;text/css;"; + exec = "${textthumb} %i %o"; + }; + + output.packages.mzte-thumbnailer-openscad = + let + scadthumb = pkgs.writeShellScript "scadthumb" '' + ${pkgs.openscad-unstable}/bin/openscad --imgsize "500,500" -o "$2" "$1" 2>/dev/null + ''; + in + mkThumbnailerEntry { + name = "mzte-thumbnailer-openscad"; + mime = "application/x-openscad;"; + exec = "${scadthumb} %i %o"; + }; + + # See: https://docs.xfce.org/xfce/tumbler/available_plugins#customized_thumbnailer_for_stl_content + output.packages.mzte-thumbnailer-stl = + let + stlthumb = pkgs.writeShellScript "stlthumb" '' + if TEMP=$(mktemp --directory --tmpdir tumbler-stl-XXXXXX); then + cp "$1" "$TEMP/source.stl" + echo 'import("source.stl", convexity=10);' > "$TEMP/thumbnail.scad" + ${pkgs.openscad-unstable}/bin/openscad --imgsize "500,500" -o "$2" "$TEMP/thumbnail.scad" 2>/dev/null + rm -rf $TEMP + fi + ''; + in + mkThumbnailerEntry { + name = "mzte-thumbnailer-stl"; + mime = "model/stl;"; + exec = "${stlthumb} %i %o"; + }; +}