Nb.: work-in-progress, unstable/incomplete.
if you really want to use, clone and load or use an advanced package manager like Elpaca.
E.g.,
(use-package sysinfo-environs
:ensure (:wait t :host github :repo "emacs-bigtop/sysinfo-environs")
:demand t
:config
(setq this-system-os
(let ((idlike
(sysinfo-environs-look-up-field "os-release-info" "ID_LIKE")))
(if idlike
idlike
(sysinfo-environs-look-up-field "os-release-info" "ID")))))Or Emacs 30+ built-in package-vc:
(use-package sysinfo-environs
:vc (sysinfo-environs :url "https://github.com/emacs-bigtop/sysinfo-environs"
:branch "main")
:ensure t
:config
(setq this-system-os
(let ((idlike
(sysinfo-environs-look-up-field "os-release-info" "ID_LIKE")))
(if idlike
idlike
(sysinfo-environs-look-up-field "os-release-info" "ID")))))Or quelpa:
(use-package sysinfo-environs
:quelpa (sysinfo-environs :fetcher github :repo "emacs-bigtop/sysinfo-environs")
:ensure t
:config
(setq this-system-os
(let ((idlike
(sysinfo-environs-look-up-field "os-release-info" "ID_LIKE")))
(if idlike
idlike
(sysinfo-environs-look-up-field "os-release-info" "ID")))))(See below discussion for why these options.)
Get information about your Emacs and your system.
Can be used to extract particular bits of information, or to display nice Org-formatted tables of information.
(The idea being something like neofetch or fastfetch, but for/in Emacs; but also (perhaps more usefully) a nice frontend for programmatically executing Elisp [e.g., in your init.el, do different things depending not only on whether you’re on Linux or another OS, but also depending on exactly which Linux distro (or distro family) you’re running on] or doing other system-specific things [e.g., setting PDF metadata].)
For the latter, currently the following functions are defined and can be used as interactive commands which show information in a temp buffer with Org-mode styling:
sysinfo-environs-os-release-info: show the/etc/os-releaseinfo (on this information and specification, see: OS_RELEASE(5))sysinfo-environs-os-uname-info-display: show various information thatunameknows about (onuname, see here)sysinfo-environs-os-release-and-uname-display: show both of the previoussysinfo-environs-emacs-self-info-display: show information about your Emacs (version, toolkit &c.)sysinfo-environs-full-sys-info-display: show all the information that Emacs System Information and Environs can display. [currently this is all of the above, plus what very basic system information Emacs knows about your OS]. this is encoded in variablesysinfo-environs-dataset-alist.
Since /etc/os-release defines a field LOGO which can be specified with the name of the icon/image for the distro, the function sysinfo-environs-sysinfo tries to find the appropriate image file (in the best resolution, the .svg if possible) on your system, and any interactive functions which display system information involving the information from /etc/os-release will try to display this image in the temp buffer:
[Currently, sysinfo-environs-sysinfo tries in order:
'("/usr/local/share/icons" ;; if you've a local thing
(concat "/usr/share/" os-id-name) ;; e.g. /usr/share/endeavouros
"/usr/share/pixmaps" ;; another place they might be
"/run/current-system/profile/share/icons" ;; where they are on Guix
;; (& maybe Nix?)
"/usr/share/icons") ;; usual placeOpen an issue if you’re on a system where there should be system/distro/os icons and they’re somewhere else and so sysinfo-environs-sysinfo isn’t finding them.]
Another screenshot, showing more system information:

For particular pieces of information, you can use the sysinfo-environs-look-up-field function, either in Elisp or as an interactive command.
When sysinfo-environs-look-up-field it will ask the user to choose between the datasets in sysinfo-environs-dataset-alist and then show a list of fields from the dataset and ask the user to choose one of these and then message the value of that field in the message area/echo buffer.
When called in Elisp, sysinfo-environs-look-up-field can be passed just the dataset, in which case it behaves interactively, as above (just not asking again for the dataset, but still asking the user to choose a field) - and the dataset can be passed by either its name in sysinfo-environs-dataset-alist (e.g., "uname-info" or the function itself (e.g., (sysinfo-environs-parse-uname-info)).
Or else sysinfo-environs-look-up-field can be passed both dataset and field name, and it will return the value of that field in that dataset:
E.g.,
(sysinfo-environs-look-up-field "emacs-info" "system-type") ;; =
;; gnu/linux
(sysinfo-environs-look-up-field (sysinfo-environs-emacs-known-sysinfo) "system-type") ;; =
;; gnu/linux
(sysinfo-environs-look-up-field "emacs-self-info" "toolkit") ;; =
;; "Lucid/Athena-toolkit (X toolkit)"
(sysinfo-environs-look-up-field "uname-info" "KERNEL_RELEASE") ;; =
;; "6.13.5"
(sysinfo-environs-look-up-field "os-release-info" "ID") ;; =
;; "guix"This last example is one of the prompting factors for this package: it can be useful to know not only if the current instance of Emacs is running on Linux (rather than, e.g., Windows) but also which distro it’s running under. Because you might have a single Emacs init.el that you use across many systems and want to keep synchronised (say, with Syncthing) in order to have changes you make to your init.el propagate across all of your Emacs instances on various machines, but you might some things to work differently on different machines depending on the particulars of the machine. Which in some cases might include which distro Emacs is running under. (In the past I’ve just used (system-name) for this and “hard-coded” things by knowing that the computers called “my-guix-laptop” and “old-thinkpad02” are both running on Guix.)
There are two very useful values in /etc/os-release, and thus accessible by sysinfo-environs-look-up-field, namely ID and ID_LIKE.
So on a Guix machine, if you call (sysinfo-environs-look-up-field "os-release-info" "ID"), you’ll get back "guix" . If you’re running CachyOS, (sysinfo-environs-look-up-field "os-release-info" "ID") will give you back "cachyos" and (sysinfo-environs-look-up-field "os-release-info" "ID_LIKE") will give you back "arch" - because CachyOS is an Arch Linux derivative. It might be useful to know the particular variant/derivative you’re running Emacs under (e.g., CachyOS), but you might just want to know “is this essentially an Arch machine, whether it’s pure Arch or CachyOS or EndeavourOS or Garuda &c.?”
If you’re going to use it like this, make sure to require sysinfo-environs early in your init.el (i.e., before you’re going to call on it.)
If you’re using a package manager like Elpaca, you’ll want to use :ensure (:wait t) :demand t, e.g.:
(use-package sysinfo-environs
:ensure (:wait t :host github :repo "emacs-bigtop/sysinfo-environs")
:demand t
:config
(setq this-system-os
(sysinfo-environs-look-up-field "os-release-info" "ID")))And so, as in the above config example, you could set a variable which gives you the distro that Emacs is running under, and so you could do something like:
(use-package pdf-tools
:ensure (if (string= this-system-os "guix") nil t)
:config
(pdf-tools-install 'no-query))(This example is for one of my use-cases: I generally want to use Elpaca to manage packages across all of my machines, regardless of which particular OS they’re running, but on Guix, I have to use Guix’s own packaged version of emacs-pdf-tools because PDF Tools wants to install other packages and then compile itself and this won’t work on Guix, but works on, e.g., Arch. So here I use use-package to require PDF Tools, but only try to have Elpaca install PDF Tools itself (rather than relying on the OS to already have installed it) when the machine isn’t running on Guix.)
Because of the difference between the os-release ID and ID_LIKE values, and the fact that not all distros will set ID_LIKE, you might want to set your “this-system-os” variable (whatever you want to call it) like this:
(setq this-system-os
(let ((idlike
(sysinfo-environs-look-up-field "os-release-info" "ID_LIKE")))
(if idlike
idlike
(sysinfo-environs-look-up-field "os-release-info" "ID"))))This will set this-system-os to the value of ID_LIKE if that is defined, and to the value of ID otherwise. This means this-system-os will be "guix" on your Guix machine and "arch" on both your vanilla Arch machine and your CachyOS machine.
What if you want to encode some system information in your LaTeX-produced PDF?
There’s a number of template/completion packages; I’ve been using TempEl, with a templates file located at ~/.emacs.d/templates. So something like (but see TempEl’s documentation for the config) in your init.el:
(use-package tempel
:ensure t
;; Require trigger prefix before template name when completing.
;; :custom
;; (tempel-trigger-prefix "<")
:bind (("M-+" . tempel-complete) ;; Alternative tempel-expand
("M-*" . tempel-insert))
:init
(setq tempel-path "~/.emacs.d/templates")
;; Setup completion at point
(defun tempel-setup-capf ()
;; Add the Tempel Capf to `completion-at-point-functions'.
;; `tempel-expand' only triggers on exact matches. Alternatively use
;; `tempel-complete' if you want to see all matches, but then you
;; should also configure `tempel-trigger-prefix', such that Tempel
;; does not trigger too often when you don't expect it. NOTE: We add
;; `tempel-expand' *before* the main programming mode Capf, such
;; that it will be tried first.
(setq-local completion-at-point-functions
(cons #'tempel-expand
completion-at-point-functions)))
(add-hook 'prog-mode-hook 'tempel-setup-capf)
(add-hook 'text-mode-hook 'tempel-setup-capf)
;; Optionally make the Tempel templates available to Abbrev,
;; either locally or globally. `expand-abbrev' is bound to C-x '.
;; (add-hook 'prog-mode-hook #'tempel-abbrev-mode)
;; (global-tempel-abbrev-mode)
)
;; Optional: Add tempel-collection.
;; The package is young and doesn't have comprehensive coverage.
(use-package tempel-collection
:ensure t)And then in my ~/.emacs.d/templates file:
;; <other shortcuts here>
;; define shortcuts for `tex-mode' (including `hyperrefv')
tex-mode
;; `hyperrefv' is the template shortcut; hit `TAB' key to expand:
(hyperrefv
;; TeX chokes on _
(replace-regexp-in-string
"_" "_"
;; TeX doesn't like # either
(replace-regexp-in-string
"#" "\\\\#"
;; use TeX-specified \title and \author, and then set `creator'
(concat
;; make a "\" TeX-command prefix
(make-string 1 ?\\)
"usepackage[pdfusetitle,pdfcreator={"
;; Emacs specs
"GNU Emacs "
(sysinfo-environs-look-up-field "emacs-self-info" "emacs-version")
" (build "
(sysinfo-environs-look-up-field "emacs-self-info" "emacs-build-number")
;; if there is a build-date
(let ((eb-date (sysinfo-environs-look-up-field "emacs-self-info" "emacs-build-time")))
(when eb-date
(concat " [of " eb-date "]")))
", "
(sysinfo-environs-look-up-field "emacs-self-info" "toolkit")
;; if there is a scrollbars toolkit
(let ((scrollb (sysinfo-environs-look-up-field "emacs-self-info" "scrollbars-toolkit")))
(when (string= scrollb "none")
(setq scrollb "no"))
(when scrollb
(concat ", " scrollb " scroll bars")))
;; if there is cairo
(let ((cairov (sysinfo-environs-look-up-field "emacs-self-info" "cairo-version")))
(when cairov
(concat ", cairo version " cairov)))
")"
" with AUCTeX "
AUCTeX-version
;; (pkg-info-package-version 'auctex) ;; = old way of getting auctex version
" on "
;; OS/distro name:
(sysinfo-environs-look-up-field "os-release-info" "PRETTY_NAME")
" ("
;; kernel name (e.g., "Linux"):
(sysinfo-environs-look-up-field "uname-info" "KERNEL_NAME")
" "
;; kernel version:
(sysinfo-environs-look-up-field "uname-info" "KERNEL_RELEASE")
" ["
;; other kernel specs:
(sysinfo-environs-look-up-field "uname-info" "KERNEL_SPECS")
;; called as arguments to TeX package `hyperref'
"])}]{hyperref}"))))And then in a LaTeX document, somewhere in the preamble type hyperrefv and then hit TAB and it expands into something like:
\usepackage[pdfusetitle,pdfcreator={GNU Emacs 30.1 (build 2 [of 2025-03-04 20:01:02], Lucid/Athena-toolkit (X toolkit), Xaw3d scroll bars, cairo version 1.18.2) with AUCTeX 14.0.9 on EndeavourOS (Linux 6.13.5-1-cachyos [\#1 SMP PREEMPT_DYNAMIC Fri, 07 Mar 2025 08:15:41 +0000])}]{hyperref}Something similar would work with other template/completion packages like yasnippet.
(The above LaTeX might produce a PDF that has metadata like this:
[output from PDF Fonts Etc.])
.....

