Moved autmounting to core

This commit is contained in:
2026-05-12 09:01:11 +03:00
parent f89e04d898
commit 83c279ded4
7 changed files with 4 additions and 138 deletions
-1
View File
@@ -19,6 +19,5 @@
./snx-rs.nix
./ytdl.nix
./nextcloud-client.nix
./udiskie.nix
];
}
-22
View File
@@ -1,22 +0,0 @@
{
lib,
config,
pkgs,
...
}: let
isEnabled =
config.azos.udiskie.enable;
in {
options.azos.udiskie.enable = lib.mkOption {
default = true;
example = true;
type = lib.types.bool;
};
config = lib.mkIf isEnabled {
services.udiskie = {
enable = true;
tray = "never";
};
};
}
+1 -1
View File
@@ -1,3 +1,3 @@
{
imports = [./audio.nix ./binfmt.nix ./bluetooth.nix ./steam.nix ./udisks.nix ./virtualization.nix];
imports = [./audio.nix ./binfmt.nix ./bluetooth.nix ./steam.nix ./virtualization.nix];
}
-19
View File
@@ -1,19 +0,0 @@
{
lib,
config,
pkgs,
...
}: let
isEnabled =
config.azos.udisks.enable;
in {
options.azos.udisks.enable = lib.mkOption {
default = true;
example = true;
type = lib.types.bool;
};
config = lib.mkIf isEnabled {
services.udisks2.enable = true;
};
}
+2
View File
@@ -86,6 +86,8 @@
auto-optimise-store = true;
};
azos.suites.exwm.enable = true;
home-manager = {
extraSpecialArgs = {inherit inputs outputs pkgs;};
users = {
-94
View File
@@ -46,100 +46,6 @@
(kbd "h") 'azos/connect-headphones)
#+end_src
** Storage
#+begin_src emacs-lisp
(defun azos/storage--lsblk-field (dev field)
"Get FIELD from lsblk DEV hash table."
(when (hash-table-p dev)
(gethash field dev)))
(defun azos/storage--list-devices ()
"Return flat list of partitions/devices from lsblk, with bare disks included."
(let* ((json-str (shell-command-to-string
"lsblk --json -o NAME,SIZE,LABEL,MOUNTPOINT,TYPE"))
(data (condition-case nil (json-parse-string json-str) (error nil)))
(devs '()))
(when (hash-table-p data)
(seq-do
(lambda (dev)
(let ((children (azos/storage--lsblk-field dev "children")))
(if (and (vectorp children) (> (length children) 0))
(seq-do (lambda (child) (push child devs)) children)
(push dev devs))))
(gethash "blockdevices" data)))
(nreverse devs)))
(defun azos/storage--null-p (val)
"Return t if VAL is a JSON null (i.e. :null)."
(eq val :null))
(defun azos/storage--label-str (dev)
"Format label for DEV, returning empty string if absent."
(let ((label (azos/storage--lsblk-field dev "label")))
(if (and label (not (azos/storage--null-p label)))
(format " [%s]" label)
"")))
(defun azos/storage/mount ()
"Mount an unmounted block device using udisksctl."
(interactive)
(let* ((devs (azos/storage--list-devices))
(unmounted (seq-filter
(lambda (d)
(let ((mp (azos/storage--lsblk-field d "mountpoint"))
(type (azos/storage--lsblk-field d "type")))
(and (member type '("part" "disk"))
(or (null mp) (azos/storage--null-p mp)))))
devs))
(choices (mapcar
(lambda (d)
(let ((name (azos/storage--lsblk-field d "name"))
(size (azos/storage--lsblk-field d "size")))
(cons (format "/dev/%s %s%s" name size (azos/storage--label-str d))
(format "/dev/%s" name))))
unmounted)))
(if choices
(let* ((selected (completing-read "Mount device: " (mapcar #'car choices) nil t))
(device (cdr (assoc selected choices))))
(message "%s" (string-trim
(shell-command-to-string
(format "udisksctl mount -b %s" device)))))
(message "No unmounted partitions found."))))
(defun azos/storage/unmount ()
"Unmount a mounted block device using udisksctl."
(interactive)
(let* ((devs (azos/storage--list-devices))
(mounted (seq-filter
(lambda (d)
(let ((mp (azos/storage--lsblk-field d "mountpoint")))
(and mp
(not (azos/storage--null-p mp))
(not (string-prefix-p "/nix" mp))
(not (string-prefix-p "/boot" mp))
(not (equal mp "/")))))
devs))
(choices (mapcar
(lambda (d)
(let ((name (azos/storage--lsblk-field d "name"))
(size (azos/storage--lsblk-field d "size"))
(mp (azos/storage--lsblk-field d "mountpoint")))
(cons (format "/dev/%s %s -> %s%s" name size mp (azos/storage--label-str d))
(format "/dev/%s" name))))
mounted)))
(if choices
(let* ((selected (completing-read "Unmount device: " (mapcar #'car choices) nil t))
(device (cdr (assoc selected choices))))
(message "%s" (string-trim
(shell-command-to-string
(format "udisksctl unmount -b %s" device)))))
(message "No mounted user partitions found."))))
(define-key azos/global-minor-mode/open-keymap (kbd "s m") 'azos/storage/mount)
(define-key azos/global-minor-mode/open-keymap (kbd "s u") 'azos/storage/unmount)
#+end_src
** Tab bar setup
#+begin_src emacs-lisp