Arroyo can manage any number of NixOS hosts, though right now it seeks to only manage systems which are "endpoints" – a place the user may want to deploy their Arroyo configuration to.
Server and cluster management will be explored at some point in the future, but for now this is designed to build laptops and desktops which can be given a bare-bones NixOS install through my NixOS Automatic Partitioning Installer and attached to the same network as a machine running Arroyo or capable of running Morph on a set of Arroyo tangled files.
NixOS configuration.nix
Generator
This thing is pretty functionally similar to the Arroyo Home Manager generator and is
conceptually quite similar. It constructs a NixOS configuration.nix
-like which is suitable for
being deployed with Morph. That file
documents My Laptops and provides an
example of the system "in-flight."
"~/arroyo-nix/networks/laptops.nix" org-roam-directory)
(defcustom arroyo-nixos-network-path (expand-file-name "Location of Nix network definition suitable for Morphing"
'arroyo
:group :type 'string)
dolist (mod '("ARROYO_NIXOS_MODULE"
("ARROYO_NIXOS_ROLE"
"ARROYO_NIXOS_EXCLUDE"))
'arroyo-db-keywords mod nil #'equal))
(add-to-list
'arroyo-db--schemata
(add-to-list
'(nixos
[(file :not-null)
(nix-module :not-null) role]))
defun arroyo-nixos-update-db (&optional keywords-too)
("P")
(interactive when keywords-too
(
(arroyo-db-update-all-roam-files))if (org-roam-file-p)
(= file $s1)]
(arroyo-db-query [:delete :from nixos :where (
(buffer-file-name))
(arroyo-db-query [:delete :from nixos]))
(when-let* ((argsif (org-roam-file-p)
(list [:select [file value] :from keywords
(= keyword $s1) :and (= file $s2)]
:where ("ARROYO_NIXOS_MODULE"
(buffer-file-name))list [:select [file value] :from keywords
(= keyword $s1)]
:where ("ARROYO_NIXOS_MODULE")))
apply #'arroyo-db-query args))
(results (
(results (-map (pcase-lambda (`(,file ,value))list file value (arroyo-db-get "ARROYO_NIXOS_ROLE" file)))
(
results)))
(arroyo-db-query [:insert :into nixos :values $v1]lambda (result) (apply #'vector result))
(-map (
results))))
'arroyo-db-update-functions #'arroyo-nixos-update-db) (add-to-list
arroyo-home-manager-imports
returns a
list of strings suitable for import
'ing in
home-manager's
literate helpers.
defun arroyo-nixos-imports (&optional role)
(
(if-let* ((imports (arroyo-nixos-imports1))not role)))
(no-role? (#'car imports)
(-map progn
(let* ((all-files (-map #'cadr imports))
("ARROYO_NIXOS_ROLE" role))
(role-only-files (arroyo-db-by-keyword "ARROYO_NIXOS_EXCLUDE" role))
(exclude-these-files (arroyo-db-by-keyword ;; also need to exclude things whose ARROYO_NIXOS_ROLE is not `role'!
(not-my-role-files#'car
(-map
(arroyo-db-query [:select file :from nixos
:where (!= role $s1)]list role))))
(;; combine all those lists in to a single authoritative list.
(amalgamated-files
(-union role-only-files
(->> all-files
(--remove (-contains? exclude-these-files it))
(--remove (-contains? not-my-role-files it)))));; make them relative to org-roam-directory for the module orderer
(rel-files (--map (file-relative-name it org-roam-directory) amalgamated-files));; map the org path back to the tangled module
lambda (org-file)
(tangled-files (-map (car (arroyo-db-get "ARROYO_NIXOS_MODULE"
(
(expand-file-name org-file org-roam-directory))))
(arroyo-utils-order-modules rel-files))))#'identity tangled-files)))))
(-filter
defun arroyo-nixos-imports1 ()
(
(->> [:select [nix-module file] :from nixos] (arroyo-db-query)))
NEXT I should make this function which crates the tangled-files list a function in Arroyo System Cache
It's a very useful thing to say "just go figure out the DAG stuff for the files that are set up by -these- metadata keywords" – i already have a copy of this in Arroyo Home Manager that could be combined in to a better pattern, surely.
I need to generally be thinking about an "API" for arroyo, something that other folks could extend, rather than just accreting features forever.
Arroyo NixOS manages systems with Morph:
It goes in to Arroyo Home Manager but can be installed from GitHub to bootstrap the system.
{ pkgs, ... }:
{
home.packages = [ pkgs.morph ];
}
Flooding the Arroyo tangles and deploys all sub-systems
an interactive command which stitches together the arroyo system and
runs the morph
command which deploys the
system:
Click here to flood the Arroyo.
defun arroyo-nixos-full-spread (host &optional local-only switch-action)
("Flood the arroyo. Tangle all related files and run morph deploy.
DEP-FILE is a string pointing to a Morph network definition.
SWITCH-ACTION is one of the actions which morph deploy expects. Read its docs."
list (->> (shell-command-to-string "deploy-targets")
(interactive ("\n")
(s-split append '("--all"))
("Which host do you want to deploy to? "))))
(completing-read let ((switch-action (or switch-action "switch")))
(;; expand this to include CCE_NIXOS keywords eventually
"cce/home-manager.org" org-roam-directory))
(org-babel-tangle-file (expand-file-name "arroyo/arroyo-emacs.org" org-roam-directory))
(org-babel-tangle-file (expand-file-name
(arroyo-emacs-generate-init)format "deploy -a %s %s" switch-action host)
(async-shell-command ("*nix-deploy*")))
'arroyo-flood 'arroyo-nixos-full-spread) (defalias
provide 'arroyo-nixos) (