Skip to content

Commit

Permalink
Switch to xonsh but preserve nushell instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
DustVoice committed Jan 24, 2025
1 parent c0cd19a commit bce541f
Show file tree
Hide file tree
Showing 13 changed files with 380 additions and 104 deletions.
1 change: 0 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export default defineConfig({
label: 'GnuPG',
items: [
'home/smartcard/gnupg',
'home/smartcard/gnupg/permission',
'home/smartcard/gnupg/missing',
'home/smartcard/gnupg/register',
'home/smartcard/gnupg/ssh',
Expand Down
47 changes: 44 additions & 3 deletions src/content/docs/home/Smartcard/GnuPG/index.mdx
Original file line number Diff line number Diff line change
@@ -1,20 +1,61 @@
---
title: GnuPG
title: Overview
---

import { Aside } from "@astrojs/starlight/components";
import { Aside, Tabs, TabItem, Steps } from "@astrojs/starlight/components";

To now actually use the YubiKey, I need to make sure it works with `gpg`.
However we are presented with a couple issues, as explained in the following parts.

<Aside type="tip">

In case we use an _X session_, it might be smart to tell `gpg` what TTY we're on
by simply adding the following lines to the `.bashrc`
by simply adding the following lines to the appropriate init file

<Tabs syncKey="shell">

<TabItem label="Xonsh">

```py title=~/.config/xonsh/user.xsh ins={1-2}
$GPG_TTY = $(tty)
gpg-connect-agent updatestartuptty /bye >/dev/null
```

</TabItem>

<TabItem label="Nushell">

```bash title=~/.bashrc ins={1-2}
export GPG_TTY=$(tty)
gpg-connect-agent updatestartuptty /bye >/dev/null
```

</TabItem>

</Tabs>

</Aside>

<Aside type="caution" title="Wrong permissions">

Unfortunately, `dotter` doesn't seem to set up the permissions correctly.
This is an issue and `gpg` will gladly and loudly complain about it.

To fix it

<Steps>

1. Make sure you are indeed the owner of `~/.gnupg`.

2. After that simply correct the wrong permissions

```sh
chmod 700 ~/.gnupg
chmod 600 ~/.gnupg/gpg.conf
chmod 600 ~/.gnupg/gpg-agent.conf
chmod 600 ~/.gnupg/sshcontrol
```

</Steps>

</Aside>
16 changes: 0 additions & 16 deletions src/content/docs/home/Smartcard/GnuPG/permission.mdx

This file was deleted.

32 changes: 29 additions & 3 deletions src/content/docs/home/Smartcard/GnuPG/ssh.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,48 @@
title: SSH
---

import { Aside, Card, Steps } from "@astrojs/starlight/components";
import {
Aside,
Card,
Steps,
Tabs,
TabItem,
} from "@astrojs/starlight/components";

As I'm almost exclusively using `gpg-agent` for SSH (except some cases where I use FIDO2 and resident keys),
as a substitute for `ssh-agent`, I have to set it up, so other applications can connect to it.

For that we mainly have to `unset` `SSH_AGENT_PID` and `set` `SSH_AUTH_SOCK`.
This is best done in our `~/.bashrc`
This is best done in our appropriate init file

```sh title=~/.bashrc ins={1,3-5}
<Tabs syncKey="shell">

<TabItem label="Xonsh">

```python title=~/.config/xonsh/user.xsh ins={1-2,4-5}
if "SSH_AGENT_PID" in ${...}:
del $SSH_AGENT_PID

if ($gnupg_SSH_AUTH_SOCK_by if "gnupg_SSH_AUTH_SOCK_by" in ${...} else 0) != os.getpid():
$SSH_AUTH_SOCK = $(gpgconf --list-dirs agent-ssh-socket)
```

</TabItem>

<TabItem label="Nushell">

```bash title=~/.bashrc ins={1,3-5}
unset SSH_AGENT_PID

if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
```

</TabItem>

</Tabs>

<Aside type="tip">

As we want to use `git` over `ssh` in a second anyway, we can test if everything worked by trying to connect to GitHub
Expand Down
74 changes: 49 additions & 25 deletions src/content/docs/home/editor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Editor
---

import { Aside, Card, CardGrid } from "@astrojs/starlight/components";
import { Aside, Card, CardGrid, LinkCard } from "@astrojs/starlight/components";

<CardGrid>
<Card title="Required" icon="puzzle">
Expand All @@ -11,11 +11,11 @@ import { Aside, Card, CardGrid } from "@astrojs/starlight/components";
[wget](https://archlinux.org/packages/extra/x86_64/wget/)
[fd](https://archlinux.org/packages/extra/x86_64/fd/)
[ripgrep](https://archlinux.org/packages/extra/x86_64/ripgrep/)
[nodejs](https://archlinux.org/packages/extra/x86_64/nodejs/)
[npm](https://archlinux.org/packages/extra/x86_64/npm/)
[python](https://archlinux.org/packages/core/x86_64/python/)
[python-neovim](https://archlinux.org/packages/extra/any/python-pynvim/)
[python-pip](https://archlinux.org/packages/extra/any/python-pip/)
[python-neovim](https://archlinux.org/packages/extra/any/python-pynvim/)
[nodejs](https://archlinux.org/packages/extra/x86_64/nodejs/)
[npm](https://archlinux.org/packages/extra/x86_64/npm/)

</Card>
<Card title="Optional" icon="puzzle">
Expand Down Expand Up @@ -49,6 +49,45 @@ It is always a good idea to have
but with my Neovim config it's even more important,
as [Telescope](https://github.com/nvim-telescope/telescope.nvim) and other plugins make heavy use of them.

## Additional tools

<CardGrid stagger="true">

<LinkCard
title="NodeJS"
href="ref/lang/nodejs"
description="Some LSPs require node. Installing it now will make sure WSL doesn't pick up a Windows node/npm executable."
/>

<LinkCard
title="Python"
href="ref/lang/python"
description="Some plugins require Python 3, so we're also going to install that."
/>

<LinkCard
title="Lua"
href="ref/lang/lua"
description="If we want to edit the Neovim config, we also need tools for Lua, namely `luarocks`."
/>

<Card title="Tree-sitter">

As my Neovim config also includes [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) support,
you need to have some kind of C/C++ compiler available.
Normally Arch Linux on WSL2 should come with `gcc`.
The `tree-sitter` binary isn't required normally, but it's nice to have available just in case.

</Card>

<Card title="lazyjj">

As I use `jj`, I also want to install `lazyjj`, as it provides some integration for AstroNvim.

</Card>

</CardGrid>

## Clipboard integration

For Neovim's clipboard integration, you kind of have to decide whether or not you want native clipboard integration with Wayland/X11.
Expand Down Expand Up @@ -78,27 +117,12 @@ as Neovim checks for wl-clipboard first anyway (see `:help clipboard`).
</Card>
</CardGrid>

## Tree-sitter
<Aside type="caution">

As my Neovim config also includes [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) support,
you need to have some kind of C/C++ compiler available.
Normally Arch Linux on WSL2 should come with `gcc`.
The `tree-sitter` binary isn't required normally, but it's nice to have available just in case.

## NodeJS

Also some LSPs, require `node` and `npm` for installing the language servers.
By installing them now, before opening neovim, we make sure it doesn't accidentally pick up any Windows `npm`.
Trust me, you'll never get back the day you spent troubleshooting some weird LSP errors due to `npm` not being WSL-native.

## Python

Some plugins require Python 3, so we're also going to install that.
If you follow the steps for **Xonsh** in the next chapter, you might choose to remove the Windows `PATH` from Xonsh's `$PATH`.

## Lua
This causes you to loose access to the `win32yank.exe` executable, as well as `clip.exe` used by Xonsh's `prompt-toolkit`.
You will therefore either need to use WezTerm from within WSL, together with the native option above,
or manually add the aforementioned executables to Xonsh's `$PATH`.

If we want to edit the Neovim config, we also need tools for Lua, namely `luarocks`.

## Lazyjj

As I use `jj`, I also want to install `lazyjj`, as it provides some integration for AstroNvim.
</Aside>
1 change: 1 addition & 0 deletions src/content/docs/home/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ needed to actually be able to use WSL.
<Aside>

Note that some sections in the following chapters are seperated into a _Xonsh_ and _Nushell_ tab.
Select the one corresponding to the shell you wanna use.

<Tabs syncKey="shell">
<TabItem label="Xonsh">
Expand Down
Loading

0 comments on commit bce541f

Please sign in to comment.