Skip to content

Add the script nix-run - #153

Closed
rickynils wants to merge 1 commit into
NixOS:masterfrom
rickynils:master
Closed

rickynils wants to merge 1 commit into
NixOS:masterfrom
rickynils:master

Conversation

@rickynils

Copy link
Copy Markdown
Member

nix-run is a convenience script that builds an expression with nix-build
and then automatically executes the build result. If the result is not an
executable file, nix-run outputs an error message.

nix-run is a convenience script that builds an expression with nix-build
and then automatically executes the build result. If the result is not an
executable file, nix-run outputs an error message.
@edolstra

Copy link
Copy Markdown
Member

Hm, not sure if this is very useful... I mean, this is just "nix-build ... && ./result" right? (And how often is $out itself a script?)

@rickynils

Copy link
Copy Markdown
Member Author

@edolstra Yes, this is basically just a way of running ./result automatically. For some reason, I have been doing this over and over again lately, though. It avoids a lot of profile pollution by nix-env -i. For example you can define myenvs like this:

with (import <nixpkgs> {});

let
  mkEnvLoader = attrs: let e = myEnvFun {
    inherit (attrs) name buildInputs;
  }; in writeScript "e" "exec ${e}/bin/load-env-${attrs.name}";
in {
  gcc = mkEnvLoader {
    name = "gcc";
    buildInputs = [ gcc gnumake ];
  };
  llvm = mkEnvLoader {
    name = "llvm";
    buildInputs = [ llvm ];
  };
}

Then simply do this to activate a specific environment:

$ nix-run -A llvm myenvs.nix

Each time you run nix-run you get an updated environment without having to do nix-env -i.

Of course, this is a very simple tool, and it doesn't have to be put in the Nix distribution. I can submit it to nixpkgs if you think it is a better idea.

@rickynils rickynils closed this Nov 5, 2013
zolodev pushed a commit to zolodev/nix that referenced this pull request Jan 1, 2024
ConnorBaker pushed a commit to ConnorBaker/nix that referenced this pull request Jul 25, 2025
…94fb5ba-acbd-46c2-b441-796aa671a07b

Release v3.8.3
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 24, 2026
Landed 18 commits across 6 shards covering 20 candidates:
- libstore +8 (NixOS#1+NixOS#3, NixOS#7, NixOS#11, NixOS#55, NixOS#59, NixOS#101, NixOS#153, NixOS#185)
- libexpr +3 covering 4 (NixOS#192, NixOS#202+NixOS#203 folded, NixOS#204)
- libutil +4 (NixOS#97, NixOS#124, NixOS#167, NixOS#224)
- libfetchers +1 (NixOS#53)
- libflake +1 (NixOS#133, rename only — deviation documented)
- libmain +1 (NixOS#223; NixOS#222 already on branch)

Skipped: NixOS#76 (libc++ in dev shell lacks <generator>) and several
RED-bucket items.

4-pass review chain: Pass A (parallel adversarial) caught 2
BLOCKERS — libstore NixOS#153 over-broad rename corrupted the
external-builders JSON wire-key, and libutil NixOS#97 dropped the
inline allowed-name list breaking eval-fail-hashString-2.err.exp.
Both fixed via amend; parseEnumOrThrow extended to render
'a', 'b', or 'c' with Oxford comma + suggestions. Pass B
(/code-review) found no blockers; substantive amends include
libexpr's callFunction hot-path now reading a ctor-frozen
profilerHooks snapshot, libstore's tryUpperFallLower returning
std::pair<R, bool>, libutil completing three migration gaps.
Pass C found one real clang-tidy error (parse-enum.hh missing
configuration.hh include); other shards only show the 5 known
pre-existing master errors. Pass D nix build -L . green on all
six shards.

New catalog candidates surfaced by review: NixOS#225 (libfetchers
getUserRegistry/getSystemRegistry/getGlobalRegistry share NixOS#53's
first-call-wins shape on the hot path), NixOS#226 (showCompressionAlgo
vs printHashAlgo enum-rendering inconsistency).

Catalog total: 226 + 44.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 24, 2026
`class DerivationBuilderImpl : public DerivationBuilder, public DerivationBuilderParams`
inherited from `DerivationBuilderParams` purely to make the params
fields visible to member-name lookup inside the class body. The params
provide no virtual surface — they are a data bag — so the inheritance
just leaked the param fields (`drv`, `drvPath`, `drvOptions`,
`inputPaths`, `initialOutputs`, `buildMode`, `defaultPathsInChroot`,
`systemFeatures`, `desugaredEnv`, `buildResult`) into the class's
public/protected name-lookup. Hold a `DerivationBuilderParams params`
member instead and rewrite every member-name access to `params.X`.

Six subclasses are defined across `chroot-/linux-/freebsd-/darwin-/
external-derivation-builder.cc` (each `#include`d into
derivation-builder.cc), counting `ChrootLinuxDerivationBuilder` as a
distinct subclass: their bodies that reference these fields are
rewritten the same way. `freebsd-derivation-builder.cc` accesses none
of the renamed fields and is unchanged. `chroot-derivation-builder.cc::
prepareSandbox` declared a local `BuildChrootParams params{...}` that
would now shadow the class member; renamed it to `chrootParams` to
keep the class member visible after the local's declarator.

Refs candidate NixOS#153.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 25, 2026
`class DerivationBuilderImpl : public DerivationBuilder, public DerivationBuilderParams`
inherited from `DerivationBuilderParams` purely to make the params
fields visible to member-name lookup inside the class body. The params
provide no virtual surface — they are a data bag — so the inheritance
just leaked the param fields (`drv`, `drvPath`, `drvOptions`,
`inputPaths`, `initialOutputs`, `buildMode`, `defaultPathsInChroot`,
`systemFeatures`, `desugaredEnv`, `buildResult`) into the class's
public/protected name-lookup. Hold a `DerivationBuilderParams params`
member instead and rewrite every member-name access to `params.X`.

Six subclasses are defined across `chroot-/linux-/freebsd-/darwin-/
external-derivation-builder.cc` (each `#include`d into
derivation-builder.cc), counting `ChrootLinuxDerivationBuilder` as a
distinct subclass: their bodies that reference these fields are
rewritten the same way. `freebsd-derivation-builder.cc` accesses none
of the renamed fields and is unchanged. `chroot-derivation-builder.cc::
prepareSandbox` declared a local `BuildChrootParams params{...}` that
would now shadow the class member; renamed it to `chrootParams` to
keep the class member visible after the local's declarator.

Refs candidate NixOS#153.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
angerman added a commit to angerman/nix that referenced this pull request Aug 5, 2026
… executable form

Build plan for Change 4 (the second surviving lever; NixOS#137 RCA'd it: narrows the
warm gap 2.49x ff/1.83x M5 to ~1.5-2.2x, doesn't beat TW alone -> sequenced AFTER
HAMT).  Foundations J0-J3 proven standalone (research/jit_*.cc).

De-risking insight (same shape as the HAMT GC plan): the J3 crux — JIT'd native
code must spill live v3 pointers at allocation safepoints so the moving scavenger
finds/updates them — maps onto the PROVEN GcRoot/walkAllV3Roots mechanism
(precise_root.cc:196 already scans Values registered via GcRoot from C++ frames).
A JIT'd frame maintains a shadow live-Value list enumerated by walkAllV3Roots;
no new GC-root theory, mirror GcRoot.

Steps: NixOS#152 real-scavenger safepoint spill (shadow frame + register with
walkAllV3Roots); NixOS#153 value-stack ABI trampoline + hot-callCount compile trigger +
deopt/bail (small opcode subset first, grow behind byte-id); NixOS#154 validate
(byte-id + --brute under 1MB-nursery moving-GC stress with ALLOCATING JIT'd bodies
= exercises the spill crux) + darwin-4 measure + ship behind NIX_V3_JIT.  Must
cover allocating bodies (pure-arith = gaming, forbidden).

Both real levers (HAMT NixOS#1, JIT NixOS#2) now blueprinted to executable form; both
multi-week, gated.

lode/C4_JIT_BUILD_PLAN_2026-06-23.md.

Copyright (c) 2026 Moritz Angermann <[email protected]>, Input Output
Group. SPDX-License-Identifier: Apache-2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants