8000 GitHub - DArtagan/dotfiles: Collection of my config files and such · GitHub
[go: up one dir, main page]

Skip to content
DArtaganPublic

About

Collection of my config files and such

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

665 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dotfiles & system configuration

Nix

Nix configuration is using this approach as its spirit guide: https://github.com/Baitinq/nixos-config

Update the system

One should first make sure all changes are committed to the repo.

nix flake update
sudo nixos-rebuild switch --flake .

Binary caches

Substituters are set in configuration.nix (nix.settings). Nix tries them in priority order:

Cache Priority Purpose
https://cache.nixos.org 40 Upstream.
http://mini-nas.forge.local:8770/public 41 Attic on mini-nas. mini-nas, thenixbeast and steamdeck push everything they build here (modules/attic-push). Paths expire 6 months after last access (server default).
http://mini-nas.forge.local:8770/archive 50 Attic on mini-nas, garbage collection disabled (retention 0). For store paths that must never disappear, such as sources whose upstream was withdrawn.

Pushing a host's builds to public

Hosts that import modules/attic-push queue each build from a post-build-hook, and a daemon pushes it, retrying for an hour if mini-nas is unreachable. Check it with journalctl -u queued-build-hook. mini-nas does the same, and mints its own token at boot.

The other hosts share one token, in modules/attic-push/secrets.yaml. Attic can't revoke a single token, only rotate the key that signs them all, so per-host tokens would buy nothing. To create or replace it:

  1. On mini-nas: sudo atticd-atticadm make-token --sub workstations --validity 99y --pull public --push public
  2. sops modules/attic-push/secrets.yaml, and set attic: { push_token: <token> }.

archive: keeping a package whose source vanished

If upstream deletes its source, a package can still build as long as its fixed-output paths (the src, plus things like cargoDeps/npmDeps) can be substituted by hash. Keep the old hash/cargoHash, and make sure those paths live in archive. Current contents:

  • qbz 2.0.2 (pkgs/qbz, removed from nixpkgs 2026-09-18 after the author withdrew it): /nix/store/2jfmb3dj1l1sc7pf6gca0vsczdkrikpi-source, /nix/store/ww0rw91wr6cgyjcpzg3zwr0vz8xikh30-qbz-2.0.2-vendor
    • Built output, with its full closure (pushed with --ignore-upstream-cache-filter), so a known-good build survives even if a later nixpkgs breaks the build. Built 2026-10-02 against nixpkgs c59305b; it needs ~40 GB of RAM + swap to compile (see pkgs/qbz): /nix/store/9qhhlswxz79vfcgjnprjj09nacl4gwv5-qbz-2.0.2

To add paths (Attic server config lives in the mini-nas repo, modules/attic):

  1. Make sure the paths are local: nix-store --realise <path>... (they're usually still on cache.nixos.org).
  2. You need a token with push access to archive. The everyday mini-nas token in ~/.config/attic/config.toml can't do this. Mint a short-lived one on mini-nas and log in under a separate name:
    sudo atticd-atticadm make-token --sub will --validity 1d --push archive --pull archive
    attic login mini-nas-admin http://mini-nas.forge.local:8770 <token>
  3. Push. --ignore-upstream-cache-filter is required: the cache lists cache.nixos.org-1 as upstream, so without the flag Attic silently skips anything cache.nixos.org has signed.
    attic push --ignore-upstream-cache-filter mini-nas-admin:archive <path>...
  4. Verify: nix path-info --sigs --store http://mini-nas.forge.local:8770/archive <path>... should list each path with an archive: signature.
  5. Record the paths in the list above, then remove the [servers.mini-nas-admin] block from ~/.config/attic/config.toml.

If a push fails:

  • Times out after about 30 s, and atticd logs Connection pool timed out: SQLite has no query statistics. It picks idx-chunk-state-holders instead of idx-chunk-chunk-hash, and every chunk lookup scans about 1.5M rows. Fix it on mini-nas: stop atticd, sqlite3 /var/lib/private/atticd/server.db console run ANALYZE;, then start atticd again. First fixed 2026-09-21.
  • Fails with a fast 500, and atticd logs database is locked, right after atticd restarts: atticd runs a GC pass on startup that holds the write lock. Wait until server.db-wal stops growing, then retry.

The cache was created with attic cache create …:archive --public and attic cache configure …:archive --priority 50 --retention-period 0s. Its public key, archive:1X1f2tklkN82QbeLjMYnySG9zhP+fWJsBSjK9Y6tPrY=, is in trusted-public-keys.

Generate NixOS iso

https://nixos.wiki/wiki/Creating_a_NixOS_live_CD

  1. The configuration is already in flake.nix
  2. nix build .#nixosConfigurations.iso.config.system.build.isoImage
  3. The resulting image can be found in result/iso/
  4. Write to the USB drive (assuming /dev/sdb in this example - double check!): sudo dd if=results/iso/<distro_name>.iso of=/dev/<sdb> status=progress

thenixbeast partition set-up

Reference: https://wiki.nixos.org/wiki/ZFS

  1. Create a NixOS liveUSB (instructions above)
  2. Generate a host SSH key:
TEMP_SSH=$(mktemp -d)
install -d -m755 "$TEMP_SSH/etc/ssh"
ssh-keygen -t ed25519 -N "" -f "$TEMP_SSH/etc/ssh/ssh_host_ed25519_key"
chmod 600 "$TEMP_SSH/etc/ssh/ssh_host_ed25519_key"
  1. cat $TEMP_SSH/etc/ssh/ssh_host_ed25519_key.pub and add that value to the .sops.yaml in this repo, constrain it to only caring about its own host secrets file, plus the shared ones under "Adding a host to the build network" below.
  2. sops updatekeys for the file/host you'll be deploying to.
  3. Optionally, do steps similar to the ones above - creating user SSH keys to be deployed onto the machine. Update the corresponding host secrets file with those keys, so they're deployed. Also add new entries for them to the .sops.yaml because ideally the user can edit all other secrets files.
TEMP_USER_SSH=$(mktemp -d)
ssh-keygen -t ed25519 -f "$TEMP_USER_SSH/id_ed25519"
  1. Boot the target machine using the liveUSB.
  2. Change to root: sudo su
  3. Set a password: passwd
  4. Note the target machine's ip address: ip addr
  5. From a remote machine, SSH into the target machine, for running the following steps.
  6. sudo gdisk /dev/nvme0n1
  7. We'll need a boot partition (ESP), a swap partition, and a large partition for NixOS (the type will be "8300" "Linux filesystem"). (Presuming that the boot and swap partitions have already been set up.)
  8. Get the device IDs (ls /dev/disk/by-id/) and set them as variables like:
BOOT=/dev/disk/by-id/nvme-Samsung_SSD_990_PRO_4TB_S7KGNJ0X145827A-part1
SWAP=/dev/disk/by-id/nvme-Samsung_SSD_990_PRO_4TB_S7KGNJ0X145827A-part7
DISK=/dev/disk/by-id/nvme-Samsung_SSD_990_PRO_4TB_S7KGNJ0X145827A-part8
  1. Create the pool: zpool create -o ashift=9 -o autotrim=on -O compression=zstd-9 -O mountpoint=none -O canmount=off -O xattr=sa -O acltype=posix -O dnodesize=auto -O atime=off -O normalization=formD rpool $DISK
  • This SSD claims (sudo fdisk -l) 512 bytes as its ideal sector size, so going with ashift=9, even though 12 is the typical recommendation and often even 13 for SSDs.
  • compression=zstd-9 7FAC : probably too much. on/lz4 is a no-brainer. zstd-3 is the default. Cranking up the compression ratio this high might bottleneck on the CPU, rather than bottle-necking on reading off the NVME SSD.
  • dnodesize=auto
  • atime=off: disable writing the "access time" for every file read.
  • normalization=formD: something about using UTF-8 for filenames, and using the formD algorithm for comparison - which seems vaguely broadly compatible.
  1. Create filesystems:
zfs create -o canmount=noauto rpool/root
zfs create rpool/home
zfs create rpool/nix
zfs create rpool/var
  1. Mount those filesystems:
mount -o X-mount.mkdir -o zfsutil -t zfs rpool/root /mnt
mount -o X-mount.mkdir -o zfsutil -t zfs rpool/home /mnt/home
mount -o X-mount.mkdir -o zfsutil -t zfs rpool/nix /mnt/nix
mount -o X-mount.mkdir -o zfsutil -t zfs rpool/var /mnt/var
mount -o X-mount.mkdir $BOOT /mnt/boot
swapon $SWAP
  1. Deploy. In a separate terminal, on the remote machine run (notice the TEMP_SSH, using the value from step #2 above):
nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-facter ./hosts/thenixbeast/facter.json --extra-files "$TEMP_SSH" --phases kexec,install,reboot --flake .#thenixbeast --target-host root@<ip address>

Adding a host to the build network

After the host's SSH key is in .sops.yaml (step 3 above):

  1. If it will push to the cache or send builds, add its key to the modules/(attic-push|distributed_builders)/secrets.yaml rule in .sops.yaml, then sops updatekeys modules/attic-push/secrets.yaml modules/distributed_builders/secrets.yaml. That's all it needs for the cache: there's no token to mint.
  2. Add its host key to programs.ssh.knownHosts in modules/distributed_builders, and to the mini-nas repo's copy.
  3. In flake.nix, import ./modules/attic-push to push its builds, and ./modules/distributed_builders to set my.distributedBuilders.builders (only hosts faster than it) or acceptBuilds. A host that accepts builds also needs an entry in that module's machines, sized as described there.
  4. Set cores and max-jobs in its hosts/<host>/default.nix so that max-jobs * cores is twice its threads, as on the other hosts.
  5. In the mini-nas repo, add it to the build dotfiles … line in modules/nightly_config_builder, so the cache is warm for it.

tailscale

Once tailscale is installed and running on your system, join the network by:

  1. Run tailscale up --login-server=https://headscale.immortalkeep.com
  2. Via a connection to the headscale server, run the command it gives you to register the node. In this case, we're going to do so using kubectl: a. Find/confirm which username to register the node under: kubectl exec -n apps headscale-abcdef-0123 -- headscale users list b. kubectl exec -n apps headscale-abcdef-0123 -- headscale nodes register --user {username_from_above} --key mkey:0123456789abcdef...
  3. You may also want to rename the node in headscale: a. Get the numeric ID of the node: kubectl exec -n apps headscale-abcdef-0123 -- headscale nodes list b. Using the numeric ID as the index, give the node a new name: headscale nodes rename -i 7 new-name

Wifi

  1. List network interfaces: nmcli device
  2. List nearby networks: nm device wifi list
  3. Connect: nm device wifi connect {network_name} --ask
  4. Disconnect: nm device disconnect {wifi_interface_name}

Other dotfiles

There are non-nix-related top level directories in the repo. These are my old dotfiles, that I used to instantiate on a machine using stow which would smoothly create symlinks between the ~/.config folder and these folders - making it easy for me to keep this repo up to date and deploy new stuff. Now though, I've mostly moved over to using Nix and I'll remove old dotfile directories if it seems I'm never going to use them again.

Deprecated dotfiles:

  • chunkwm: project is no longer developed. Move to yabai instead.
  • fish: configuration moved to home.nix, now ceasing to maintain the fish directory.
  • sway: configuration moved to modules/sway/default.nix. I've ceased to maintain the sway dotfiles independently, because I can't imagine setting up a new desktop environment and not using nix to do it.
  • termite: terminal deprecated. Author recommends using alacritty instead.
  • terminator: abandoned by the original devs and then picked up again by new enthusiasts. For me though, alacritty + tmux is cleaner.
  • urxvt: hopefully I never need return to the X window system. alacritty + tmux otherwise preferred.
  • zsh: ceasing to maintain the configuration files. fish has all the shell niceness, batteries included.

About

Collection of my config files and such

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

0