CCE

Arroyo Nix Support

Contents

This document collects some support that is shared between Arroyo NixOS Generator and Arroyo Home Manager. It sets up the nixpkgs overlay, the injection of a custom Nix packages in to the Arroyo systems' nixpkgs pkgs attrset, etc.

Making arroyo-nix an importable repository of my own packages

So Arroyo dumps the tangled Nix files in to ~/arroyo-nix/:

I have a handful of packages I want to export and include here. I have been trying to maintain a branch of nixpkgs containing my changes but it's been awfully difficult to keep it up to date and i haven't had the mental wherewithal to clean the changes up enough to merge in to nixpkgs.

nix:tangle ~/nix/default.nix:noweb yes
{ pkgs ? import <nixpkgs> {}, inputs ? (builtins.getFlake (toString ./.)).inputs }:
let
  callPackageInputs = pkgs.lib.callPackageWith (pkgs // { inherit inputs; });
in with pkgs;
rec {
  # The `lib`, `modules`, and `overlay` names are special
  lib = import ./lib { inherit pkgs; }; # functions
  # modules = import ./modules; # NixOS modules
  # overlays = import ./overlays; # nixpkgs overlays
  overlays = [
    (import ./overlay.nix)
  ];

  <<gen-pkg-overlays(rix-pkgs)>>

  # opencode is wired explicitly rather than via the rix-pkgs table because
  # it must be called with bun = bun-baseline (no-AVX2 build) for the
  # langlemangler MicroVM. See [[id:20260720T070200.000000][opencode / bun-baseline wiring]].
  opencode = callPackageInputs pkgs.opencode.override { bun = bun-baseline; };

  drawingbot-premium = (drawingbot-free.override {
    name = "drawingbotv3-premium";
  }).overrideAttrs (old: old // {
    src = ./files/DrawingBotV3-Premium-1.6.25-stable-linux-x86-64.deb;
    meta.license = pkgs.lib.licenses.unfree;
  });

  # plasma5Packages = let
  #   p5pcc = pkgs.plasma5Packages.overrideScope (pFinal: pPrev: rec {
  #     stdenv = pkgs.ccacheStdenv;
  #   });
  # in
  #   pkgs.plasma5Packages.overrideScope (plasmaFinal: plasmaPrev: rec {
  #     kwin = p5pcc.kwin.overrideAttrs (old: {
  #       src = /home/rrix/Code/kwin;
  #     });
  #   });
  karousel = plasma5Packages.callPackage ./pkgs/karousel.nix { inherit inputs; };
  karess = plasma5Packages.callPackage ./pkgs/karess.nix { inherit inputs; };
  kwin-effects-forceblur = kdePackages.callPackage ./pkgs/kwin-effects-forceblur.nix { inherit inputs; };
} // {
  <<gen-pkg-overlays(wrapWine-pkgs)>>
} // (with python3Packages; rec {
  <<gen-python-overlays(python-pkgs)>>

  inaturalist-to-sqlite = toPythonModule (callPackage ./pkgs/inaturalist-to-sqlite.nix { inherit inputs; });
  twitter-to-sqlite = toPythonModule (callPackage ./pkgs/twitter-to-sqlite.nix { inherit inputs; });
  jisho-api = toPythonModule (callPackage ./pkgs/jisho-api.nix { inherit inputs; });
  beetcamp = toPythonApplication (callPackage ./pkgs/beetcamp.nix { inherit inputs; });
  bandcamp-dl = toPythonApplication (callPackage ./pkgs/bandcamp-dl.nix { inherit inputs; });

  vpypePackages = callPackage ./pkgs/vpype/default.nix {
    inherit pnoise;
    inherit svgelements;
    inherit watchfiles;
    inherit hnswlib;
  };
  vpype = vpypePackages.vpype;
  vsketch = vpypePackages.vsketch;
})
NixGL nixGL ./pkgs/nixgl.nix
Arroyo customized Emacs package myEmacs ./pkgs/emacs.nix
Arroyo customized Emacs package arroyo-emacs ./pkgs/emacs.nix
cpmtools on NixOS cpmtools ./pkgs/cpmtools.nix
DrawingBot V3 on NixOS drawingbot-free ./pkgs/drawingbot.nix
Mopidy Bandcamp mopidy-bandcamp ./pkgs/mopidy-bandcamp.nix
RiverWM-ultitile river-ultitile ./pkgs/river-ultitile.nix
Wau for River Init wau ./pkgs/wau.nix
pi-web package pi-web ./pkgs/pi-web.nix
bun-baseline package bun-baseline ./pkgs/bun-baseline.nix
Cogmind cogmind ./pkgs/cogmind.nix
Caves of Qud cavesofqud ./pkgs/cavesofqud.nix
Sid Meier's Alpha Centauri smac ./pkgs/smac.nix
Google Earth Pro google-earth-pro ./pkgs/google-earth-pro.nix
Feediverse feediverse ./pkgs/feediverse.nix Module
Matrix Feedbot matrix-feedbot ./pkgs/feedbot.nix Module
Waydroid Passthrough Browser passthroughbrowser ./pkgs/passthroughbrowser.nix Module
vsketch and vpype deps pnoise ./pkgs/pnoise.nix Module
Meshtastic metrics exporter meshtastic-metrics-exporter ./pkgs/meshtastic-metrics-exporter.nix Application
Morph Command Wrapper morph-wrapper /home/rrix/org/morph-wrapper/default.nix Module
The Arcology Project arcology /home/rrix/org/arcology-django/default.nix Module

nixpkgs configuration needs to be passed in when the module is instantiated, doing it in your config isn't supported. This import is used as <arroyo/pkgs/nixpkgs.nix> by e.g. the Morph Command Wrapper, flakes will have to do this on their own still:

nix:tangle ~/nix/pkgs/nixpkgs.nix
{ ... }:

import <nixpkgs> {
	allowUnfree = true;
  permittedInsecurePackages = [
    "olm-3.2.16"
  ];
}

Literate Programming Helpers

These turn the tables above in to code embedded above that:

lua#+name: gen-pkg-overlays:eval arroyo:results raw:var tbl=wrapWine-pkgs
local lines = {}
for i, row in ipairs(tbl) do
    table.insert(lines, row[2] .. " = callPackageInputs " .. row[3] .. " {};")
end
return table.concat(lines, "\n")
lua#+name: gen-python-overlays:eval arroyo:results raw:var tbl=python-pkgs
local lines = {}
for i, row in ipairs(tbl) do
    local typeSuffix = row[4] or "Module"
    table.insert(lines, row[2] .. " = toPython" .. typeSuffix .. " (callPackage " .. row[3] .. " {});")
end
return table.concat(lines, "\n")

Arroyo Nix Library Helpers

Arroyo exposes some library helpers which i would like to not just bare-import:

nix:tangle ~/nix/lib/default.nix
{ pkgs }:

with pkgs.lib; {
  mkKwriteConfig5 = pkgs.callPackage ./kde-configs.nix {};
  mkNixGLWrapper = pkgs.callPackage ./nixgl.nix {};
  mkActivationLocalLink = pkgs.callPackage ./mk_activation_local_link.nix {};
  publicKeys = import ./public-keys.nix;
}

Arroyo NixOS loads this as an overlay

Arroyo-Nix could be used as an nixpkgs overlay, this exposes all the stuff in default.nix as a nixpkgs overlay, it's a little bit terrible to read and parse and explain it.

nix:tangle ~/nix/overlay.nix
{ inputs ? {} }:
self: super:
let
  isReserved = n: n == "lib" || n == "overlays" || n == "modules";
  nameValuePair = n: v: { name = n; value = v; };
  nurAttrs = import ./default.nix { pkgs = super; inherit inputs; };

  outAttrs = builtins.listToAttrs
  (map (n: nameValuePair n nurAttrs.${n})
    (builtins.filter (n: !isReserved n)
      (builtins.attrNames nurAttrs))) // {
        lib = (super.lib or {}) // (import ./lib/default.nix { pkgs = super; });
      };
in outAttrs

This is exported as the Arroyo System Flake default overlay:

nix:tangle ~/nix/snippets/rixpkgs-overlay.nix
overlays.default = final: prev: (import ./overlay.nix {}) final prev;

Which is included in the Arroyo System Flake as an nixpkgs overlay.

nix:tangle ~/nix/nixos/rixpkgs-overlay.nix:mkdirp yes
{ self, inputs, pkgs, ... }:

{
  nixpkgs.overlays = [
    (import ../overlay.nix { inherit inputs; })
  ];
}

NEXT figure all this out -- probably have flake generation as well here.

NEXT probably need an arroyo-db keyword to note which packages go in default.nix...

and probably one for lib... uagh.

NEXT extract packages from nixpkgs

DONE beets-bandcamp

NEXT libqtolm

NEXT libquotient

NEXT neochat with e2e