<?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=Flake_Compat</id>
	<title>Flake Compat - 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=Flake_Compat"/>
	<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Flake_Compat&amp;action=history"/>
	<updated>2026-05-29T23:32:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.nixos.org/w/index.php?title=Flake_Compat&amp;diff=21921&amp;oldid=prev</id>
		<title>Pigs: Add category flakes</title>
		<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Flake_Compat&amp;diff=21921&amp;oldid=prev"/>
		<updated>2025-06-01T18:03:36Z</updated>

		<summary type="html">&lt;p&gt;Add category flakes&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 18:03, 1 June 2025&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-l72&quot;&gt;Line 72:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 72:&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;br&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;br&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;With this setup, running &amp;lt;code&amp;gt;nix run&amp;lt;/code&amp;gt; will build and execute the flake as expected. When using flake-compat, it becomes possible to run traditional commands like &amp;lt;code&amp;gt;nix-build&amp;lt;/code&amp;gt; which will return a derivation using the flake’s output definitions.&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;With this setup, running &amp;lt;code&amp;gt;nix run&amp;lt;/code&amp;gt; will build and execute the flake as expected. When using flake-compat, it becomes possible to run traditional commands like &amp;lt;code&amp;gt;nix-build&amp;lt;/code&amp;gt; which will return a derivation using the flake’s output definitions.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Flakes]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key mediawiki:diff:1.41:old-21864:rev-21921:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Pigs</name></author>
	</entry>
	<entry>
		<id>https://wiki.nixos.org/w/index.php?title=Flake_Compat&amp;diff=21864&amp;oldid=prev</id>
		<title>Pigs: Create flake-compat page, move some content from the main flake page</title>
		<link rel="alternate" type="text/html" href="https://wiki.nixos.org/w/index.php?title=Flake_Compat&amp;diff=21864&amp;oldid=prev"/>
		<updated>2025-05-29T18:09:17Z</updated>

		<summary type="html">&lt;p&gt;Create flake-compat page, move some content from the main flake page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[https://github.com/edolstra/flake-compat Flake Compat] is a compatibility layer for Nix [[Flakes]] that lets projects written in the old style Nix (&amp;lt;code&amp;gt;default.nix&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;shell.nix&amp;lt;/code&amp;gt;) use inputs and outputs from flake style Nix setups.&lt;br /&gt;
&lt;br /&gt;
The flake-compat library downloads the inputs of the flake, pass them to the flake’s &amp;lt;code&amp;gt;outputs&amp;lt;/code&amp;gt; function and return an attribute set containing &amp;lt;code&amp;gt;defaultNix&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;shellNix&amp;lt;/code&amp;gt; attributes. The attributes will contain the output attribute set with an extra &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt; attribute pointing to current platform’s &amp;lt;code&amp;gt;defaultPackage&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;devShell&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;shellNix&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
To integrate flake-compat into a project, place the following into &amp;lt;code&amp;gt;default.nix&amp;lt;/code&amp;gt; (for &amp;lt;code&amp;gt;shell.nix&amp;lt;/code&amp;gt;, replace &amp;lt;code&amp;gt;defaultNix&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;shellNix&amp;lt;/code&amp;gt;) to use the shim:&lt;br /&gt;
&lt;br /&gt;
{{file|default.nix|nix|&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
(import&lt;br /&gt;
  (&lt;br /&gt;
    let&lt;br /&gt;
      lock = builtins.fromJSON (builtins.readFile ./flake.lock);&lt;br /&gt;
      nodeName = lock.nodes.root.inputs.flake-compat;&lt;br /&gt;
    in&lt;br /&gt;
    fetchTarball {&lt;br /&gt;
      url = lock.nodes.${nodeName}.locked.url or &amp;quot;https://github.com/edolstra/flake-compat/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz&amp;quot;;&lt;br /&gt;
      sha256 = lock.nodes.${nodeName}.locked.narHash;&lt;br /&gt;
    }&lt;br /&gt;
  )&lt;br /&gt;
  { src = ./.; }&lt;br /&gt;
).defaultNix&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Then in your &amp;lt;code&amp;gt;flake.nix&amp;lt;/code&amp;gt;, add &amp;lt;code&amp;gt;flake-compat.url = &amp;quot;github:edolstra/flake-compat&amp;quot;;&amp;lt;/code&amp;gt; to your inputs.&lt;br /&gt;
&lt;br /&gt;
== Example usage ==&lt;br /&gt;
&lt;br /&gt;
An example flake.nix that packages a simple shell script:&lt;br /&gt;
&lt;br /&gt;
{{file|flake.nix|nix|&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  description = &amp;quot;A very basic flake&amp;quot;;&lt;br /&gt;
  inputs = {&lt;br /&gt;
    nixpkgs.url = &amp;quot;github:nixos/nixpkgs?ref=nixos-unstable&amp;quot;;&lt;br /&gt;
    flake-compat.url = &amp;quot;github:edolstra/flake-compat&amp;quot;;&lt;br /&gt;
  };&lt;br /&gt;
  outputs = { self, nixpkgs, flake-compat }:&lt;br /&gt;
    let&lt;br /&gt;
      system = &amp;quot;x86_64-linux&amp;quot;;&lt;br /&gt;
      pkgs = import nixpkgs { inherit system; };&lt;br /&gt;
    in {&lt;br /&gt;
      packages.x86_64-linux.hello = pkgs.stdenv.mkDerivation {&lt;br /&gt;
        pname = &amp;quot;hello&amp;quot;;&lt;br /&gt;
        version = &amp;quot;1.0&amp;quot;;&lt;br /&gt;
        src = ./hello.sh;&lt;br /&gt;
        unpackPhase = &amp;quot;true&amp;quot;;&lt;br /&gt;
        installPhase = &amp;#039;&amp;#039;&lt;br /&gt;
          mkdir -p $out/bin&lt;br /&gt;
          cp $src $out/bin/hello&lt;br /&gt;
          chmod +x $out/bin/hello&lt;br /&gt;
        &amp;#039;&amp;#039;;&lt;br /&gt;
      };&lt;br /&gt;
      packages.x86_64-linux.default = self.packages.x86_64-linux.hello;&lt;br /&gt;
    };&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The shell script being packaged:&lt;br /&gt;
&lt;br /&gt;
{{file|hello.sh|nix|&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/usr/bin/env sh&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Hello&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
With this setup, running &amp;lt;code&amp;gt;nix run&amp;lt;/code&amp;gt; will build and execute the flake as expected. When using flake-compat, it becomes possible to run traditional commands like &amp;lt;code&amp;gt;nix-build&amp;lt;/code&amp;gt; which will return a derivation using the flake’s output definitions.&lt;/div&gt;</summary>
		<author><name>Pigs</name></author>
	</entry>
</feed>