Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mirkolenz/nixos
Personal nix-based configuration for all my computers and servers
https://github.com/mirkolenz/nixos
dotfiles flake linux macos nix nixos nixos-configuration
Last synced: 3 months ago
JSON representation
Personal nix-based configuration for all my computers and servers
- Host: GitHub
- URL: https://github.com/mirkolenz/nixos
- Owner: mirkolenz
- Created: 2023-03-07T13:44:16.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T01:22:10.000Z (9 months ago)
- Last Synced: 2024-04-14T00:38:10.139Z (9 months ago)
- Topics: dotfiles, flake, linux, macos, nix, nixos, nixos-configuration
- Language: Nix
- Homepage:
- Size: 1.3 MB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NixOS Setup
All configurations select the correct device name through their hostname.
When setting up a new host, please run the following first:```shell
hostname MACHINE_NAME
```You may also change the hostname as follows:
```shell
nix run github:mirkolenz/nixos -- --hostname MACHINE_NAME
```## NixOS
### Graphical Setup
1. Install NixOS with provided ISO
2. Create config: `nixos-generate-config`
3. Migrate generated `/etc/nixos/configuration.nix` and `/etc/nixos/hardware-configuration.nix` to this flake manually
4. Eventually install git in a temporary shell: `nix shell nixpkgs#git````shell
# Large changes (like first time)
sudo nix run github:mirkolenz/nixos -- -o boot
# Small changes
sudo nix run github:mirkolenz/nixos
```### Terminal Setup
-
-
-#### Partitioning using `parted`
```shell
parted -l # find device name, most likely /dev/sda
wipefs -a /dev/sda
parted /dev/sda
mklabel gpt
mkpart boot fat32 0% 512MiB
set 1 esp on
unit GiB print free
# determine the swap size by substractting the amount of your ram from the free size
# for instance, free size here is 238GiB and the ram of the system is 8GiB
mkpart root ext4 512MiB 230GiB
mkpart swap linux-swap 230GiB 100%
```#### Partitioning using `fdisk`
One can also use the ncurses-based program `cfdisk`.
```shell
# Find out the device name, most likely /dev/sda
fdisk -l # or lsblk
wipefs -a /dev/sda
fdisk /dev/sda
g # empty gpt partition table
n # new partition
1 # partition number
2048 # first sector, default
+512M # last sector
t # change partition type
1 # partition number (if not already selected)
1 # efi partition type
n # new partition
2 # partition number
# first sector, default
-16G # last sector, size of swap (about the size of your ram)
n # new partition
3 # partition number
# first sector, default
# last sector, default
t # change partition type
3 # partition number
19 # linux swap
v # verify
w # write
```#### Formatting
```shell
mkfs.fat -F 32 -n boot /dev/sda1
mkfs.ext4 -L root /dev/sda2
mkswap -L swap /dev/sda3
```#### Mounting
```shell
mount /dev/disk/by-label/root /mnt
swapon /dev/disk/by-label/swap
mkdir -p /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot
```#### Installation
If you get an error like `too many open files` during `nixos-install`, try one of the following options:
- Execute `ulimit -n 65535` before installing to increase the number of open files for the current shell session
- Use `--max-jobs 2` to limit the number of parallel jobs (could also try with 1 max job)```shell
nixos-generate-config --root /mnt
cd /mnt/etc/nixos/
# Now verify that the hardware configuration of this flake is in sync with the generated `hardware-configuration.nix`
# The machine name is required for the nixos-install command, even if hostname is updated
nixos-install --flake github:mirkolenz/nixos#MACHINE_NAME
# One could append --no-root-passwd to the command, but that may affect the ability to enter emergency mode
```A warning about `/boot` being world-readable is not an issue, [the permissions are correctly set after a reboot](https://discourse.nixos.org/t/nixos-install-with-custom-flake-results-in-boot-being-world-accessible/34555).
### Troubleshooting
If getting an error like `Getting status of /nix/store/...: No such file or directory`, try the following
```shell
nix-store --verify --check-contents --repair
```### Tailscale
- Create auth key:
- SSH into the machine
- Save the auth key to `./tsauth.txt`
- Run `sudo tailscale up --auth-key file:tsauth.txt`
- Run `tailscale status` to verify the connection
- Remove the auth key file: `rm ./tsauth.txt`
- Approve exit-node/routes:## Mac Computers
### Installation
1. Install Apple Developer Tools: `xcode-select --install`
2. [Install Homebrew](https://brew.sh)
3. [Install Nix](https://github.com/DeterminateSystems/nix-installer)
4. Sign in to the App Store
5. Enable Full Disk Access for terminal application```shell
nix run github:mirkolenz/nixos
chsh -s /run/current-system/sw/bin/fish
sudo reboot
# Add ssh key to keychain
ssh-add --apple-use-keychain ~/.ssh/id_ed25519
```### Uninstallation
```shell
# TODO: Remove old nix-darwin/home-manager generations
chsh -s /bin/zsh
nix run github:lnl7/nix-darwin#darwin-uninstaller
/nix/nix-installer uninstall
```### Applications and Settings
System Preferences
- `General > About`: Set name
- `Wallpaper`: Solid color (black)
- `Appearance > Allow wallpaper tinting in windows`: Off
- `Keyboard > Keyboard Shortcuts > Modifier Keys`: Caps Lock -> Option
- `Keyboard > Keyboard Shortcuts > App Shortcuts`: Disable all
- `Keyboard > Keyboard Shortcuts > Spotlight`: Disable alliTerm2
- `Setting > General > Preferences > Load preferences from a custom folder or URL`: iCloud Drive
Raycast
- `Settings > Advanced > Import/Export` (also set up new schedule)
- `Settings > Account > Login`
- `Settings > Extensions > Scripts > Plus`: iCloud Drive
- `Launch > Manage Fallback Command`: Add KagiVisual Studio Code
- `Settings > Backup and Sync Setting > GitHub`
Rectangle
- `Settings > General > Sync over iCloud`
Zotero
- [Install Better BibTeX](https://github.com/retorquere/zotero-better-bibtex)
- `Settings > General > Customize Filename Format > {{ creators max="1" case="hyphen" }}-{{ year }}-{{ title truncate="50" case="hyphen" }}`
- `Settings General > Reader > Tabs > Creator - Title - Year`
- `Settings > Export > Item Format > Better BibTeX Citation Key Quick Copy`
- `Settings > Export > Note Format > Markdown + Rich Text`
- `Settings > Better BibTeX > Citation Key Format > auth.capitalize + year + shorttitle(3,3)`
- `Settings > Better BibTeX > Citation Key Format > Automatic Export > Delay > 10 seconds`Default Folder X
- `Settings > Options > Sync settings via iCloud`
iA Presenter
- Move theme to `$HOME/Library/Containers/net.ia.presenter/Data/Library/Application Support/iA Presenter/Themes`
Contexts
- `Sidebar > Show Sidebar on > No display`
- `Search > Search with > Disable`
- `Command-Tab > Command-Tab`: Show windows of all apps
- Minimized: Show at bottom
- Hidden: Show at bottom
- Apps without windows: Do not show
- `Command-Tab > Command-Backtick`: Show windows of active app
- Minimized: Do not show
- Hidden: Do not show
- Apps without windows: Do not showArq Backup
Additional wildcard exclude rules:
```txt
.venv
.direnv
.devenv
node_modules
*/OrbStack
*/.orbstack
*/Library/CloudStorage
*/Library/Application Support/
```## Home-Manger Standalone
_Note:_ Reconnect via SSH after installing nix.
```shell
sudo /nix/var/nix/profiles/default/bin/nix upgrade-nix
nix run github:mirkolenz/nixos#home
sudo usermod -s $(which fish) "$USER"
```## Utilities and Snippets
### NixOS Generators
- If building for another architecture on NixOS: [Enable cross compiling](https://github.com/nix-community/nixos-generators#cross-compiling)
- Available formats:
- `installer-iso`
- `installer-raspi````shell
nix build github:mirkolenz/nixos#FORMAT --system SYSTEM
```### Update Raspberry Pi
```shell
nix shell pkgs#raspberrypi-eeprom
sudo mount /dev/disk/by-label/FIRMWARE /mnt
sudo env BOOTFS=/mnt FIRMWARE_RELEASE_STATUS=default rpi-eeprom-update -d -a
sudo reboot
```### Use MakeMKV
```shell
# otherwise the optical drive is not found: https://discourse.nixos.org/t/makemkv-cant-find-my-usb-blu-ray-drive/23714
sudo modprobe sg
# if that does not work, try again with sudo
NIXPKGS_ALLOW_UNFREE=1 nix run pkgs#makemkv --impure
```### Investigate ID Mappings
```shell
sudo podman run --rm --subuidname=$USER ubuntu cat /proc/self/uid_map
```