Giter Club home page Giter Club logo

firstaide's People

Contributors

allenap avatar mavnn avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

mavnn noredink

firstaide's Issues

Maybe require direnv 2.21.2 or newer

2.20.x seems to have some weird behaviour that's confusing and results in broken environments.

Perhaps give advice to users along the lines of:

direnv is too old (2.20.2); upgrade to 2.21.2 or later.
Nix: `nix-channel --update && nix-env --install direnv && nix-env --upgrade direnv`
Homebrew: `brew update && brew install direnv && brew upgrade direnv`

Work with NIX_CONF_DIR

Nix itself doesn't have a story for saying "I want some project specific options", but firstaide could do something useful with NIX_CONF_DIR to make it work.

Quick idea: firstaide could write out a nix.conf in some situations:

Global NIX_CONF_DIR Project-specific NIX_CONF_DIR What do to
unset unset Nothing
unset project/etc Write new nix.conf: include /etc/nix, include project/etc
/some/thing unset Nothing
/some/thing project/etc Write new nix.conf: include /some/thing, include project/etc

Why include /etc/nix? From nix.conf(5): 'this is the "system-wide configuration file sysconfdir/nix/nix.conf'. It doesn't seem possible or at least obvious how to find out what Nix's notion of sysconfdir is, so we assume it's /etc for now.

Cache recently used environments

We can probably cache recently-used environments based on dependency checksums (i.e. of those files yielded from watch_exe). This might make life easier when switching branches.

Get GC working with Nix shells

Nix shells and GC equals frustration. Below are my notes so far. I've managed to find a 95% solution or something like that; see DO THIS ONE.

    // 3c. Capture the environment's closure to prevent GC.
    // nix-build --no-out-link stuff.nix | xargs -r nix-store -qR | \
    //   xargs -r nix-store --realise --add-root _build/firstaide/gc/$random --indirect
    // log::info!("Capture closure of inside environment to prevent GC.");
    // let gcroot_dir = &config.cache_dir.join("gc");
    // fs::create_dir(gcroot_dir)?;
    // let gcroot_output = process::Command::new("nix-build")
    //     .current_dir(&config.build_dir)
    //     .arg("--no-out-link")
    //     .arg("stuff.nix")
    //     .stdin(process::Stdio::null())
    //     .stdout(process::Stdio::piped())
    //     .stderr(process::Stdio::inherit())
    //     .output()?;
    // let gcroot_inputs: Vec<&[u8]> = gcroot_output.stdout.fields().collect();

    // Another approach?
    //   nix-instantiate shell.nix --add-root gc/shell --indirect
    //   nix-store -r gc/shell --add-root gc/root --indirect


    // An approach that seems to work:  *** DO THIS ONE ***
    //   nix-instantiate shell.nix --add-root _build/firstaide/shell --indirect
    //   nix-shell _build/firstaide/shell --run 'firstaide env ...'
    //   ALSO: Check that user has `keep-outputs` enabled. <-- IMPORTANT

    // 3c. Add a GC root for this environment. This alone is not enough to
    // ensure that the environment and its constituents are not garbage
    // collected – Nix does *not* make this easy – but if we also check if users
    // have `keep-outputs` enabled in their configuration then we're fairly
    // close: Nix will only think it needs to GC a couple of dozen packages.

    log::info!("Capture closure of inside environment to prevent GC.");
    let gcroot_dir = &config.cache_dir.join("gc");
    fs::create_dir(gcroot_dir)?;
    let gcroot_output = process::Command::new("nix-build")
        .current_dir(&config.build_dir)
        .arg("--no-out-link")
        .arg("stuff.nix")
        .stdin(process::Stdio::null())
        .stdout(process::Stdio::piped())
        .stderr(process::Stdio::inherit())
        .output()?;
    let gcroot_inputs: Vec<&[u8]> = gcroot_output.stdout.fields().collect();

    
    // let gcroot_dir = tempfile::TempDir::new_in(
    // let gcroot_path = temp_path.join("inside");
    // let mut dump_cmd = config.command_to_dump_env_inside(&dump_path, &env_outside);
    // log::debug!("{:?}", dump_cmd);
    // let mut dump_proc = dump_cmd.spawn()?;
    // if !dump_proc.wait()?.success() {
    //     return Err(Error::EnvInsideCapture);
    // }
    // match bincode::deserialize(&fs::read(dump_path)?) {
    //     Ok(env) => Ok(env),
    //     Err(err) => Err(Error::EnvInsideDecode(err)),
    // }

Add a DWIM command and make it the default

I wonder if it's possible to have a firstaide dwim command (that Does What I Mean) that's also the default when firstaide is invoked without arguments:

  • At the terminal, firstaide [dwim] -> firstaide build.
  • In .envrc, firstaide [dwim] -> firstaide hook.

Call watch_file with multiple arguments.

Calling watch_file in direnv is slow, about 7-8ms per call for a single file.

However, we insist on direnv 2.20.1 (see check_direnv_version) which has an implementation of watch_file that can take multiple arguments. This is much faster: adding ~50 watches can take as little as 12ms.

We should do that.

Add an exec command

firstaide exec -- some-command --with-args should ensure a built environment then exec some-command --with-args inside that environment, using the cache if possible of course.

Logging is too verbose

Maybe hide DEBUG logs for now, allow INFO, but add --verbose and --quiet flags to change it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.