complete-computing-environment/nix-on-droid.org

169 lines
4.8 KiB
Org Mode

:PROPERTIES:
:ID: 20221106T113721.266425
:END:
#+title: CCE in Nix On Droid
#+ARCOLOGY_KEY: cce/nix-on-droid
#+ARCOLOGY_ALLOW_CRAWL: t
I'd like to get parts of my [[id:cce/cce][CCE]] running on [[id:20220817T205401.021191][t184256/nix-on-droid]] so that I can have my [[id:cce/emacs][Emacs]] [[id:a7420bb9-395f-4afa-92fb-8eaa0b8a4cd8][Tools]] like [[id:2e31b385-a003-4369-a136-c6b78c0917e1][SRS]] and [[id:cce/org-roam][org-roam]] running on it.
* =nix-on-droid.nix=
:PROPERTIES:
:ID: 20221107T121318.041740
:END:
This uses [[id:arroyo/home-manager][Arroyo Home Manager]] to generate a list of Arroyo modules to include in to the Nix On Droid home-manager environment and then does some basic housekeeping stuff to expose [[id:arroyo/emacs][Arroyo Emacs]] and [[id:20221021T121120.541960][rixpkgs]] to that environment.
#+begin_src nix :tangle ~/arroyo-nix/nix-on-droid.nix :noweb yes
{ pkgs, ... }:
{
environment.packages = with pkgs; [ vim openssh ];
system.stateVersion = "22.11";
nix.nixPath = [
"nixpkgs=/data/data/com.termux.nix/files/home/.nix-defexpr/channels/nixpkgs/"
"arroyo=/storage/emulated/0/arroyo-nix"
"/data/data/com.termux.nix/files/home/.nix-defexpr/channels"
];
nix.substituters = [
"https://cache.nixos.org/"
"https://nix-community.cachix.org"
];
nix.trustedPublicKeys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
nixpkgs.overlays = [
(let emacsOverlay = (import ./versions.nix {}).emacsOverlay null;
in import emacsOverlay)
(import <arroyo/overlay.nix>)
];
home-manager.useGlobalPkgs = true;
time.timeZone = "America/Los_Angeles";
home-manager.config =
{ pkgs, ... }:
{
home.stateVersion = "22.05";
imports = [
<<home_manager_imports()>>
];
programs.ssh.matchBlocks = {
virtuous-cassette = {
hostname = "100.96.6.32";
user = "builder";
identitiesOnly = true;
identityFile = "~/.ssh/id_rsa";
};
window-smoke = {
hostname = "100.79.48.59";
user = "builder";
identitiesOnly = true;
identityFile = "~/.ssh/id_rsa";
};
};
};
}
#+end_src
#+NAME: home_manager_imports
#+begin_src emacs-lisp
(->> (arroyo-home-manager-imports "droid")
(s-join "\n"))
#+end_src
#+results: home_manager_imports
#+begin_example
hm/contacts.nix
hm/deadgrep.nix
hm/direnv.nix
hm/emacs-helpers.nix
hm/emacs-pager.nix
hm/emacs.nix
hm/git.nix
hm/gnupg.nix
hm/morph.nix
hm/nix-update.nix
hm/org-fc.nix
hm/org-roam.nix
hm/profile.nix
hm/prompt.nix
hm/python.nix
hm/shell-helpers.nix
hm/spell-check.nix
hm/ssh_client.nix
#+end_example
* Using machines running [[id:cce/my_nixos_configuration][My NixOS configuration]] to as builders for nix-on-droid
Based on the [[https://github.com/t184256/nix-on-droid/wiki/Use-a-remote-builder-with-qemu][Nix On Droid wiki examples]]:
#+ARROYO_NIXOS_MODULE: nixos/nixos-builder.nix
#+ARROYO_SYSTEM_ROLE: endpoint
#+ARROYO_SYSTEM_ROLE: server
[[id:20211029T115928.954970][Virtuous Cassette]] is set up with a =builder= user and =aarch64= =binfmt= emulation:
#+begin_src nix :tangle ~/arroyo-nix/nixos/nixos-builder.nix
{ ... }:
{
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
users.users.builder = {
createHome = true;
isNormalUser = true;
initialPassword = "changeme!";
};
nix.settings.trusted-users = [ "builder" ];
}
#+end_src
* Bootstrapping the build setup
On the droid side, it's configured to use this as the builder and SSH to the host over [[id:20220811T124742.042180][Tailscale]]:
=nix.conf=:
#+begin_src conf
builders-use-substitutes = true
builders = ssh://virtuous-cassette;ssh://window-smoke
#+end_src
=.ssh/config=
#+begin_src conf
Host virtuous-cassette
HostName 100.96.6.32
User builder
IdentitiesOnly yes
IdentityFile ~/.ssh/id_rsa
Host window-smoke
HostName 100.79.48.59
User builder
IdentitiesOnly yes
IdentityFile ~/.ssh/id_rsa
#+end_src
- set up ssh: =nix-shell -p openssh git= then =ssh-keygen= then =ssh-copy-id builder=; git is used in =nix-on-droid build=
- set up directories: =ln -s /storage/emulated/0/org ~/org= then =ln -s /storage/emulated/0/arroyo-nix ~/arroyo-nix=
- [[https://nix-community.github.io/home-manager/index.html#sec-install-standalone][install]] home-manager channel (only used for bootstrap, subsequent builds will use [[id:cce/version_pins][Nix Version Pins]])
- then finally =nix-on-droid build -f ~/arroyo-nix/nix-on-droid.nix -I arroyo=$HOME/arroyo-nix=
Termux app properties should be set on the Cosmo and other devices with a hardware keyboard:
#+begin_src conf
# extra-keys-style = none doesn't work...
extra-keys = []
back-key = escape
ctrl-space-workaround = true
#+end_src