From 5e1fbf2fe3367aa624a12372155a1b27f378a6ae Mon Sep 17 00:00:00 2001 From: harry123 Date: Thu, 23 Jan 2025 22:08:28 +0100 Subject: [PATCH] more customization --- flake.lock | 106 +++++++++++------------ flake.nix | 2 +- home-manager/dotfiles/bash/.bashrc | 3 + home-manager/dotfiles/nnn/plugins/nmount | 88 +++++++++++++++++++ home-manager/dotfiles/sway/config | 1 + home-manager/home.nix | 9 ++ packages/miku-cursor.nix | 7 +- 7 files changed, 157 insertions(+), 59 deletions(-) create mode 100644 home-manager/dotfiles/nnn/plugins/nmount diff --git a/flake.lock b/flake.lock index feb976d..d4d1a14 100644 --- a/flake.lock +++ b/flake.lock @@ -32,11 +32,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1731092955, - "narHash": "sha256-L1hLXf4IDZ0KoXbFiSNNZJ7IrReEr/J+CLt6Rl4Ea3M=", + "lastModified": 1735301051, + "narHash": "sha256-jU88Q9tP4vuvWYGQcmOdFwI9e2uMPVYJHbXdiklIH9o=", "owner": "anyrun-org", "repo": "anyrun", - "rev": "d2017f224b2bfd7e33573c7070e7c3e2960c7dcc", + "rev": "06017e753c8886d5296768dca80745ee09402a2d", "type": "github" }, "original": { @@ -128,11 +128,11 @@ ] }, "locked": { - "lastModified": 1733312601, - "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", + "lastModified": 1736143030, + "narHash": "sha256-+hu54pAoLDEZT9pjHlqL9DNzWz0NbUn8NEAHP7PQPzU=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", + "rev": "b905f6fc23a9051a6e1b741e1438dbfc0634c6de", "type": "github" }, "original": { @@ -150,11 +150,11 @@ ] }, "locked": { - "lastModified": 1733312601, - "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", + "lastModified": 1736143030, + "narHash": "sha256-+hu54pAoLDEZT9pjHlqL9DNzWz0NbUn8NEAHP7PQPzU=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", + "rev": "b905f6fc23a9051a6e1b741e1438dbfc0634c6de", "type": "github" }, "original": { @@ -185,18 +185,14 @@ "nixpkgs": [ "neovim-nightly-overlay", "nixpkgs" - ], - "nixpkgs-stable": [ - "neovim-nightly-overlay", - "nixpkgs" ] }, "locked": { - "lastModified": 1734797603, - "narHash": "sha256-ulZN7ps8nBV31SE+dwkDvKIzvN6hroRY8sYOT0w+E28=", + "lastModified": 1737465171, + "narHash": "sha256-R10v2hoJRLq8jcL4syVFag7nIGE7m13qO48wRIukWNg=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "f0f0dc4920a903c3e08f5bdb9246bb572fcae498", + "rev": "9364dc02281ce2d37a1f55b6e51f7c0f65a75f17", "type": "github" }, "original": { @@ -236,11 +232,11 @@ ] }, "locked": { - "lastModified": 1733333617, - "narHash": "sha256-nMMQXREGvLOLvUa0ByhYFdaL0Jov0t1wzLbKjr05P2w=", + "lastModified": 1736917206, + "narHash": "sha256-JTBWmyGf8K1Rwb+gviHIUzRJk/sITtT+72HXFkTZUjo=", "owner": "hercules-ci", "repo": "hercules-ci-effects", - "rev": "56f8ea8d502c87cf62444bec4ee04512e8ea24ea", + "rev": "afd0a42e8c61ebb56899315ee4084a8b2e4ff425", "type": "github" }, "original": { @@ -256,11 +252,11 @@ ] }, "locked": { - "lastModified": 1735344290, - "narHash": "sha256-oJDtWPH1oJT34RJK1FSWjwX4qcGOBRkcNQPD0EbSfNM=", + "lastModified": 1736373539, + "narHash": "sha256-dinzAqCjenWDxuy+MqUQq0I4zUSfaCvN9rzuCmgMZJY=", "owner": "nix-community", "repo": "home-manager", - "rev": "613691f285dad87694c2ba1c9e6298d04736292d", + "rev": "bd65bc3cde04c16755955630b344bc9e35272c56", "type": "github" }, "original": { @@ -281,11 +277,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1734999862, - "narHash": "sha256-CJ3dXoCQzbSR/b8kbswlf/JIGKIN/6c9ywRw2rQAIYY=", + "lastModified": 1737614530, + "narHash": "sha256-s5+trj2UfrIWlrCm+hKDB5+36kY5scH9MxM9zfU+4qc=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "0d0beafd94c34915fb951b31e165be5cf1cf3a7c", + "rev": "7d9aaf2f175602b8511e4c5134c4a975628c6948", "type": "github" }, "original": { @@ -297,11 +293,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1734989976, - "narHash": "sha256-DVlI7ua+VOkqC70WpSbJO+FjQyBEarGZnKoql7I7Unk=", + "lastModified": 1737560784, + "narHash": "sha256-bW3ub7hI5Ml+4cFErZvlbbQNDmmycoroRYYAegj33qo=", "owner": "neovim", "repo": "neovim", - "rev": "c51bf5a6b24928ac04d0bb129b1b424d4c78f28d", + "rev": "af0ef2ac9dd19b7c4005a3197334d3e7d554646c", "type": "github" }, "original": { @@ -317,11 +313,11 @@ ] }, "locked": { - "lastModified": 1733570843, - "narHash": "sha256-sQJAxY1TYWD1UyibN/FnN97paTFuwBw3Vp3DNCyKsMk=", + "lastModified": 1737504076, + "narHash": "sha256-/B4XJnzYU/6K1ZZOBIgsa3K4pqDJrnC2579c44c+4rI=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "a35b08d09efda83625bef267eb24347b446c80b8", + "rev": "65cc1fa8e36ceff067daf6cfb142331f02f524d3", "type": "github" }, "original": { @@ -364,11 +360,11 @@ }, "nixlib": { "locked": { - "lastModified": 1734829460, - "narHash": "sha256-dPhc+f2wkmhMqMIfq+hColJdysgVxKP9ilZ5bR0NRZI=", + "lastModified": 1736643958, + "narHash": "sha256-tmpqTSWVRJVhpvfSN9KXBvKEXplrwKnSZNAoNPf/S/s=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "0a31e8d833173ae63e43fd9dbff1ccf09c4f778c", + "rev": "1418bc28a52126761c02dd3d89b2d8ca0f521181", "type": "github" }, "original": { @@ -385,11 +381,11 @@ ] }, "locked": { - "lastModified": 1734915500, - "narHash": "sha256-A7CTIQ8SW0hfbhKlwK+vSsu4pD+Oaelw3v6goX6go+U=", + "lastModified": 1737057290, + "narHash": "sha256-3Pe0yKlCc7EOeq1X/aJVDH0CtNL+tIBm49vpepwL1MQ=", "owner": "nix-community", "repo": "nixos-generators", - "rev": "051d1b2dda3b2e81b38d82e2b691e5c2f4d335f4", + "rev": "d002ce9b6e7eb467cd1c6bb9aef9c35d191b5453", "type": "github" }, "original": { @@ -400,11 +396,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1734856068, - "narHash": "sha256-Q+CB1ajsJg4Z9HGHTBAGY1q18KpnnkmF/eCTLUY6FQ0=", + "lastModified": 1737525964, + "narHash": "sha256-3wFonKmNRWKq1himW9N3TllbeGIHFACI5vmLpk6moF8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "93ff48c9be84a76319dac293733df09bbbe3f25c", + "rev": "5757bbb8bd7c0630a0cc4bb19c47e588db30b97c", "type": "github" }, "original": { @@ -416,11 +412,11 @@ }, "nixpkgsSmall": { "locked": { - "lastModified": 1735640024, - "narHash": "sha256-4I5qiwYmZFygUC3numWaMhStwRYX+Lk0ISddJIoHEwE=", + "lastModified": 1737624615, + "narHash": "sha256-LS94mLWVwLvHQEqXlxO9hQYbgUccoy33o7NsB/nFr6A=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "bc130b5a632d110d76f1584213eab6e029fd7802", + "rev": "d075248e4db179dd0b4fecf80c1aaa1de8954ddc", "type": "github" }, "original": { @@ -432,11 +428,11 @@ }, "nixpkgsUnstable": { "locked": { - "lastModified": 1735471104, - "narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=", + "lastModified": 1737469691, + "narHash": "sha256-nmKOgAU48S41dTPIXAq0AHZSehWUn6ZPrUKijHAMmIk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4", + "rev": "9e4d5190a9482a1fb9d18adf0bdb83c6e506eaab", "type": "github" }, "original": { @@ -448,11 +444,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1735531152, - "narHash": "sha256-As8I+ebItDKtboWgDXYZSIjGlKeqiLBvjxsQHUmAf1Q=", + "lastModified": 1737569578, + "narHash": "sha256-6qY0pk2QmUtBT9Mywdvif0i/CLVgpCjMUn6g9vB+f3M=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3ffbbdbac0566a0977da3d2657b89cbcfe9a173b", + "rev": "47addd76727f42d351590c905d9d1905ca895b82", "type": "github" }, "original": { @@ -516,11 +512,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1734546875, - "narHash": "sha256-6OvJbqQ6qPpNw3CA+W8Myo5aaLhIJY/nNFDk3zMXLfM=", + "lastModified": 1737411508, + "narHash": "sha256-j9IdflJwRtqo9WpM0OfAZml47eBblUHGNQTe62OUqTw=", "owner": "Mic92", "repo": "sops-nix", - "rev": "ed091321f4dd88afc28b5b4456e0a15bd8374b4d", + "rev": "015d461c16678fc02a2f405eb453abb509d4e1d4", "type": "github" }, "original": { @@ -552,11 +548,11 @@ ] }, "locked": { - "lastModified": 1734982074, - "narHash": "sha256-N7M37KP7cHWoXicuE536GrVvU8nMDT/gpI1kja2hkdg=", + "lastModified": 1737483750, + "narHash": "sha256-5An1wq5U8sNycOBBg3nsDDgpwBmR9liOpDGlhliA6Xo=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "e41e948cf097cbf96ba4dff47a30ea6891af9f33", + "rev": "f2cc121df15418d028a59c9737d38e3a90fbaf8f", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index c6d461c..a8062ea 100644 --- a/flake.nix +++ b/flake.nix @@ -162,7 +162,7 @@ # Expose the package set, including overlays, for convenience. darwinPackages = self.darwinConfigurations."iMac-de-Eddie".pkgs; - defaultPackage.x86_64-linux = pkgs.callPackage ./packages/miku-cursor.nix {}; + packages.miku-cursor-linux = pkgs.callPackage ./packages/miku-cursor.nix {}; }; } diff --git a/home-manager/dotfiles/bash/.bashrc b/home-manager/dotfiles/bash/.bashrc index 96787ad..6f2d213 100644 --- a/home-manager/dotfiles/bash/.bashrc +++ b/home-manager/dotfiles/bash/.bashrc @@ -3,3 +3,6 @@ alias gocode="cd ~/Documents/Code/" kittysay meow eval "$(zoxide init bash)" eval "$(direnv hook bash)" + +# nnn configuration +NNN_PLUG='L:nmount' diff --git a/home-manager/dotfiles/nnn/plugins/nmount b/home-manager/dotfiles/nnn/plugins/nmount new file mode 100644 index 0000000..e05453f --- /dev/null +++ b/home-manager/dotfiles/nnn/plugins/nmount @@ -0,0 +1,88 @@ +#!/usr/bin/env sh + +# Description: Toggle mount status of a device using pmount +# If the device is not mounted, it will be mounted. +# If the device is mounted, it will be unmounted and powered down. +# +# Dependencies: lsblk, pmount (optional), udisks2 +# +# Usage: Runs `lsblk` on 'l', exits on 'Return`. +# +# Notes: +# - The script uses Linux-specific lsblk to list block devices. Alternatives: +# macOS: "diskutil list" +# BSD: "geom disk list" +# - The script uses udisksctl (from udisks2) to power down devices. This is also Linux-specific. +# Users on non-Linux platforms can comment it and use an alternative to power-down disks. +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +prompt="device name [e.g. sdXn] ('l'ist, 'q'uit): " + +lsblk + +printf "\nEnsure you aren't still in the mounted device.\n" +printf "%s" "$prompt" +read -r dev + +while [ -n "$dev" ]; do + if [ "$dev" = "l" ]; then + lsblk + elif [ "$dev" = "q" ]; then + exit + else + # LUKS volumes mounted with udisksctl appear differently than with pmount + if grep -qs "$dev " /proc/mounts || [ -n "$(lsblk -n "/dev/$dev" -o MOUNTPOINT)" ]; then + sync "$(lsblk -n "/dev/$dev" -o MOUNTPOINT | sed "/^$/d")" + if type pumount >/dev/null 2>&1; then + pumount "/dev/$dev" + exit_code="$?" + else + # Unlike pmount, udisksctl does not transparently handle LUKS volumes + # We need to manually get the unlocked device, unmount it, and then lock the volume + if lsblk -n "/dev/$dev" -o FSTYPE | grep "crypto_LUKS" >/dev/null; then + dev_map="$(udisksctl info -b /dev/"$dev" | grep "CleartextDevice" | grep -o "dm_2d[[:digit:]]*" | sed "s/_2d/-/")" + udisksctl unmount -b "/dev/$dev_map" --no-user-interaction >/dev/null + exit_code="$?" + udisksctl lock -b "/dev/$dev" --no-user-interaction >/dev/null + else + udisksctl unmount -b "/dev/$dev" --no-user-interaction >/dev/null + exit_code="$?" + fi + fi + if [ $exit_code -eq 0 ]; then + echo "/dev/$dev unmounted." + if udisksctl power-off -b "/dev/$dev" --no-user-interaction; then + echo "/dev/$dev ejected." + fi + fi + elif [ -b "/dev/$dev" ]; then + if type pmount >/dev/null 2>&1; then + pmount "/dev/$dev" + exit_code="$?" + else + # Unlike pmount, udisksctl does not transparently handle LUKS volumes + # We need to manually get the unlocked device and mount that instead of the volume itself + if [ "$(lsblk "/dev/$dev" -n -o FSTYPE)" = "crypto_LUKS" ]; then + dev_map=$(udisksctl unlock -b "/dev/$dev" --no-user-interaction | grep -o "dm-[[:digit:]]*") + udisksctl mount -b "/dev/$dev_map" --no-user-interaction >/dev/null + exit_code="$?" + else + udisksctl mount -b "/dev/$dev" --no-user-interaction >/dev/null + exit_code="$?" + fi + fi + if [ $exit_code -eq 0 ]; then + sleep 1 + echo "/dev/$dev mounted to $(lsblk -n "/dev/$dev" -o MOUNTPOINT | sed "/^$/d")." + fi + else + echo "/dev/$dev does not exist or is not a block device." + fi + fi + + echo + printf "%s" "$prompt" + read -r dev +done diff --git a/home-manager/dotfiles/sway/config b/home-manager/dotfiles/sway/config index 10d7625..b80b6e3 100755 --- a/home-manager/dotfiles/sway/config +++ b/home-manager/dotfiles/sway/config @@ -224,5 +224,6 @@ bar { swaybar_command waybar } +seat seat0 xcursor_theme "miku-cursor-linux" 36 include /etc/sway/config.d/* diff --git a/home-manager/home.nix b/home-manager/home.nix index 0961f3e..54f492d 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -18,6 +18,7 @@ nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "vscode" ]; + # The home.packages option allows you to install Nix packages into your # environment. home.packages = [ @@ -66,6 +67,7 @@ pkgs.xfce.thunar pkgs.gimp-with-plugins pkgs.fzf + pkgs.nnn pkgs.why3 pkgs.alt-ergo pkgs.cvc4 @@ -168,6 +170,13 @@ EDITOR = "nvim"; }; + home.pointerCursor = { + name = "miku-cursor-linux"; + size = 32; + gtk.enable = true; + package = pkgs.callPackage ../packages/miku-cursor.nix {}; + }; + programs.git = { userName = "harry123"; userEmail = "harryh@ik.me"; diff --git a/packages/miku-cursor.nix b/packages/miku-cursor.nix index a38ca7b..9a8fc66 100644 --- a/packages/miku-cursor.nix +++ b/packages/miku-cursor.nix @@ -6,12 +6,13 @@ stdenv.mkDerivation { src = fetchFromGitHub { owner = "supermariofps"; repo = "hatsune-miku-windows-linux-cursors"; - rev = "v${1.2.6}"; - hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; + rev = "1.2.6"; + hash = "sha256-OQjjOc9VnxJ7tWNmpHIMzNWX6WsavAOkgPwK1XAMwtE="; }; postInstall = '' - mkdir $out + mkdir -p $out/share/icons/miku-cursor-linux + cp -r * $out/share/icons/miku-cursor-linux ''; }