Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

lorri daemon #81

Merged
merged 43 commits into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
899ea5c
Add socket::ReadWriter for socket communication.
Profpatsch Apr 29, 2019
2f69cbf
Add socket/communicate.rs: A way to communicate with a lorri daemon.
Profpatsch May 13, 2019
70e7b5e
Add a ping command and a daemon that accepts the ping
Profpatsch May 14, 2019
4664e8a
Loop the daemon forever.
Profpatsch May 14, 2019
e51dfff
Implement a `Daemon` struct that can start build_loops
Profpatsch May 14, 2019
2f91f8f
Don't retrigger a build if it is already in the loop
grahamc May 9, 2019
fa3cea1
Implement a lame error message if the socket is not listening
grahamc May 9, 2019
88ccc54
tests/daemon: Add test sending a message over socket
Profpatsch May 14, 2019
0782aff
pre-check.sh: explicitely set XDG_CACHE_DIR
Profpatsch May 16, 2019
c6b1881
socket: Borrow `UnixStream` for `ReadWriter`
Profpatsch May 22, 2019
2ed083a
socket: make `Timeout` a an enum (instead of type alias)
Profpatsch May 22, 2019
5d98022
socket/ReadWriter: add react()
Profpatsch May 27, 2019
7800885
socket/communicate: Move to ReadWriter for everything
Profpatsch May 27, 2019
1157329
socket/Timeout: move from Duration to u16
Profpatsch May 27, 2019
fc35cd5
socket/ReadWriter: move timeout logic to a `poll(2)` syscall
Profpatsch May 27, 2019
1ffdc28
socket: slight documentation fixes
Profpatsch May 27, 2019
9b2ef64
daemon: Ensure that only one process is listening on a socket.
Profpatsch May 29, 2019
6da130b
ExitError: remove Err wrapping
Profpatsch May 29, 2019
461d19e
daemon: Display error message when binding to locked socket
Profpatsch May 29, 2019
b346b37
daemon: factor out static socket string
Profpatsch May 29, 2019
4fd565e
project: Move gc_path constant to new constants module
Profpatsch Jun 5, 2019
162fce8
Move GC roots from `~/.cache/lorri` to `~/.cache/lorri/gc_roots`
Profpatsch Jun 5, 2019
fcd0588
constants, daemon: Move daemon socket to cache dir
Profpatsch Jun 5, 2019
778305d
constants/Paths: create directories if they don’t exist
Profpatsch Jun 6, 2019
a3e2052
ops/daemon: move `Daemon` struct into `daemon` module
Profpatsch Jun 6, 2019
52034e6
project: rename `shell_nix` to `nix_file`
Profpatsch Jun 6, 2019
c7e2873
project: remove `.name()` and rename `.id()` to `.hash()`
Profpatsch Jun 6, 2019
4ca9c4a
Move ops/info and ops/init to plain rust files
Profpatsch Jun 6, 2019
070cb99
roots: Remove `new()` because unused
Profpatsch Jun 6, 2019
e90deb8
Add `NixFile` newtype to distinguish from other `PathBuf`s
Profpatsch Jun 7, 2019
4bb7bc3
project/Project: remove `project_root` field
Profpatsch Jun 7, 2019
31c5a06
project/Project.from_cwd: move gc_root out to call site
Profpatsch Jun 7, 2019
ecea7b4
project/Project: make a shallow wrapper
Profpatsch Jun 7, 2019
614793f
daemon: Set default message socket read timeout of 1000ms
Profpatsch Jun 7, 2019
395a4a9
default.nix: fix cargoSha256
Profpatsch Jun 7, 2019
02f9fef
socket/communicate: introduce a DEFAULT_READ_TIMEOUT
Profpatsch Jun 7, 2019
28be34a
main.rs: `daemon` subcommand doesn’t require a shell.nix in cwd
Profpatsch Jun 19, 2019
17e303d
cli.rs: add documentation to `Daemon` and `Ping`
Profpatsch Jun 19, 2019
12a0551
cli.rs: postfix `Ping` with `_` to indicate it’s plumbing
Profpatsch Jun 19, 2019
ee70572
socket/communicate: more declarative names for PhantomData fields
Profpatsch Jun 19, 2019
9150ed3
constants/Paths: move daemon socket to the runtime dir if possible
Profpatsch Jun 19, 2019
5dc0a56
daemon/StartBuild: rename to IndicateActivity
Profpatsch Jun 20, 2019
40dc0d3
ops/direnv: improve error message for missing shell.nix
Profpatsch Jun 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 57 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ notify = "4.0.6"
serde = "1.0.88"
serde_derive = "1.0.88"
serde_json = "1.0.38"
bincode = "1.1.3"
tempfile = "3.0.7"
vec1 = "1.1.0"
proptest = "0.9.1"
nix = "0.14.0"
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pkgs.rustPlatform.buildRustPackage rec {
BUILD_REV_COUNT = src.revCount or 1;
RUN_TIME_CLOSURE = pkgs.callPackage ./nix/runtime.nix {};

cargoSha256 = "0lx4r05hf3snby5mky7drbnp006dzsg9ypsi4ni5wfl0hffx3a8g";
cargoSha256 = "094w2lp6jvxs8j59cjqp6b3kg4y4crlnqka5v2wmq4j0mn6hvhsj";

NIX_PATH = "nixpkgs=${./nix/bogus-nixpkgs}";

Expand Down
3 changes: 3 additions & 0 deletions nix/pre-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ TEST_ROOT_DEST=${TMPDIR:-/tmp}/nix-test/nix
mkdir -p $TEST_ROOT_DEST
TEST_ROOT=$(realpath $TEST_ROOT_DEST)

# prevent us from creating $HOME if it doesn’t exist
export XDG_CACHE_HOME=${TMPDIR:-/tmp}/nix-test/xdg-cache-dir

export NIX_STORE_DIR=$TEST_ROOT/store
mkdir -p $NIX_STORE_DIR
export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
Expand Down
9 changes: 8 additions & 1 deletion release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
package = import ./default.nix { inherit src; };

changelog = {
# Find the current version number with `git log --prety=%h | wc -l`
# Find the current version number with `git log --pretty=%h | wc -l`
entries = [
{
version = 171;
changes = ''
gc_root dirs move from `~/.cache/lorri` to `~/.cache/lorri/gc_roots`.
You can delete every file in `~/.cache/lorri`.
'';
}
{
version = 132;
changes = ''
Expand Down
5 changes: 3 additions & 2 deletions src/build_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::pathreduction::reduce_paths;
use crate::roots;
use crate::roots::Roots;
use crate::watch::Watch;
use crate::NixFile;
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::mpsc::Sender;
Expand Down Expand Up @@ -44,7 +45,7 @@ pub struct BuildExitFailure {
/// Additionally, we create GC roots for the build results.
pub struct BuildLoop {
/// A nix source file which can be built
nix_root_path: PathBuf,
nix_root_path: NixFile,
roots: Roots,
/// Watches all input files for changes.
/// As new input files are discovered, they are added to the watchlist.
Expand All @@ -54,7 +55,7 @@ pub struct BuildLoop {
impl BuildLoop {
/// Instatiate a new BuildLoop. Uses an internal filesystem
/// watching implementation.
pub fn new(nix_root_path: PathBuf, roots: Roots) -> BuildLoop {
pub fn new(nix_root_path: NixFile, roots: Roots) -> BuildLoop {
BuildLoop {
nix_root_path,
roots,
Expand Down
6 changes: 4 additions & 2 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ use std::io::{BufRead, BufReader};
use std::path::PathBuf;
use std::process::{Command, Stdio};
use std::thread;
use NixFile;

/// Builds the Nix expression in `root_nix_file`.
///
/// Instruments the nix file to gain extra information,
/// which is valuable even if the build fails.
pub fn run(root_nix_file: &PathBuf) -> Result<Info, Error> {
pub fn run(root_nix_file: &NixFile) -> Result<Info, Error> {
// We're looking for log lines matching:
//
// copied source '...' -> '/nix/store/...'
Expand All @@ -32,6 +33,7 @@ pub fn run(root_nix_file: &PathBuf) -> Result<Info, Error> {

cmd.args(&[
"-vv",
// TODO: we should pass this as a file instead of a 12k argv string
"--expr",
include_str!("./logged-evaluation.nix"),
"--no-out-link",
Expand All @@ -41,7 +43,7 @@ pub fn run(root_nix_file: &PathBuf) -> Result<Info, Error> {
"--argstr",
"src",
])
.arg(root_nix_file)
.arg(root_nix_file.as_os_str())
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
Expand Down
Loading