Skip to content

Latest commit

 

History

History
160 lines (142 loc) · 7.11 KB

notes.org

File metadata and controls

160 lines (142 loc) · 7.11 KB

Using QMK

To use QMK, I just clone my fork:

# Initialize repo
cd
git clone git@github.com:LilleAila/qmk_firmware
cd qmk_firmware
direnv allow
# git submodule init # below does this for you
qmk setup
# Set up remotes
git remote add upstream https://github.com/qmk/qmk_firmware.git
# Rebase from upstream
git fetch upstream
git checkout master
git merge upstream/master
git push origin master
# Compile keymap
qmk compile -kb beekeeb/piantor_pro -km default
# Alternatively, flash directly
qmk flash -kb beekeeb/piantor_pro -km default

factorio as global install (might complain about arm, idk)

Factorio is currently downloaded manually as an executable from factorio.com and run directly from an fhsenv. Now that I have “inline” secrets set up, maybe I can switch to downloading it from nixpkgs (this will also mean that i have to edit syncthing to reflect the new config directory path)

add some documentation to the repo

  1. Some screenshots of the configuration
  2. File structure
  3. Secrets: setting up the keys before building, and the syntax of secrets files (private repo, gpg key etc.)

add ssh private and public keys to the SOPS secrets

Place them in the correct location using the path value, and set the owner as the correct user. https://discourse.nixos.org/t/gpg-ssh-key-pairs-management/28604/4

File encryption

I am currently using sops-nix in combination with a private nix flake hosted on GitHub. This works, but I should maybe look into setting up GPG to encrypt some files using git-crypt, and also signing git commits. Also see this

Flakegen

The flake.nix uses some nix expressions, which means that it can not be evaluated normally. To fix this, I used flakegen. This means that I have to edit flake.in.nix instead of flake.nix, and run nix run .#genflake flake.nix (aliased to update-inputs) after changing something. Omitting the flake.nix argument will preview the file without writing it.

Initializing

When initializing flakegen, i did:

mv flake.nix flake.in.nix
cp flake.lock flake.lock.old
nix flake init -t github:jorsn/flakegen
nix run .#genflake flake.nix
rm flake.lock
mv flake.lock.old flake.lock
nix run .#genflake flake.nix

Legion Y540

Model: Y540-15irh

BIOS keys:

  • Enter BIOS settings: F2
  • Boot menu: F12

Using the nix repl:

nix repl
:l <nixpkgs>
:? # get help
:e lib.mkEnableOption # see source
:q # quit

Nix flakes

A new project can be created using one of the available templates (completion with tab). Example with rust:

mkdir new-project
cd new-project
nix flake init --template templates#rust
cargo init .
git add -A && git commit -m "Initial commit"
nvim flake.nix # Add rust-analyzer and start coding

I have also created a few of my own templates, located at https://github.com/LilleAila/flake-templates

SSH

Generate a new key:

ssh-keygen -t ed25519 -C "your_email@example.com note"

SSH-ing into a server can often result in errors because kitty terminfo files are unavailable. To fix this, run kitten ssh instead of ssh.

SOPS

This config needs SOPS to work! If it is not configured properly, the user will not have a password!

# Generate age key:
nix shell nixpkgs#age -c age-keygen -o ~/.config/sops/age/keys.txt # Random
## From SSH key: (I used the SSH key from `m1pro14`)
nix run nixpkgs#ssh-to-age -- -private-key -i ~/.ssh/id_ed25519 > ~/.config/sops/age/keys.txt

# Get the public key:
nix shell nixpkgs#age -c age-keygen -y ~/.config/sops/age/keys.txt

The private key file should be at ~/.config/sops/age/keys.txt.

Creating writable files

Some programe may need a writable file for some reasom. This is probably one of the worst ways of doing it with a lot of downsides:

Writable only

Changes to the file are ignored when rebuilding

home.file."test_hm.txt" = {
 text = ''
    abd
    def
    ghi
    jkl
    1234567890
  '';
  onChange = ''
    rm -f $HOME/test.txt
    cp $HOME/test_hm.txt $HOME/test.txt
    chmod u+w $HOME/test.txt
  '';
};

Symlinked file

When edited, changes are reflected in the source flake.

home.activation.symlinkCustomFiles = lib.hm.dag.entryAfter ["writeBoundary"] ''
  run rm -f $HOME/testFile.txt && ln -s $HOME/dotfiles/home/testFile.txt $HOME/testFile.txt
'';

(pls don’t actually use this)

Configure devenv to use instead of manual devshells

Devenv

Virtual Machines

Basic setup steps

  • Enable virtualisation stuff in nixOS
  • Use lspci -nnk to find ids of hardware to pass through
  • Make the virtual machine
    • Configure the VM before installation (CPU to host-passthrough and use EFI)
    • Follow the steps described in the looking glass install guide.
      • First, install the host and other tools in windows with the default VM config
      • Set video type to none and pass through the GPU, a mouse and a keyboard with “add hardware”
      • After booting the VM, plug in a second monitor to install the GPU drivers (it might be possible to do this before removing video drivers, so that an external monitor is not needed)
      • Follow the remaining configuration steps from looking glass. Remember to keep spice enabled, but with video type as none!
      • Set up a virtual display so that it works without a monitor plugged in (also possible to do earlier)
      • For me, windows only detected a single one of the 6 cpu cores passed through. The solution was to check “Manually set CPU topology”, with 1 socket, 6 cores and 2 threads
        • The threads refer to threads per core, and according to lscpu my cpu has 2 threads per core.
    • Use the ctt windows utility to install other stuff
      • Open administrator command prompt
      • iwr -useb https://christitus.com/win | iex
    • Do these things (TODO for next vm, virtio drive or passthrough external drive)

Other resources I used: