Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/noib3/dotfiles

:house: Procrastinating never felt this productive
https://github.com/noib3/dotfiles

dotfiles home-manager neovim-dotfiles neovim-setup nix-dotfiles nixos ricing unixporn

Last synced: 6 days ago
JSON representation

:house: Procrastinating never felt this productive

Awesome Lists containing this project

README

        

# `/machines/blade`

Configuration deployed on a 15" 2021 Razer Blade running NixOS.

## Bootstrapping process

### Preliminaries

Every command that follows has to be run either as the root user or with
`sudo`.

### Partitioning

Find the name of the disk you want to install NixOS on with `fdisk -l`.
Assuming that disk is `/dev/sda`, create a GPT partition table (you can ignore
`parted`'s message about needing to update /etc/fstab)
```
parted /dev/sda -- mklabel gpt
```
Create the root partition
```
parted /dev/sda -- mkpart primary 512MiB -8GiB
```
next, create a swap partition (8GB should be plenty enough for a machine with
16GB of RAM. Also, ignore warnings about partitions not being properly aligned
for best performance):
```
parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
```
finally, the boot partition. NixOS uses the ESP (EFI partition table) by
default as its /boot partition
```
parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB
parted /dev/sda -- set 3 esp on
```

### Formatting

```
mkfs.ext4 -L nixos /dev/sda1
mkswap -L swap /dev/sda2
mkfs.fat -F 32 -n boot /dev/sda3
```

### Mounting

(this needs to be modified: `configuration.nix` should be cloned from this
repo, not edited manually)
```
mount /dev/disk/by-label/nixos /mnt
mkdir -p /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot
nixos-generate-config --root /mnt
vim /mnt/etc/nixos/configuration.nix
nixos-install
```
set a password for the root user, then `reboot`.

### Adding channels

```
nix-channel --add https://nixos.org/channels/nixos-20.09 nixos
nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable
nix-channel --add https://github.com/nix-community/home-manager/archive/release-20.09.tar.gz home-manager
nix-channel --update
sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable
sudo nix-channel --update
```
`exit` and log back in to install home-manager:
```
nix-shell '' -A install
```

### `home-manager switch`ing to this config

```
nix-env -iA nixos.git
cd ~
git clone https://github.com/noib3/dotfiles.git
nix-env -e git-minimal
mkdir -p ~/.config/nixpkgs
ln -sf ~/dotfiles/* ~/.config/nixpkgs/
ln -sf ~/.config/nixpkgs/machines/blade/home.nix ~/.config/nixpkgs/home.nix
home-manager switch
rm ~/.bash-history
```

### Remapping keys at the hardware level

The following information is largely taken from
[this](https://wiki.archlinux.org/index.php/Map_scancodes_to_keycodes) ArchWiki
post and [this](https://unix.stackexchange.com/a/170357/368116) stackexchange
answer.

First, find the scancode of the keys that need to be remapped. This can be done
with `sudo evtest` in a linux console (it won't work in a terminal emulator
inside an X session. Use `ctrl-alt-1` to switch to tty1). Once you start typing
you will see something like:
```
Event: time

To swap the keycodes of the two keys we first need to find the device ID of the
keyboard. This can be done with `sudo evemu-describe`, selecting the device
number from the list and looking for a line starting with `# Input device ID`.
In my case I had
```
# Input device ID: bus 0x03 vendor 0x1532 product 0x26f version 0x111
```
Once we have the scancodes, the keycodes and the keyboard's device ID we can
edit our `/etc/nixos/configuration.nix` by adding
```
services.udev = {
extraHwdb = ''
evdev:input:b0003v1532p026F*
KEYBOARD_KEY_700e2=leftmeta
KEYBOARD_KEY_700e3=leftalt
'';
};
```
it should be fairly obvious how to map the info we have into the expected
format:
```
evdev:input:bvp*
KEYBOARD_KEY_=
```
in particular ``, `` and `` are all 4 digits uppercase
hex values (adding some leading zeros if necessary), and `` is the
lowercase version of the one returned by `evtest`, stripped of the initial
`KEY_` part (i.e. `| sed 's/KEY_\(.*\)/\L\1/'`).

After a `nixos-rebuild switch` (and maybe a reboot) the two keys should have
swapped.