complete-computing-environment/version_pins.org

454 lines
16 KiB
Org Mode

:PROPERTIES:
:ID: cce/version_pins
:ROAM_ALIASES: "Nix Version Pins"
:END:
#+TITLE: Keeping Nix Version Pins in One Place
#+ARCOLOGY_KEY: cce/nix-pins
#+ARCOLOGY_ALLOW_CRAWL: t
#+filetags: :Project:
#+AUTO_TANGLE: vars:org-babel-load-languages vars:load-path
[[id:c75d20e6-8888-4c5a-ac97-5997e2f1c711][NixOS]] is a big fan of reproduceability -- indeed that's what i'm using it for. But then I go read READMEs that say to do things like say "hey just download the code here from github's =master.tar.gz= and use it unconditionally". Nuh-uh, no can-do, bad idea. I'm going to maintain versions in a single Nix module which can be imported and used and updated when necessary.
To update this document:
- Call [[id:20220526T160150.431487][cce/update-nixpkgs-checkout]] to update nixpkgs and then possibly resolve merge conflicts myself.
- =M-o i= will call =nix-update-branch-revs= to fetch the latest revision for modules using =builtins.fetchGit=.[fn:1:This is required because I couldn't get =nix-update-decls= to update the revs of these without also populating a =sha256= key which will not be valid in a =builtins.fetchGit= invocation. Both [[id:nix_community_emacs_overlay][nix-community/emacs-overlay]] and [[id:cce/home-manager][home-manager]] are loaded in situations where there is no pre-existing [[id:c75d20e6-8888-4c5a-ac97-5997e2f1c711][nixpkgs]] to invoke, so they have to use this "impure" invocation.]
- =C-u M-o o= will call =nix-update-decls= to update the =rev= and =sha256= for the rest. Note the prefix argument which will force =nix-prefetch-git= to fetch the latest revisions of the default (or specified) branch.
To understand why/how read on:
* This document contains Magic
:PROPERTIES:
:ID: 20220913T142944.295536
:ROAM_ALIASES: "org-auto-tangle with babel functions"
:END:
To get the [[id:957de5e6-0cc3-43c6-a915-4506cfa005bd][org-auto-tangle]] to work with the document I have had to be quite careful in how I construct it. I would like to be able to update all the refs on the page at once, by an affirmative user-action. The process for updating this file involves using modifications I've made of jweigley's [[id:20220913T104837.013589][nix-update-el]] and is simple to operate:
There is some scaffolding and nuance required to make this work in the tangle stage.
First of all, =org-auto-tangle= is smart enough to not execute [[id:cce/literate_programming][Org Babel]] functions by default. It's imperative to customize [[help:org-auto-tangle-babel-safelist]].
Consider =nix-update-branch-revs=. These are fetched using this code block referenced in the document as =prefetch-git-rev=, evaluated, and the results inserted in to =versions.nix= using [[id:09779ac0-4d5f-40db-a340-49595c717e03][noweb syntax]]. If this was evaluated every time I saved the document, the version of home-manager and emacs-overlay which are imported would change every time I save!
#+NAME: prefetch-git-rev
#+begin_src emacs-lisp :var REPO="" :var BRANCH="main"
(require 's)
(s-chomp
(shell-command-to-string
(format "curl -s https://api.github.com/repos/%s/branches/%s | jq .commit.sha" REPO BRANCH)))
#+end_src
This =require='s things which aren't a part of Emacs by default, so I have to modify my =AUTO_TANGLE= document keyword with a [[https://github.com/yilkalargaw/org-auto-tangle/pull/22][new feature]] to pass variables in to the async Emacs invocation, thus =#+AUTO_TANGLE: vars:load-path=. This is, unfortunately, much slower to load and thus tangle now.
You'll note that this =prefetch-git-rev= is an elisp function, why not just use a shell-script? well, org doesn't load =ob-shell= by default, and passing =org-babel-load-languages= in to the async function was not enough to get it to work. oh well. Luckily I don't need anything too special here.
And so we are quite careful in how this document is constructed. Consider the home-manager example. If [[(NAME)]] were attached to the inline org-babel =CALL=, this would update every save. So the *results* have to be named. The [[(invocation)]] looks like a function call but will actually use the cached value.
#+begin_src org -r
,#+CALL: prefetch-git-rev(REPO="nix-community/home-manager", BRANCH="master")
,#+NAME: prefetch-hm (ref:NAME)
,#+results:
: "60c6bfe322944d04bb38e76b64effcbd01258824"
,#+begin_src nix :noweb-ref homeManager :noweb yes
homeManager = _: builtins.fetchGit {
url = "https://github.com/nix-community/home-manager.git";
rev =
<<prefetch-hm()>> (ref:invocation)
;
};
,#+end_src
#+end_src
By structuring these invocations like this it is possible to write a function contained in my [[id:20220913T104837.013589][nix-update]] page which will iterate over all the call sections and update the =builtins.fetchGit= entities, and then update the revisions and =sha256= of the rest of the document, and safely tangle the new values out on save. This is probably a useful pattern in developing [[id:128ab0e8-a1c7-48bf-9efe-0c23ce906a48][Hypermedia]] in org-mode.
* NEXT update my [[id:c75d20e6-8888-4c5a-ac97-5997e2f1c711][NixOS]] version pins and deploy
SCHEDULED: <2024-02-14 Wed .+2w>
:PROPERTIES:
:LAST_REPEAT: [2024-01-31 Wed 15:49]
:END:
:LOGBOOK:
- State "DONE" from "NEXT" [2024-01-31 Wed 15:49]
- State "DONE" from "NEXT" [2024-01-22 Mon 18:28]
CLOCK: [2024-01-22 Mon 10:24]--[2024-01-22 Mon 10:26] => 0:02
CLOCK: [2024-01-22 Mon 09:54]--[2024-01-22 Mon 10:19] => 0:25
- State "DONE" from "NEXT" [2023-11-29 Wed 17:11]
- State "DONE" from "NEXT" [2023-11-12 Sun 21:52]
- State "DONE" from "NEXT" [2023-09-08 Fri 18:42]
- State "DONE" from "NEXT" [2023-08-17 Thu 19:00]
- State "DONE" from "NEXT" [2023-07-27 Thu 15:37]
- State "DONE" from "INPROGRESS" [2023-06-20 Tue 08:07]
- State "INPROGRESS" from "NEXT" [2023-06-19 Mon 15:42]
- State "DONE" from "NEXT" [2023-05-29 Mon 12:54]
- State "DONE" from "NEXT" [2023-04-18 Tue 10:39]
- State "DONE" from "NEXT" [2023-03-29 Wed 10:33]
- State "DONE" from "NEXT" [2022-12-20 Tue 13:15]
CLOCK: [2022-12-20 Tue 10:26]--[2022-12-20 Tue 13:15] => 2:49
- State "DONE" from "NEXT" [2022-11-07 Mon 12:15]
- State "DONE" from "NEXT" [2022-09-28 Wed 15:59]
:END:
: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
#+begin_src nix :tangle ~/arroyo-nix/versions.nix :noweb yes
{ ... }:
{
<<homeManager>>
<<emacsOverlay>>
<<poetry2nix>>
<<nixpkgs>>
<<nixgl>>
<<mastodon>>
# org libraries
<<consult-org-roam>>
<<ox-rss>>
<<org-fc>>
<<delve>>
<<tabfs>>
<<cpmtools>>
<<tuhc>>
# pythons
<<beetcamp>>
<<bandcamp-dl>>
<<mopidy-bandcamp>>
<<jisho-api>>
<<twitter-to-sqlite>>
<<inaturalist-to-sqlite>>
<<ttrss>>
}
#+end_src
** Run [[elisp:(cce/update-nixpkgs-checkout)]] first
Right now I am running off a branch of [[id:c75d20e6-8888-4c5a-ac97-5997e2f1c711][nixpkgs]] which builds [[id:20220506T155905.773161][vsketch and vpype]] for my [[id:20220528T120133.736193][Plotter Art]], so it's kind of a pain to update rather than simply checking out the =nixpkgs-unstable= branch.. Might have to [[elisp:(magit-status "/home/rrix/Code/nixpkgs")]] and resolve some merge conflicts... I should upstream these packages!!!
** Update [[id:cce/home-manager][home-manager]] by hand
#+CALL: prefetch-git-rev(REPO="nix-community/home-manager", BRANCH="release-23.11")
#+NAME: prefetch-hm
#+results:
: "10cd9c53115061aa6a0a90aad0b0dde6a999cdb9"
#+begin_src nix :noweb-ref homeManager :noweb yes
homeManager = _: builtins.fetchGit {
url = "https://github.com/nix-community/home-manager.git";
allRefs = true;
rev =
<<prefetch-hm()>>
;
};
#+end_src
** Update [[id:nix_community_emacs_overlay][emacs-overlay]] used in [[id:arroyo/emacs][Arroyo Emacs]] by hand
#+CALL: prefetch-git-rev(REPO="nix-community/emacs-overlay", BRANCH="master")
#+NAME: prefetch-em
#+results:
: "bfd3b792ef19d8dbe826c7c8e17cdaccd2f82f20"
#+NAME: emacsOverlay
#+begin_src nix :noweb yes
emacsOverlay = _: builtins.fetchGit {
url = "https://github.com/nix-community/emacs-overlay/";
rev =
<<prefetch-em()>>
;
};
#+end_src
^ This is upstream; I also have a checkout which I can manage with [[elisp:(magit-status "~/Code/emacs-overlay")]]; I can move the =#+NAME= keyword on the above code segment to this one to build a local instance:
#+begin_src nix
emacsOverlay = _: /home/rrix/Code/emacs-overlay;
#+end_src
** Update =poetry2nix= overlay
#+CALL: prefetch-git-rev(REPO="nix-community/poetry2nix", BRANCH="master")
#+NAME: prefetch-p2n
#+results:
: "e0b44e9e2d3aa855d1dd77b06f067cd0e0c3860d"
#+NAME: poetry2nix
#+begin_src nix :noweb yes
poetry2nix = _: builtins.fetchGit {
url = "https://github.com/nix-community/poetry2nix/";
rev =
<<prefetch-p2n()>>
;
};
#+end_src
** [[id:mastodon_in_emacs][mastodon]] in Emacs ->
builds from https://codeberg.org/martianh/mastodon.el/commits/branch/main
#+begin_src nix :noweb-ref mastodon
mastodon = { pkgs, ... }: pkgs.fetchgit {
url = "https://codeberg.org/martianh/mastodon.el";
rev = "a8c80d25b7790746a439ae6c2deea3dc6bcac710";
sha256 = "143wmg9jhdi79y1gdi0y9xxpp8vyn7qbhvaysq1sf7g1h0jskxc2";
# date = "2023-10-30T20:22:18+01:00";
};
#+end_src
** [[id:cce/nixgl][nixGL]] ->
#+begin_src nix :noweb-ref nixgl
nixGL = { pkgs, ... }: pkgs.fetchFromGitHub {
owner = "guibou";
repo = "nixGL";
rev = "489d6b095ab9d289fe11af0219a9ff00fe87c7c5";
sha256 = "03kwsz8mf0p1v1clz42zx8cmy6hxka0cqfbfasimbj858lyd930k";
# date = "2023-06-04T21:57:57+02:00";
};
#+end_src
** [[id:cce/tabfs][TabFS]] ->
#+begin_src nix :noweb-ref tabfs
tabfs-rev = "09d57f94b507f68ec5e16f53b1cc868fbaf6cceb";
tabfs-fetch = {pkgs, ...}: pkgs.fetchFromGitHub {
owner = "osnr";
repo = "TabFS";
rev = "e056ff9073470192ef4c8498aaa7e722edae87c2";
sha256 = "1xbnx30m6dcd10i5xrma5q0azky5w6hgas500ginqg9s9skgciiw";
# date = "2023-03-02T15:45:33-05:00";
};
#+end_src
** [[id:ba5765e9-7b30-4168-9001-f1a34787ab94][consult-org-roam]]
#+begin_src nix :noweb-ref consult-org-roam
consult-org-roam-rev = "268f436858e1ea3b263782af466a54e4d603a7d2";
consult-org-roam = {pkgs, ...}: pkgs.fetchFromGitHub {
owner = "jgru";
repo = "consult-org-roam";
rev = "8e5b60a61eee9d0582afd309bc4e70ca3b1054cb";
sha256 = "0hzc8kd52f2r5nrx5l3pbkj17mz2ms3715gq814k5iw2z9ir6ha3";
# date = "2024-01-15T12:45:32+01:00";
};
#+end_src
** [[id:20220704T164150.482873][ox-rss]]
#+begin_src nix :noweb-ref ox-rss
ox-rss = rec {
version = "20220704.0450";
rev = "83dc898fa5493925b01716e5dd495d5e07c3d41a";
url = "https://gitlab.com/nsavage/ox-rss.git/";
src = { pkgs, ... }: pkgs.fetchgit {
rev = "3b8bbe8a392bbb04f17bf426400c53283fd3647a";
url = "https://gitlab.com/nsavage/ox-rss.git/";
sha256 = "02k9mbi3shjzpmc2z6w5ypjvxq9mlnw6qjkrs8bi10fqsw6fjkpq";
# date = "2023-01-22T11:36:35+00:00";
};
};
#+end_src
** [[id:2e31b385-a003-4369-a136-c6b78c0917e1][org-fc]]
#+begin_src nix :noweb-ref org-fc
org-fc = rec {
rev = "f64b5336485a42be91cfe77850c02a41575f5984";
src = { pkgs, ... }: pkgs.fetchFromGitHub {
owner = "l3kn";
repo = "org-fc";
rev = "0fea2849150032199fdf275c2fee660cc586095d";
sha256 = "0911lr5qlk7p1fg8ady5x39ai08yws70z6yg2w1qgc8zadyqp0w4";
# date = "2024-01-31T03:20:05+01:00";
};
};
#+end_src
** [[id:cce/ement.el][Ement.el]]
#+begin_src nix :noweb-ref org-fc
ement = rec {
rev = "8aea26acefd9e3eafa24db240e41aa9d41603586";
src = { pkgs, ... }: pkgs.fetchurl {
url = "https://github.com/alphapapa/ement.el/archive/8aea26acefd9e3eafa24db240e41aa9d41603586.tar.gz";
sha256 = "1zs8j9zvwda029ld2lnqkw03i7zsibrdy68fpsz5ylw7czd6qfzi";
# date = "2024-01-31T15:49:01-0800";
};
};
#+end_src
** [[id:20221216T003951.778630][=cpmtools=]]
:LOGBOOK:
CLOCK: [2024-01-22 Mon 10:24]--[2024-01-22 Mon 10:24] => 0:00
:END:
#+begin_src nix :noweb-ref cpmtools
cpmtools = {
version = "2.21";
src = { pkgs, ... }: pkgs.fetchFromGitHub {
owner = "lipro-cpm4l";
repo = "cpmtools";
rev = "e534e20c15973a9559e981efb498a102020e5db7";
sha256 = "0klad0zpxsllqcrjqqmsjvhcbrw7pjnkksr4n84ma6gc3nxb984c";
# date = "2020-07-26T12:24:37+02:00";
};
};
#+end_src
** [[id:20220611T182415.660603][beetcamp]]
#+begin_src nix :noweb-ref beetcamp
beetcamp = {
version = "unstable-2022-06-07";
src = { pkgs, ... }: pkgs.fetchFromGitHub {
repo = "beetcamp";
owner = "snejus";
rev = "f09dfed68e74ee99474a7e414c9bcf4cf056ee5c";
sha256 = "1217gqd9jv4ip0rcmpq5q84gia891hwgpmdn2ywkcy4dvniwvxxa";
# date = "2023-08-09T10:09:27+01:00";
};
};
#+end_src
** [[id:20220421T223829.601322][Mopidy Bandcamp]]
#+begin_src nix :noweb-ref mopidy-bandcamp
mopidy-bandcamp = {
version = "1.1.5";
src = { python3Packages, ... }: python3Packages.fetchPypi {
version = "1.1.5";
pname = "Mopidy-Bandcamp";
sha256 = "012w2iw09skayskbswp5dak0mp5xf3p0ld90lxhh8rczw9q763y2";
};
};
#+end_src
** [[id:cce/delve][delve]]
#+begin_src nix :noweb-ref delve
delve = {
version = "0.9.3";
commit = "9a3e2675ef76865e9ffd95bb49ae1c8307cbfcc1";
src = { pkgs, ... }: pkgs.fetchFromGitHub {
owner = "publicimageltd";
repo = "delve";
rev = "0c84a886d9c2fa8a6743c2882551d4b1c0b4cc4f";
sha256 = "1cd2lbq5xky0ayqqvc3mc0zbvmskdc00h37jqzdvp6vsajqfnpxn";
# date = "2024-01-10T08:36:50+01:00";
};
};
#+end_src
** [[id:20221223T144838.047747][=jisho-api=]]
#+begin_src nix :noweb-ref jisho-api
jisho-api = {
version = "0.1.8";
src = { pkgs, ... }: pkgs.fetchFromGitHub {
owner = "pedroallenrevez";
repo = "jisho-api";
rev = "d6dc85ca686e6f80b90fdf5ff5d2e76754abbdf2";
sha256 = "0lkkilab5g4mbd8d8cr4wbig4cm2sr9nwpdjv90f3bwpw6klizlf";
# date = "2023-09-05T13:53:44+01:00";
};
};
#+end_src
** [[id:20220727T152924.019338][iNaturalist to Sqlite]]
#+begin_src nix :noweb-ref inaturalist-to-sqlite
inaturalist-to-sqlite = {
version = "0.2.1";
src = { pkgs, ... }: pkgs.fetchFromGitHub {
owner = "dogsheep";
repo = "inaturalist-to-sqlite";
rev = "d888c7c2f02aa0dfb1559603f02357cd0089da11";
sha256 = "0iybdjinlxinsh4fk74k65q39rn1phwg0q9xjay9w90i74dqd0nr";
# date = "2020-10-21T17:08:29-07:00";
};
};
#+end_src
** [[id:20220727T152922.043013][Twitter to Sqlite]]
#+begin_src nix :noweb-ref twitter-to-sqlite
twitter-to-sqlite = {
version = "0.2.1";
src = { pkgs, ... }: pkgs.fetchFromGitHub {
owner = "dogsheep";
repo = "twitter-to-sqlite";
rev = "f09d611782a8372cfb002792dfa727325afb4db6";
sha256 = "0nr2s1avb7ah7ygw5p75h0q6qsqvr97k46hi1hsc1j4w6gy2q810";
# date = "2021-12-26T10:08:40-08:00";
};
};
#+end_src
** [[id:20230205T132148.236178][bandcamp-dl]]
#+begin_src nix :noweb-ref bandcamp-dl
bandcamp-dl = {
version = "0.0.1";
src = { pkgs, ... }: pkgs.fetchFromGitHub {
owner = "iliana";
repo = "bandcamp-dl";
rev = "2334dbba00da874210191704b1e86ae489e543c0";
sha256 = "1h4jjrbgndsg2kg5hg0ar0m7bn1sb8b0chzp63pzqbyjsrr53lhm";
# date = "2023-12-26T23:03:05-08:00";
};
};
#+end_src
** NEXT [[id:20220506T155905.773161][vsketch and vpype]] dependencies
** NEXT automate fetchFromPyPi or move to GH fetchers
** [[id:20230310T155744.804329][tt-rss]] plugins
#+begin_src nix :noweb-ref ttrss
large_apod = { pkgs, ... }: pkgs.fetchFromGitHub {
owner = "joshp23";
repo = "TTRSS-APOD-Fix";
rev = "d6233f7a9031eaa07649d6b4777525524827f9de";
sha256 = "11vi81vha3sv9nq36ipxisrnrk5y38582f2nk7qg057d6jm9jw0f";
# date = "2017-06-25T13:52:41-04:00";
};
ttrss_wallabag = { pkgs, ... }: pkgs.fetchFromGitHub {
owner = "joshp23";
repo = "ttrss-to-wallabag-v2";
rev = "49ade5a1a216de74e42c4942ffa9cbf1bf426bec";
sha256 = "09rspawg0by5fk1x5b3b3smzqp4zw93h8c7zdxr63z6wjs41ba0j";
# date = "2021-03-14T01:26:43-05:00";
};
# https://gitlab.tt-rss.org/tt-rss/plugins/ttrss-af-readability
ttrss_readability = { pkgs, ... }: pkgs.fetchgit {
url = "https://gitlab.tt-rss.org/tt-rss/plugins/ttrss-af-readability";
rev = "cdc97d886cb7085f9c44a1796ee4bbbf57534d06";
sha256 = "0n0dzw9v2fgzn9zg95infwifkcc1yhv7m8n7isq67yh6rvx2kg1x";
# date = "2023-04-02T19:07:22+03:00";
};
fever_plugin = { pkgs, ... }: pkgs.fetchFromGitHub {
owner = "DigitalDJ";
repo = "tinytinyrss-fever-plugin";
rev = "cc297d8939f91e53bf873f8d982a7869916483df";
sha256 = "0qryndbh8liwyd6iilqagd29v0awmg8il4qrpdg1khac8nxa1cb9";
# date = "2023-10-28T00:29:41+10:30";
};
#+end_src