tack and everything and wow

This commit is contained in:
atagen 2026-06-09 16:01:48 +10:00
parent 480c556d32
commit 7a6f387652
24 changed files with 801 additions and 358 deletions

302
.tack/default.nix Normal file
View file

@ -0,0 +1,302 @@
# SPDX-License-Identifier: EUPL-1.2
# tack-managed resolver. delete this line to take ownership; tack will leave it alone afterwards.
let
inherit (builtins)
attrNames
attrValues
concatMap
elemAt
filter
foldl'
fromJSON
head
intersectAttrs
isList
isString
listToAttrs
mapAttrs
match
pathExists
readFile
substring
tail
trace
;
call =
{
overrides ? { },
}:
let
pins = fromTOML (readFile ./pins.toml);
lock = fromJSON (readFile ./pins.lock.json);
all_follow_raw = pins.all_follow or { };
# flatten `target = [aliases]` rows alongside `alias = "target"` rows
all_follow = foldl' (
acc: key:
let
val = all_follow_raw.${key};
in
if isList val then
acc
// {
${key} = key;
}
// listToAttrs (
map (a: {
name = a;
value = key;
}) val
)
else if isString val then
acc // { ${key} = val; }
else
acc
) { } (attrNames all_follow_raw);
# a path node's stored path is absolute, or relative to this resolver dir
fetchPin =
name:
let
node = lock.${name};
in
if (node.type or "") == "path" && substring 0 1 node.path != "/" then
fetchTree (node // { path = ./. + ("/" + node.path); })
else
fetchTree node;
fetchFixed =
name: entry:
let
raw = derivation {
inherit name;
inherit (entry) url;
builder = "builtin:fetchurl";
system = "builtin";
outputHash = entry.sha256;
outputHashAlgo = "sha256";
outputHashMode = "flat";
};
unpacked = derivation {
inherit name;
builder = "builtin:unpack-channel";
system = "builtin";
src = raw;
channelName = name;
};
in
if (entry.unpack or "file") == "tarball" then unpacked.outPath + "/" + name else raw.outPath;
resolveSpec = upLock: spec: if isList spec then walkPath upLock upLock.root spec else spec;
walkPath =
upLock: nodeName: path:
if path == [ ] then
nodeName
else
walkPath upLock (resolveSpec upLock upLock.nodes.${nodeName}.inputs.${head path}) (tail path);
followsFor =
pin:
let
rules = removeAttrs all_follow (pin.exclude_follow or [ ]);
in
{
level = (pin.follows or { }) // rules;
deep = rules;
};
resolveFollows = mapAttrs (
_: target: self.${target} or (throw "tack: follows target '${target}' is not a pin")
);
# follows key is `flake:name`, `tack:name`, or bare `name`
# project onto one side, rekeyed to bare names
followsForSide =
side: follows:
listToAttrs (
concatMap (
key:
let
m = match "(flake|tack):(.*)" key;
in
if m == null then
[
{
name = key;
value = follows.${key};
}
]
else if head m == side then
[
{
name = elemAt m 1;
value = follows.${key};
}
]
else
[ ]
) (attrNames follows)
);
mkCallerInputs =
upLock: nodeName: rawInputs: levelFollows: deepFollows:
let
resolved = resolveFollows levelFollows;
in
mapAttrs (
n: _decl:
resolved.${n} or (
if upLock != null then
let
ref =
(upLock.nodes.${nodeName}.inputs or { }).${n}
or (throw "tack: input '${n}' declared but not in flake.lock node '${nodeName}'");
childName = resolveSpec upLock ref;
childNode = upLock.nodes.${childName};
childSrc = fetchTree childNode.locked;
in
if childNode.flake or true then evalTransitive upLock childName childSrc deepFollows else childSrc
else
throw "tack: no flake.lock; cannot resolve input '${n}'"
)
) rawInputs;
mkFlakeResult =
sourceInfo: flakeDir: callerInputs: outputs:
outputs
// sourceInfo
// {
outPath = flakeDir;
inputs = callerInputs;
inherit outputs sourceInfo;
_type = "flake";
};
evalFlake =
sourceInfo: flakeDir: upLock: nodeName: levelFollows: deepFollows:
let
raw = import (flakeDir + "/flake.nix");
tackPinsPath = flakeDir + "/.tack/pins.toml";
hasTack = pathExists tackPinsPath;
upPins = if hasTack then fromTOML (readFile tackPinsPath) else { };
# project follows onto each side, keep only names that side has
# bare follow reaches both; `flake:`/`tack:` reaches just one
tackOverrides = resolveFollows (
intersectAttrs (upPins.inputs or { }) (followsForSide "tack" levelFollows)
);
flakeLevel = intersectAttrs (raw.inputs or { }) (followsForSide "flake" levelFollows);
# deep follows pass down raw, so each descendant re-projects per side
callerInputs = mkCallerInputs upLock nodeName (raw.inputs or { }) flakeLevel deepFollows;
# upstream declares its outputs forward tackOverrides; a closed `{ self }:`
# would throw on the extra kwarg, so forward only when declared
supportsOverrides = (upPins.tack or { }).recomposable or false;
extraArgs = if supportsOverrides && tackOverrides != { } then { inherit tackOverrides; } else { };
outputs = raw.outputs (callerInputs // extraArgs // { self = result; });
result =
let
base = mkFlakeResult sourceInfo flakeDir callerInputs outputs;
in
if hasTack && tackOverrides != { } && !supportsOverrides then
trace "tack: ${flakeDir}: not marked recomposable (set [tack] recomposable = true); overrides will not reach upstream" base
else
base;
in
result;
evalTransitive =
upLock: nodeName: sourceInfo: follows:
evalFlake sourceInfo sourceInfo.outPath upLock nodeName follows follows;
evalTopFlake =
sourceInfo: pin:
let
flakeDir = sourceInfo.outPath + (if pin ? dir then "/" + pin.dir else "");
upLockPath = flakeDir + "/flake.lock";
upLock = if pathExists upLockPath then fromJSON (readFile upLockPath) else null;
rootNode = if upLock != null then upLock.root else null;
f = followsFor pin;
in
evalFlake sourceInfo flakeDir upLock rootNode f.level f.deep;
evalFetch =
sourceInfo: pin: subdir:
let
path = sourceInfo.outPath + subdir;
tackPinsPath = path + "/.tack/pins.toml";
hasTack = pathExists tackPinsPath;
upPins = if hasTack then fromTOML (readFile tackPinsPath) else { };
f = followsFor pin;
# a fetch drill-in is tack-only
tackOverrides = resolveFollows (
intersectAttrs (upPins.inputs or { }) (followsForSide "tack" f.level)
);
in
# a fetch pin is a source tree (path); hand back resolved inputs only when
# there are overrides to push into the upstream's .tack
if hasTack && tackOverrides != { } then
let
upstream = import (path + "/.tack");
in
# old resolvers return a plain attrset, not a callable functor
if upstream ? __functor then
(upstream { overrides = tackOverrides; }) // { outPath = path; }
else
trace "tack: ${path}: upstream .tack predates override support; overrides will not reach it" path
else
path;
loadPin =
name: pin:
let
pinType = pin.type or (if pin.flake or true then "flake" else "fetch");
subdir = if pin ? dir then "/" + pin.dir else "";
in
if pinType == "fixed" then
fetchFixed name lock.${name}
else
let
sourceInfo = fetchPin name;
in
if pinType == "flake" then evalTopFlake sourceInfo pin else evalFetch sourceInfo pin subdir;
declared = pins.inputs or { };
# undeclared lock entries are auto-dedup synthetics only when referenced as
# [all_follow] targets; stale locks from hand-edits are ignored (tack rm to clean)
autoTargets = listToAttrs (
map (target: {
name = target;
value = true;
}) (attrValues all_follow)
);
autoNames = filter (n: !(declared ? ${n}) && autoTargets ? ${n}) (attrNames lock);
autoPin =
name:
let
sourceInfo = fetchPin name;
in
if pathExists (sourceInfo.outPath + "/flake.nix") then evalTopFlake sourceInfo { } else sourceInfo;
self =
(mapAttrs loadPin declared)
// listToAttrs (
map (name: {
inherit name;
value = autoPin name;
}) autoNames
)
// overrides;
in
self // { __functor = _: call; };
in
call { }

206
.tack/pins.lock.json Normal file
View file

@ -0,0 +1,206 @@
{
"arbys": {
"type": "git",
"url": "https://git.lobotomise.me/atagen/arbys",
"ref": "refs/heads/meats",
"rev": "cc1e2613fbbb0ed98bb4ce0d52c6e99bb8f98055",
"narHash": "sha256-Z/O9W0A0SG/cZiiviNPfmciqvI6a3giCLFt/ElwtLCs=",
"lastModified": 1756449827
},
"autonym": {
"type": "github",
"owner": "manic-systems",
"repo": "autonym",
"rev": "0117ec675ef469d92309a25456005e44dae3d1e8",
"narHash": "sha256-WWyMNxb2HAAr13HoO7rC1wrT83zTaYf3/Q2taFUVu84=",
"lastModified": 1780983954
},
"cade": {
"type": "github",
"owner": "manic-systems",
"repo": "cade",
"rev": "37603ff8a75483e713ad823b53df627c72be093a",
"narHash": "sha256-+uzmExx+QszSWUKQeFJSTGm9WrNxtf6oSd2dcRNOG8M=",
"lastModified": 1780984342
},
"headroom": {
"type": "github",
"owner": "manic-systems",
"repo": "headroom",
"rev": "041edb0f1758372dfb64048eb5d3b18d4b620dfc",
"narHash": "sha256-NNhwKxYLf4rxJjjAKrjCfm65PGPJ/jdZZAmiTwxtoew=",
"lastModified": 1780544339
},
"helium": {
"type": "github",
"owner": "amaanq",
"repo": "helium-flake",
"rev": "d765e1962dbe3fa08e0bf4f6abd3dd53806cf826",
"narHash": "sha256-eHfsA/pKQAK60jmyGzGP7BvcJOXAPZJY0lEQJC2xlGc=",
"lastModified": 1780821058
},
"hudcore": {
"type": "git",
"url": "https://git.lobotomise.me/atagen/hudcore-plymouth",
"ref": "refs/heads/main",
"rev": "6555d555797bf1960bd89e76a53e0240b6a93df9",
"narHash": "sha256-AI72zuAQBSYETn/dhN8qN8Hdts8PWnSDLEgAxMSZ+CU=",
"lastModified": 1774692528
},
"inshellah": {
"type": "github",
"owner": "manic-systems",
"repo": "inshellah",
"rev": "d9b0785a14acb6b9f439d19b0fd696489b017591",
"narHash": "sha256-yAyiffrfDxZvjsDSJzVkxJB2rHCe7pamtuv0xq0zIuU=",
"lastModified": 1780984030
},
"meat": {
"type": "git",
"url": "https://git.lobotomise.me/atagen/meat",
"ref": "HEAD",
"rev": "d76f4783000aa109b8fbe63380ae8cfa1e9fcece",
"narHash": "sha256-+Psh1I2/T0x4+Efl73iI59ZR9LKrkdwKAxsB1RN9VHM=",
"lastModified": 1780984054
},
"ncro": {
"type": "github",
"owner": "feel-co",
"repo": "ncro",
"rev": "b33e43200b2c28924b1f6a1304f316e9f8d75654",
"narHash": "sha256-POz3sWFFCYnwp79EMnal0I9487Q/ir+hPrswfGamExw=",
"lastModified": 1780984256
},
"niri": {
"type": "github",
"owner": "sodiboo",
"repo": "niri-flake",
"rev": "da6577a9bef8a4d7a9d7a2a0dc1e1089edb46bed",
"narHash": "sha256-/Tzx2TY0IVm/ptBvkKaLdOHADpM7xsUMfBKOpCibH1M=",
"lastModified": 1780944960
},
"niri-s76": {
"type": "git",
"url": "https://git.lobotomise.me/atagen/niri-s76-bridge",
"ref": "refs/heads/main",
"rev": "e3afb85f23c0e59b2a818094ee7b391ca2f3504d",
"narHash": "sha256-UicMzXYy2XE5jr2J7IO6pZTXUNPndPrGHSIIN6+fB1E=",
"lastModified": 1771162707
},
"niri-tag": {
"type": "git",
"url": "https://git.lobotomise.me/atagen/niri-tag",
"ref": "refs/heads/main",
"rev": "785619920b8ae1dd147da795cc7e703c3367c34a",
"narHash": "sha256-y5KsYbzC3MLKr+2M1792jxs3//uV8x9kG+G0LA7cycg=",
"lastModified": 1772457471
},
"nix-index-database": {
"type": "github",
"owner": "Mic92",
"repo": "nix-index-database",
"rev": "1a2ea89c917781e88508d9fd2b507f2d2a0e173c",
"narHash": "sha256-0BYqs8yKWkOz2Q7+SP18N5E5gmDKSo6LSxIVIa0wWes=",
"lastModified": 1780816331
},
"nix-rice": {
"type": "github",
"owner": "bertof",
"repo": "nix-rice",
"rev": "98b16b0f649bb41db9a1c3b32191bccb9a1ec271",
"narHash": "sha256-nt/xmuXaJB/vWlRJ4wpdlYQCIgCzFR6QJwlRyhfNn5o=",
"lastModified": 1768817933
},
"nixos-core": {
"type": "github",
"owner": "manic-systems",
"repo": "nixos-core",
"rev": "20b5f8916a3fde2f02bccd2e1f2795ab511aab5b",
"narHash": "sha256-7x7KzH5p+VDBvvzpCjkRcVhNm6fIty7WYgI7sPq1SCw=",
"lastModified": 1780223676
},
"nixpkgs": {
"type": "tarball",
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1011622.a799d3e3886d/nixexprs.tar.xz",
"narHash": "sha256-G5B1h4sOH4DN/RZ85xYi6zPm2MHdOrNMeUmMslZ28Qs=",
"lastModified": 1780879182
},
"nixpkgs-stable": {
"type": "tarball",
"url": "https://releases.nixos.org/nixos/26.05/nixos-26.05.1550.bd0ff2d3eac2/nixexprs.tar.xz",
"narHash": "sha256-YMnBf9lk/LYgvqfmSSJuOGigtRs5Lsy26pJHVlR9yMY=",
"lastModified": 1780936340
},
"qstn": {
"type": "git",
"url": "https://git.lobotomise.me/atagen/qstn",
"ref": "refs/heads/main",
"rev": "e6570c79145f3190ff93cb2036ae963a8643445f",
"narHash": "sha256-0tMAB3gHKG32A4z/hM7aWNU2t+jh1zT4dpoamcHucog=",
"lastModified": 1767007132
},
"qtengine": {
"type": "github",
"owner": "kossLAN",
"repo": "qtengine",
"rev": "073987f0120ac77a92fb9f0c0877aa7f1f04d3bf",
"narHash": "sha256-D7mzavE5WfLyvEXV0pvO3/gxC+SSmfjw4Lxy7I5qvnI=",
"lastModified": 1778644540
},
"rom": {
"type": "github",
"owner": "manic-systems",
"repo": "rom",
"rev": "c577ca3033fe997b0c2910f7abd31076a39b2c42",
"narHash": "sha256-JWOFEK7BUVt0mICxtTITWDCZWhJz7ZStc5VmvPJO9q0=",
"lastModified": 1780479426
},
"run0-shim": {
"type": "github",
"owner": "lordgrimmauld",
"repo": "run0-sudo-shim",
"rev": "0cc83451d5171eba0fdcba36b7f1a09b0f023fa4",
"narHash": "sha256-+t1YYIUG1aMYiryiLsXaUoc3nMNjvO5WsD73lIn/BMk=",
"lastModified": 1780915531
},
"stash": {
"type": "github",
"owner": "notashelf",
"repo": "stash",
"rev": "2f5cf1dd2ec964e545ad5795d69f27941d9eedfe",
"narHash": "sha256-+1uQWB/Lo1EDMTQGap246klRWCnESkkzl+uS3FJOrsQ=",
"lastModified": 1780680185
},
"tack": {
"type": "github",
"owner": "manic-systems",
"repo": "tack",
"rev": "0bc8dcb07dbd85d5d8d889c89accc9b228a6e4cc",
"narHash": "sha256-/GrnjZK71UdLFtugaXkShE8dWpvGxJyOHpj073v+pXU=",
"lastModified": 1780970897
},
"toes": {
"type": "git",
"url": "https://git.wry.land/entailz/toes",
"ref": "refs/heads/master",
"rev": "1962186ce19f771c6c407db2e29d5eb5d762f22f",
"narHash": "sha256-M8rCWv83QSC8SzK0VwyGKciEVSO9FrrncUHnTLt8r9Y=",
"lastModified": 1779607934
},
"tuigreet": {
"type": "github",
"owner": "notashelf",
"repo": "tuigreet",
"rev": "dc41006d4a4366f732a1a75a20b989fc1e42c0a6",
"narHash": "sha256-ZZk1ccebBjK3pzHVsDU4+fvX/c1fePZ3Tic96/OkfpA=",
"lastModified": 1780583973
},
"wry": {
"type": "git",
"url": "https://git.wry.land/kosslan/wry",
"ref": "refs/heads/socket-ipc",
"rev": "f92c092acc1cf6bb7b7b131f8e996c57471a77d2",
"narHash": "sha256-hw5eWVSutlAK3f2rfoSkKvV9FJx4AshWAJwFbQ8LOJE=",
"lastModified": 1780962977
}
}

100
.tack/pins.toml Normal file
View file

@ -0,0 +1,100 @@
# tack pins. edit by hand or with tack add / rm / alias
# nix reads pins.lock.json; this file drives tack update
[shorturls]
atagen = "git+https://git.lobotomise.me/atagen/{path}"
amaan = "github:amaanq/{path}"
wry = "git+https://git.wry.land/{path}"
ms = "github:manic-systems/{path}"
raf = "github:notashelf/{path}"
[all_follow]
nixpkgs = "nixpkgs"
[inputs.nixpkgs]
url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"
[inputs.nixpkgs-stable]
url = "https://channels.nixos.org/nixos-26.05/nixexprs.tar.xz"
exclude_follow = [ "nixpkgs" ]
[inputs.nix-index-database]
url = "github:Mic92/nix-index-database"
exclude_follow = [ "nixpkgs" ]
[inputs.nix-rice]
url = "github:bertof/nix-rice"
exclude_follow = [ "nixpkgs" ]
[inputs.meat]
url = "atagen:meat"
[inputs.hudcore]
url = "atagen:hudcore-plymouth"
exclude_follow = [ "nixpkgs" ]
[inputs.niri]
url = "github:sodiboo/niri-flake"
exclude_follow = [ "nixpkgs" ]
[inputs.niri-tag]
url = "atagen:niri-tag"
[inputs.arbys]
url = "atagen:arbys"
[inputs.qstn]
url = "atagen:qstn"
[inputs.run0-shim]
url = "github:lordgrimmauld/run0-sudo-shim"
[inputs.niri-s76]
url = "atagen:niri-s76-bridge"
[inputs.helium]
url = "amaan:helium-flake"
exclude_follow = [ "nixpkgs" ]
[inputs.stash]
url = "raf:stash"
[inputs.wry]
url = "wry:kosslan/wry/socket-ipc"
[inputs.toes]
url = "wry:entailz/toes"
[inputs.tuigreet]
url = "raf:tuigreet"
[inputs.rom]
url = "ms:rom/small-refactor"
[inputs.qtengine]
url = "github:kossLAN/qtengine"
[inputs.inshellah]
url = "ms:inshellah"
[inputs.nixos-core]
url = "ms:nixos-core"
[inputs.headroom]
url = "ms:headroom"
[inputs.cade]
url = "ms:cade/next"
[inputs.tack]
url = "ms:tack/next"
[inputs.ncro]
url = "github:feel-co/ncro"
[inputs.autonym]
url = "ms:autonym"
# [inputs.zedless]
# url = "github:zedless-editor/zedless-patches"
# exclude_follow = [ "nixpkgs" ]