| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
| |
The unreleased changes become 2.0.0, which the README's minimal example
fetches already, and populate's version, which it prints and records in
.populate/run.json, is 2.0.0 too.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Each rsync run costs several round trips to the target, and about 45 ms
of rsync waiting for its own processes, also with nothing to transfer, so
a run with many file sources and nothing to change took long: 25.5 s for
the bench's 50 file, 30 symlink, and 20 git sources with 30 ms to the
target, 20 s of that waiting for round trips.
Right after taking the lock, one command lists the target paths of the
file sources that are directories, compared by size and time, and whose
lock file the flakes step doesn't rewrite, with find. At its turn, each
such source lists what rsync would transfer: with find, if nothing
excludes or filters anything, else with rsync --list-only, which is also
the run checking the .rsync-filter files, instead of a dry run. If both
listings have the same entries, with mode and path, and for files size and
time in whole seconds, and for symlinks the target, which is what rsync's
quick check compares, neither break_hard_links nor rsync runs. Entries
populate can't compare (paths with control characters, devices), and
sources that need --insecure-links, run rsync.
The scenario file-skip checks that an unchanged source keeps another hard
link of a file, which break_hard_links would break, and that a file too
many, a file's time, a directory's mode, and an excluded file make the
sources deliver again.
|
| |
|
|
|
|
|
|
|
|
| |
A source's type can depend on a condition, e.g. nixpkgs.file =
optionalSource local { ... }, which returns the settings if the condition
holds, and else null. A source whose types are all null, at least one of
them set to null rather than left unset, gets the type null, and evalSource
leaves it out. A type left unset, e.g. by lib.mkIf false, still counts as
missing, so an empty source stays an error. krops' lib provides
optionalSource, too.
|
| |
|
|
|
|
| |
populate runs grep and sed, for pass sources, Git work trees, and git
sources on local targets. pkgs.populate puts gnugrep and gnused into the
PATH it gives populate, so the caller's PATH doesn't need them.
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
writeDeploy, writeCommand, and writeTest pass target strings to
pkgs.populate as they are, so populate fills in what they leave out, and
decides whether the target is local, when it runs. runShell runs
populate shell, which decides that for running nixos-rebuild and
writeCommand's commands, so rebuild's unbuffer for local targets with
allocateTTY depends on $1, and runShell returns shell code, also for
remote targets. Target attribute sets get mkTarget's defaults and
whether they're local during evaluation, as before, unless that's pure:
then mkTarget leaves the user and the host null, instead of reading
/etc/hostname, which pure evaluation pretends doesn't exist, and
pkgs.populate and populate shell leave them, and whether the target is
local, to populate, which also refuses copying flakes to targets using
sudo then. writeTest checks that its target is local during evaluation,
unless that's pure, and with populate shell --local-only before
populating. writeDeploy needs a target's host for a separate
buildTarget in pure evaluation. pkgs/krops/target.nix has what
pkgs.populate and pkgs.krops need of targets.
pkgs.populate's derivations stay the same, for strings and attribute
sets. The deploy scenarios get target strings too, for the local and
the remote target, and so does the allocateTTY scenario.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
| |
krops' lib imported <nixpkgs/lib>, which pure evaluation doesn't allow,
and so did pkgs.krops and pkgs.populate, through it, also in krops'
flake. lib/with.nix is krops' own lib, a function taking nixpkgs' lib,
without merging it in. pkgs.krops and pkgs.populate use it with the lib
callPackage gives them, nixpkgs.lib in krops' flake, and lib/default.nix
is what it was: <nixpkgs/lib>, builtins, and krops' own lib, merged.
The derivations 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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
| |
What krops 1.31.1 has goes into a section of its own, the same as in
krops-1, leaving what's new in krops 2 unreleased.
|
| |
|
|
|
|
|
| |
git sources refused work trees with hooks, but populate's Git doesn't
run hooks, so git-foreign's work tree with a hook is fine to use, as it
expects. Only Nix's Git runs them, in a git+file: flake, so drawing
inputs refers to a work tree with hooks as path: instead.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Writing the lock file of a git+file: flake, Nix runs Git, with the
repository's configuration and hooks, which may run commands. A .git
in a source's directory can come from anywhere, e.g. one planted in a
materialized flake, or one a file source keeps. So drawing inputs
refers to a flake as git+file: only if git_problems finds nothing wrong
with its .git directory, the way git sources check their work trees,
and else as path:.
lock-foreign-git plants a .git in a materialized flake and in a file
source that keeps it, whose configuration names an fsmonitor command.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
git submodule update uses the .git of a submodule as it finds it in the
work tree: a repository of its own, with configuration that runs
commands, or a file naming a repository elsewhere. So git_problems
also requires each .git below the work tree to be a file naming a
repository in .git/modules. And it refuses hooks in .git/hooks, which
populate's Git doesn't run, but Nix's does, writing the lock file of a
flake in a git source.
git-submodule plants a submodule's .git in the work tree: a repository
of its own whose configuration names a filter, and a file naming a
repository elsewhere. The fixture withsub has gitsrc as its submodule
sub.
|
| |
|
|
|
|
|
|
|
|
| |
A git source's url and ref are strings, and git clone, git remote, and
git fetch took ones starting with - for options, e.g. --upload-pack,
which runs a command where the repository is local. They come after
-- now, and so does a pass source's name for git log and pass show.
git-ref-option gives a ref that git fetch would take for
--upload-pack.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
| |
With allocateTTY, nixos-rebuild runs with a terminal, so it shows colours
and progress: on remote targets, ssh gets -t, which allocates a terminal
if its own input is one, and on the local target, expect's unbuffer
provides one.
The nixos-rebuild stand-in records whether its output is a terminal.
|
| |
|
|
|
|
|
|
| |
A ref that consists of 4 to 40 hex digits is a commit, which populate
fetches only if the work tree lacks it, unless fetchAlways is set. Any
other ref is a branch or tag, which populate fetches on every run,
resetting the work tree to the commit fetched. Resetting to the name
itself resolves to a local branch, which fetching doesn't move.
|
| |
|