| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
pkgs/populate/README.md documents populate on its own: building it,
what it needs, its command line, the sources as JSON and in Nix with
its Nix library, the target directory, the source types, flake inputs
from sources, what it prints, and its tests. The sections about the
target directory, the source types, and flake inputs from sources move
there from krops' README, which links to them from sections of the same
names, and from the first mention of populate. docs/design.md keeps
how populate works.
krops' README describes krops' own tests, and CHANGELOG what populate
being a program of its own means for krops.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
populate is a program of its own, with a Nix library, in pkgs/populate,
which krops uses, and which doesn't use krops:
- default.nix builds the program, with nix-build there or callPackage,
as pkgs.populate-unwrapped.
- lib is populate's Nix library: the types of sources and the POSIX
types they use, evalSource, flakeFollows, hasGeneratedFlake, and
derivesFlake, taking nixpkgs' lib. krops' lib takes them from there,
so it provides them as before, and so does lib/types.
pkgs.populate, the function from populate's arguments to a script
running the program, is krops' own, in pkgs/krops/populate.nix, with
checks.nix next to it. It takes the program as populate-unwrapped,
which callPackage passes from the overlay; the flake, whose nixpkgs
lacks it, passes its own.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The program takes populate's arguments on its command line, like other
programs: populate [OPTION]... SOURCES [TARGET], with the sources as
JSON in the file SOURCES, or on standard input for -. TARGET has the
syntax of krops' lib's mkTarget, [USER@][HOST][:PORT][PATH], parsed the
same way, and what it leaves out gets filled in when populate runs, as
mkTarget would, from LOGNAME and the machine's name. Options set what
the syntax can't express, or override its parts: --sudo, --ssh-arg,
--user, --host, --port, --path, and --local or --remote for whether the
target is the machine populate runs on, which populate otherwise
decides like isLocalTarget. The sources carry no version.
pkgs.populate passes a target attribute set, as mkTarget returns it,
part by part, with --local or --remote as evaluation decides, so
nothing changes for krops. A target string goes to the program as it
is.
The program also refuses target hosts and users starting with -, which
ssh would take for options, now that a command line can give them.
|
| |
|
|
|
|
|
|
| |
For specs whose target's local is null, the program decides whether the
target is local like krops' lib's isLocalTarget: an empty LOGNAME or
HOSTNAME counts as unset, as with lib.maybeEnv, and /etc/hostname's
labels can be of any length, as with lib.types.label. is_local_with,
pure, has unit tests.
|
| |
|
|
|
|
|
|
|
|
|
| |
The shell implementation runs under set -e, so it exits with the status
of the command that failed, e.g. 255 if ssh can't reach the target,
which wrappers retrying on connection failures rely on, or 128 if git
fetch fails. The program does the same, instead of exiting with 1, and
with 128 plus the signal for a command a signal ended.
A phase's expect.status is the exit status it expects populate to fail
with; git-status checks git fetch's.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The program checks that each source's settings are those
lib/types/populate.nix defines for its type, with values of the kinds
it defines, for specs from elsewhere than default.nix: a misspelt
setting fails, as design.md promises, instead of being ignored, and so
does a setting the program would treat as its default because of its
kind. This subsumes the check of absolute paths.
ln gets a symlink source's target after --, so it can't be taken for an
option either.
|
| |
|
|
|
|
| |
rsync gives sizes in units of 1000 for two apostrophes, and in units of
1024 for three, which the shell implementation asks for. rsync-units
checks it.
|
| |
|
|
|
|
| |
New users learn what the deploying machine and the target need,
including nixpkgs 23.11 or later for building populate, and developers
where populate's program, its description, and its unit tests are.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Populate is the program in Rust only. pkgs.populate checks its arguments,
and returns a script running the program with them as JSON. The
arguments it took for the shell implementation, dash, jq, and
implementation, stay accepted and unused, so overrides setting them keep
working.
Copying flakes to remote targets using sudo gets refused during
evaluation, as before, by checks.nix, and by the program for specs from
elsewhere.
The jq test goes with the jq programs; the program's unit tests cover
their equivalents.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
pkgs/populate/docs/design.md describes populate's parts, the program's
invocation, the spec, the checks, what populate prints, its safety
guarantees, how it runs commands, how to test changes, and what the
program does so far.
|