<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.nixos.org/w/index.php?action=history&amp;feed=atom&amp;title=Build_Helpers</id>
	<title>Build Helpers - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.nixos.org/w/index.php?action=history&amp;feed=atom&amp;title=Build_Helpers"/>
	<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Build_Helpers&amp;action=history"/>
	<updated>2026-05-10T05:38:29Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.0</generator>
	<entry>
		<id>https://wiki.nixos.org/w/index.php?title=Build_Helpers&amp;diff=17881&amp;oldid=prev</id>
		<title>Frontear: minor update to syntax</title>
		<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Build_Helpers&amp;diff=17881&amp;oldid=prev"/>
		<updated>2024-10-17T02:38:55Z</updated>

		<summary type="html">&lt;p&gt;minor update to syntax&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:38, 17 October 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l25&quot;&gt;Line 25:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 25:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   derivationArgs.nativeBuildInputs = [ sassc ];&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   derivationArgs.nativeBuildInputs = [ sassc ];&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;} &amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;} &amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   mkdir -p $out&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;/&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   mkdir -p $out&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   sassc ${./style.scss} $out/style.css&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   sassc ${./style.scss} $out/style.css&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Frontear</name></author>
	</entry>
	<entry>
		<id>https://wiki.nixos.org/w/index.php?title=Build_Helpers&amp;diff=17880&amp;oldid=prev</id>
		<title>Frontear: Created page with &quot;Nixpkgs hosts a number of simple functions called &quot;build helpers&quot;, that are commonly used as part of a larger derivation, such as stdenv.mkDerivation. These helpers can be used part of a larger derivation, or to produce a simple derivation that doesn&#039;t need the full power of the standard environment.  === Trivial Build Helpers === {{Expansion|Doesn&#039;t cover all builders, see: https://nixos.org/manual/nixpkgs/unstable/#part-builders}}  ==== runCommandWi...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Build_Helpers&amp;diff=17880&amp;oldid=prev"/>
		<updated>2024-10-17T02:36:35Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/wiki/Nixpkgs&quot; title=&quot;Nixpkgs&quot;&gt;Nixpkgs&lt;/a&gt; hosts a number of simple functions called &amp;quot;build helpers&amp;quot;, that are commonly used as part of a larger derivation, such as &lt;a href=&quot;/wiki/Derivations&quot; title=&quot;Derivations&quot;&gt;stdenv.mkDerivation&lt;/a&gt;. These helpers can be used part of a larger derivation, or to produce a simple derivation that doesn&amp;#039;t need the full power of the standard environment.  === Trivial Build Helpers === {{Expansion|Doesn&amp;#039;t cover all builders, see: https://nixos.org/manual/nixpkgs/unstable/#part-builders}}  ==== runCommandWi...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Nixpkgs]] hosts a number of simple functions called &amp;quot;build helpers&amp;quot;, that are commonly used as part of a larger derivation, such as [[Derivations|stdenv.mkDerivation]]. These helpers can be used part of a larger derivation, or to produce a simple derivation that doesn&amp;#039;t need the full power of the standard environment.&lt;br /&gt;
&lt;br /&gt;
=== Trivial Build Helpers ===&lt;br /&gt;
{{Expansion|Doesn&amp;#039;t cover all builders, see: https://nixos.org/manual/nixpkgs/unstable/#part-builders}}&lt;br /&gt;
&lt;br /&gt;
==== runCommandWith ====&lt;br /&gt;
An extremely simple derivation that runs a series of shell commands as part of the build-step. It would be accurate to consider this as a fancy wrapper around installPhase.&lt;br /&gt;
&lt;br /&gt;
This function accepts two arguments, an attribute set and a string. The attribute set is defined as:&lt;br /&gt;
&lt;br /&gt;
# name: The derivation name, exactly like a standard Nix derivation.&lt;br /&gt;
# stdenv (default: &amp;lt;code&amp;gt;pkgs.stdenv&amp;lt;/code&amp;gt;): Define the standard environment used&lt;br /&gt;
# runLocal (default: &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;): Prevents the usage of substituters and/or remote builders; forces local builds only.&lt;br /&gt;
# derivationArgs (default: &amp;lt;code&amp;gt;{}&amp;lt;/code&amp;gt;): Additional arguments passed directly into an internal &amp;lt;code&amp;gt;mkDerivation&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The string represents a series of shell commands to execute when building this derivation. These must generate an &amp;lt;code&amp;gt;$out&amp;lt;/code&amp;gt;, much like a standard derivation.&lt;br /&gt;
&lt;br /&gt;
A common use case for this type of builder is when you&amp;#039;re copying files into the store. You can get quite creative and use this to transform those files as they become part of the store, leaving you with the final, transformed file output.&amp;lt;syntaxhighlight lang=&amp;quot;nix&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  runCommandWith,&lt;br /&gt;
  sassc,&lt;br /&gt;
}:&lt;br /&gt;
runCommandWith {&lt;br /&gt;
  name = &amp;quot;sass-to-css&amp;quot;;&lt;br /&gt;
  derivationArgs.nativeBuildInputs = [ sassc ];&lt;br /&gt;
} &amp;#039;&amp;#039;&lt;br /&gt;
  mkdir -p $out/&lt;br /&gt;
  sassc ${./style.scss} $out/style.css&lt;br /&gt;
&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Nixpkgs provides a few higher-level entry points for this builder. All of these functions accept a name, and an attribute set that maps to &amp;lt;code&amp;gt;derivationArgs&amp;lt;/code&amp;gt; for the above. This simpler signature makes them more suitable for use as compared to &amp;lt;code&amp;gt;runCommandWith&amp;lt;/code&amp;gt;, and should be preferred unless you know you need &amp;lt;code&amp;gt;runCommandWith&amp;lt;/code&amp;gt; directly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;runCommand&amp;lt;/code&amp;gt;: sets &amp;lt;code&amp;gt;stdenv = pkgs.stdenvNoCC&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;runCommandCC&amp;lt;/code&amp;gt;: completely default &amp;lt;code&amp;gt;runCommandWith&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;runCommandLocal&amp;lt;/code&amp;gt;: sets &amp;lt;code&amp;gt;runLocal = true&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are a couple other aliases that aren&amp;#039;t used very often, but will be listed here anyways as an exhaustive reference:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;runCommandNoCC&amp;lt;/code&amp;gt;: identical to &amp;lt;code&amp;gt;runCommand&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;runCommandNoCCLocal&amp;lt;/code&amp;gt;: identical to &amp;lt;code&amp;gt;runCommandLocal&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Frontear</name></author>
	</entry>
</feed>