| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
lib/default.nix is for backwards compatibility only, so the examples in
the README and ci.nix use lib/with.nix, as klib, with nixpkgs' lib from
pkgs. pkgs.populate and its checks name what they use from nixpkgs'
lib, builtins, and klib, instead of bringing them into scope with with,
and the scenarios inherit what they use from the builder and nixpkgs'
lib, which the builder doesn't pass on anymore. Nix tells undefined
names when parsing then, and a name means the same wherever it's used.
The derivations and the scenarios stay the same.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Looking at a flake with inputs drawn from sources, populate overrides
those inputs with an empty flake, which makes Nix warn that it doesn't
write the lock file it changed, listing the overrides, on every run,
locally for archiving a flake or flake-input source, and on the target
for checking the inputs drawn. nix_looking leaves that warning out of
what Nix prints.
A generated flake gets locked anew on every run, so it pins what the
inputs are now, which made Nix print that it creates the lock file,
listing all inputs, on every run. That only gets printed if the lock
file differs from the one there was.
No phase is expected to print Nix's warning, and relock's second phase,
which changes nothing, isn't expected to print anything about the
generated flake's lock file.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
| |
Resetting a work tree that is at the commit already rewrites Git's index,
after comparing each tracked file with it, which takes long for big work
trees like nixpkgs, and comparing alone takes about a third of that. So
git sources reset only if HEAD isn't the commit, or a tracked file
differs from it, as git status tells, which also covers a lock file Nix
created and staged.
The git scenarios also change a tracked file, which redeploying resets.
|
| |
|
|
|
| |
dep's greeting is "dep+" and the who of its input inner, so the flake
the scenario draws inner from needs who, not greeting.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Whether a derived copy of a flake or flake-input source needs to be
made again depends on the sources it draws inputs from. For one that
isn't in the store, the key had its hash, so every run read all of it,
e.g. all of a nixpkgs work tree, .git included, which takes long even
when nothing changed. For a Git work tree that Nix gets as git+file:,
whose commit and tracked files are all Nix uses, the key has its
commit instead, if no tracked file differs from it, which Git tells
quickly. git_flake decides what Nix gets as git+file:, for resolve as
well.
Keys of copies drawing from such work trees change once, so those
copies get made again on the first run, also after deploying with
krops 1.
rewrite-cache-git checks that such a copy gets made again for a new
commit, but not for redeploying, nor for an untracked file.
|
|
|
populate's tests are in pkgs/populate/tests, independent of krops.
They run the program, with the sources as JSON from populate's Nix
library, and target strings for the remote targets, leaving the user
and whether the target is local to populate, so they cover its command
line too. Phases expecting populate to refuse its arguments, e.g. a
source name or a target path that can't be used, expect the program's
refusal, with refused, the message, since nothing checks them during
evaluation there.
builder.nix is what builds the scenarios, which krops' tests use as
well, with a function running the phases, and whether that checks the
arguments during evaluation. vm.nix takes a module for both machines,
for what else the scenarios run, and fixtures.nix and smoke.nix are
what both use of the fixtures and the smoke test.
krops' tests are deploy, writeDeploy's arguments to nixos-rebuild, with
the stand-in for nixos-rebuild in the module, and populate, populate's
scenarios that expect refusals, which pkgs.populate makes evaluation
fail with, and those of populate's smoke test, all through
pkgs.populate with target attribute sets as mkTarget returns them.
-A only selects from all of populate's scenarios and krops' own.
|