| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
| |
ln -f replaces files and links, but not directories, so a symlink source
failed where a directory was, e.g. the Git work tree of a source that had
another type: "cannot overwrite directory". The symlink script removes
what isn't a link first, with remove_tree, which also copes with
directories that aren't writable.
|
| |
|
|
|
|
|
|
| |
git sources' snippets run grep and sed on the target, so check looks for
them there as well, with Git, and gets them from <nixpkgs> there, if the
target lacks them. The README names grep and sed among what populate
runs on the machine it runs on, too, for pass sources and Git work trees
that flakes get drawn from.
|
| |
|
|
|
|
|
|
|
|
| |
populate runs findutils, flock, rsync, patch, and Git on the target, as
the sources need them. check looks for those first, and if any isn't
there, it warns, and gets their packages from the target's <nixpkgs> with
one nix-build, whose bin directories commands on the target, and rsync's
remote end, find commands in before those in their PATH, for the rest of
the run. If the target is the machine populate runs on, that goes for
populate as well.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A consumer recording what a build used gets the commit of git sources,
and the store paths of flake, flake-input, and derivation sources, but
nothing for file sources, which often hold the configuration, taken from
work trees on the deploying machine. Recording nothing about them stays
the default, since they may hold secrets, whose hash could give them
away. file sources' record setting, with flags that default to false,
adds to the source's entry in the record:
- commit: if path is in a Git work tree, the commit HEAD names, and
dirty, whether git status lists anything in path. Git runs on the
deploying machine, without hooks, file system monitors, and writing
the index, on every run, which is cheap: a new commit can change HEAD
without changing any file.
- digest: what nix-hash --type sha256 --sri prints for the target path,
after the flakes step, which may have rewritten its lock file. That
takes reading all of it, so populate only computes it if the source
changed since the last record, and else takes it from that record,
which the command taking the lock prints, so a run that changes
nothing reads nothing more.
The record's format stays version 0: the fields are optional additions.
The README documents that the record tells what populate delivered,
which something changing the target directory meanwhile would make it
miss, and how rsync can leave out much of what Git ignores, with
:- .gitignore in a .rsync-filter file, and what that misses.
record-file checks the commit, dirty, and the digest, also taken from
the last record.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A file or git source whose lock file the flakes step rewrites in place
gets the original back from delivering it, on every run, from rsync, or
from git reset, which also printed HEAD is now at, and Nix printed that
it updates the lock file, so the record said the source changed on every
run. Populate keeps a copy of the rewritten lock file in
.populate/locks/<name>, and the flakes step compares with it, printing
what Nix says about the lock file, and changed, only if it differs.
Delivering such a source doesn't count bringing back the lock file:
rsync returns the paths of what it changed, and the git source's script
takes the lock file's path, and resets quietly if that's all that
differs.
relock also checks that the second, unchanged, run prints nothing about
lock files, and says nothing changed, now for rewriting in place too.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The command holding the lock can end while populate runs: killed on the
target, e.g. by the OOM killer, or with the shared ssh connection, e.g.
when its master gets killed, after which populate's next command would
start a new one, and go on without the lock. When that command ends, so
does what populate runs it with, ssh or sh, which populate's child is.
So Context::shell, which every command on the target goes through,
before what it changes, and before the record, checks that the child is
still running, failing otherwise. A run that wasn't locked throughout
doesn't get recorded, and its journal stays, so the next record tells
what it changed. Context keeps the lock, which clean_up releases.
The keepalives end the shared connection, and with it the command
holding the lock on the target, about a minute after the target stops
answering, e.g. when the network fails, instead of when TCP gives up,
which may take hours.
lock-lost kills the command holding the lock from a pipe source.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For consumers of the target directory on the target, e.g. a CI service,
which should act after a run that delivered everything, and know what it
delivered.
Populate holds an exclusive flock on .populate/lock from right after
checking the sentinel until it's done. The command holding it runs over
the shared connection, or directly, keeping the lock until its input
ends, which populate's ending ends as well, so no lock stays behind.
Runs wait for each other, and for consumers holding a shared lock,
saying so. The sentinel is a directory, which a sentinel file becomes,
since there's always state to keep now, and the target needs flock.
Populate keeps a journal in .populate/journal, a line of JSON for each
entry: a run starting, beginning to deliver or change a source, what
that changed, and pruning. The entries go with the next command on the
target, before what that changes, so the journal needs no commands of
its own. After delivering everything, populate replaces
.populate/run.json with the record of the run, which sums up the
journal, and removes the journal. A run that doesn't finish leaves it,
so changed in the record means changed since the last record: a source
the journal tells began changing, without what it changed, counts as
changed. The record has, for each source, its type, whether it changed,
and what got delivered: the commit of a git source, the store path of a
flake, flake-input, or derivation source, and the derived one, and a
symlink's target. Nothing about secrets, nor files.
Each source type is a Kind, whose deliver returns the Outcome: whether
anything changed, and what got delivered. rsync tells changes by what
it itemizes, the snippets by printing changed: the git source if it
cloned, reset, or submodule updates or cleaning printed anything, links
if they point elsewhere, and lock files and generated flakes if they
differ. Symlinks in place of the lock or the journal get refused.
A file or git source whose lock file populate rewrites in place counts
as changed on every run, since delivering it brings back the original.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The default, toString ~/.passage/identities, is a path relative to the
home directory, which Nix resolves when parsing the file defining it,
populate's Nix library's types, so evaluating any sources failed in pure
mode, e.g. in a flake. identities_file defaults to null, which leaves it
out of the sources, and populate defaults it to ~/.passage/identities,
in HOME, when it runs.
The passage scenarios also run without identities_file, with HOME a
directory that has .passage/identities.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
git_problems looks through all of a work tree for .git files and
directories, which takes long for big ones like nixpkgs. A git source
drawn from by a flake-input source got checked three times per run:
when delivering it, by resolve, deciding on git+file:, and by
derived_state, for the key. populate notes the work trees git_problems
found nothing wrong with during the run, and resolve and derived_state
get told, so git_flake only checks the rest, e.g. hooks.
The git source's script prints checked if it checked the work tree that
was there, instead of making a fresh clone. Its commands print to
standard error, without getting the standard output populate reads, so
nothing they leave running keeps populate waiting.
rewrite-cache-gitsource is rewrite-cache-git with a git source.
|
| |
|
|
|
|
|
|
| |
A pipe source's command is an absolute path, which a shell runs as a
script if it isn't a program, e.g. lacks #!. The program ran it
directly, which fails for such a command.
pipe-script runs a pipe command without #!.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The program decides how to draw inputs and derive copies of flake and
flake-input sources itself. The target runs fixed snippets, which send
back what it needs to know: where paths resolve to and what's there, the
lock files of flakes as nix flake metadata prints them, and what tells
whether a derived copy needs to be made again. The program checks that
drawn inputs exist in the lock files, computes the keys of derived
copies, and writes generated flakes.
Derived copies get the same keys as with the shell implementation, so
switching implementations doesn't make them again.
|
| |
|
|
|
|
|
|
|
|
|
| |
src/flake_input.rs reads what nix flake metadata and nix flake archive
print as JSON itself: it selects the flake or input, decides what the
target fetches or gets copied, and computes the store paths to root,
which are what selected.jq, selfIsRemote.jq, selfLocked.jq, and the Nix
expressions of the shell implementation do there. On the target, fixed
snippets in sh::flake run Nix, getting values as positional parameters,
and send JSON or store paths back. The jq test's cases are unit tests of
the Rust equivalents.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The program delivers flake and flake-input sources, draws inputs from
sources, and removes state that sources don't need anymore, so it does
everything the shell implementation does, and passes all scenarios.
src/flake.rs builds the same shell code as shell.nix generates for
these, with every value quoted, so both implementations behave alike
while that code moves to Rust piece by piece.
The ssh scripts in the temporary directory run the ssh that was in PATH
when populate started, so one can be ssh in PATH for nix copy. The
other one is for nix copy's ssh:// store, without the control socket.
|
|
|
The program delivers derivation, file, git, pass, passage, pipe, and
symlink sources, makes backups, and prunes, as the shell implementation
does, with the same messages. Commands on the target are fixed shell
snippets in src/sh.rs, which get values as positional parameters, run
directly for local targets and over ssh, sharing one master connection,
for remote ones. rsync's transfers and its check for .rsync-filter files
it can't read are in src/rsync.rs. Given flake or flake-input sources, or
sources drawing inputs from others, the program fails before changing
anything, saying that these aren't implemented yet.
SIGHUP, SIGINT, and SIGTERM make populate stop once the command it waits
for ends, stop the ssh master, remove its temporary directory, and exit
with 128 plus the signal's number.
The spec's target gets local, which rust.nix sets during evaluation, like
the other functions of krops decide, and which the program decides when
it runs if it's null. The spec comes on file descriptor 3, so the
commands populate runs keep standard input, and the tools populate runs
come first in PATH.
|