This commit is contained in:
Amy de Buitléir 2025-08-19 22:25:58 +01:00
parent aa6f39042a
commit d3186b9494
3 changed files with 2278 additions and 2254 deletions

View file

@ -2910,7 +2910,7 @@ don&#8217;t need to <code>git push</code> the changes until we&#8217;re ready to
<div class="literalblock">
<div class="content">
<pre class="nowrap">$ git commit hello-flake flake.nix -m 'added bovine feature'
[main 415788f] added bovine feature
[main ace77a6] added bovine feature
2 files changed, 7 insertions(+), 1 deletion(-)
$ nix run
________________________
@ -3434,6 +3434,7 @@ repo before building or running the flake.</p>
<pre class="nowrap">$ git add flake.nix hello-flake-haskell.cabal LICENSE Main.hs
$ nix run
warning: Git tree '/home/amy/codeberg/nix-book/source/new-flake/haskell-flake/hello-haskell' is dirty
unpacking 'github:nixos/nixpkgs/b6b47963d86aca847fe9754627b1f20f5fd0181d' into the Git cache...
warning: creating lock file '"/home/amy/codeberg/nix-book/source/new-flake/haskell-flake/hello-haskell/flake.lock"':
• Added input 'flake-parts':
'github:hercules-ci/flake-parts/af66ad14b28a127c5c0f3bbb298218fc63528a18?narHash=sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8%3D' (2025-08-06)
@ -3442,7 +3443,7 @@ warning: creating lock file '"/home/amy/codeberg/nix-book/source/new-flake/haske
• Added input 'haskell-flake':
'github:srid/haskell-flake/4bed0d0db1b5ae4e50cf4f1373fdf68d9c070517?narHash=sha256-lsEcVlgd6Xck%2B0pOmtEL93b138Tg8g6xTFg4fZ3YZ30%3D' (2025-08-18)
• Added input 'nixpkgs':
'github:nixos/nixpkgs/a650b5d0de99158323597f048667c4d914243224?narHash=sha256-ixn50x9Qoh9RNpG3LGhTI86GioR9GkGxR4%2Bj/Ttj0uE%3D' (2025-08-15)
'github:nixos/nixpkgs/b6b47963d86aca847fe9754627b1f20f5fd0181d?narHash=sha256-WujRF%2B1SX5f1tvU9n6LWU1E6gzTuwdj%2BHk7Q4dpZpU0%3D' (2025-08-16)
warning: Git tree '/home/amy/codeberg/nix-book/source/new-flake/haskell-flake/hello-haskell' is dirty
Hello from Haskell inside a Nix flake!
Your hostname is: wombat11k</pre>
@ -3458,7 +3459,7 @@ repo, and commit all important files.</p>
<div class="content">
<pre class="nowrap">$ git add flake.lock
$ git commit -a -m 'initial commit'
[master (root-commit) 39979dd] initial commit
[master (root-commit) 10cb39e] initial commit
5 files changed, 136 insertions(+)
create mode 100644 LICENSE
create mode 100644 Main.hs
@ -3475,6 +3476,11 @@ another directory and running it from there.</p>
<div class="content">
<pre class="nowrap">$ cd ..
$ nix run ./hello-haskell
these 2 derivations will be built:
/nix/store/xppgrz534x2ly7wwbdynmcdhl9336zpd-hello-flake-haskell-source-1.0.0.drv
/nix/store/25xy4dr33zfnwa6rygnrhjpzrzxb2qja-hello-flake-haskell-1.0.0.drv
building '/nix/store/xppgrz534x2ly7wwbdynmcdhl9336zpd-hello-flake-haskell-source-1.0.0.drv'...
building '/nix/store/25xy4dr33zfnwa6rygnrhjpzrzxb2qja-hello-flake-haskell-1.0.0.drv'...
Hello from Haskell inside a Nix flake!
Your hostname is: wombat11k</pre>
</div>
@ -3503,9 +3509,10 @@ Haskell flake.</p>
<div class="literalblock">
<div class="content">
<pre class="nowrap">$ mkdir hello-python
mkdir: cannot create directory hello-python: File exists
$ cd hello-python
$ git init
Initialized empty Git repository in /home/amy/codeberg/nix-book/source/new-flake/python-flake/hello-python/.git/</pre>
Reinitialized existing Git repository in /home/amy/codeberg/nix-book/source/new-flake/python-flake/hello-python/.git/</pre>
</div>
</div>
<div class="sect3">
@ -3830,11 +3837,17 @@ something like this.</p>
<div class="literalblock">
<div class="content">
<pre class="nowrap">$ nix run
error: Path 'flake.nix' in the repository "/home/amy/codeberg/nix-book/source/new-flake/python-flake/hello-python" is not tracked by Git.
To make it visible to Nix, run:
git -C "/home/amy/codeberg/nix-book/source/new-flake/python-flake/hello-python" add "flake.nix"</pre>
warning: Git tree '/home/amy/codeberg/nix-book/source/new-flake/python-flake/hello-python' is dirty
unpacking 'github:NixOS/nixpkgs/d22d5405986cd78dbdcf9be2b5d5bb4915e4210c' into the Git cache...
warning: creating lock file '"/home/amy/codeberg/nix-book/source/new-flake/python-flake/hello-python/flake.lock"':
• Added input 'flake-utils':
'github:numtide/flake-utils/11707dc2f618dd54ca8739b309ec4fc024de578b?narHash=sha256-l0KFg5HjrsfsO/JpG%2Br7fRrqm12kzFHyUHqHCVpMMbI%3D' (2024-11-13)
• Added input 'flake-utils/systems':
'github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e?narHash=sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768%3D' (2023-04-09)
• Added input 'nixpkgs':
'github:NixOS/nixpkgs/d22d5405986cd78dbdcf9be2b5d5bb4915e4210c?narHash=sha256-NWulbT/q4nDBiqWt4V6FDHB/4wcVV70q4ULIDYes4U4%3D' (2025-08-19)
warning: Git tree '/home/amy/codeberg/nix-book/source/new-flake/python-flake/hello-python' is dirty
Hello from inside a Python program built with a Nix flake!</pre>
</div>
</div>
<div class="paragraph">
@ -3847,14 +3860,9 @@ repo before building or running the flake.</p>
<pre class="nowrap">$ git add flake.nix setup.py hello.py
$ nix run
warning: Git tree '/home/amy/codeberg/nix-book/source/new-flake/python-flake/hello-python' is dirty
warning: creating lock file '"/home/amy/codeberg/nix-book/source/new-flake/python-flake/hello-python/flake.lock"':
• Added input 'flake-utils':
'github:numtide/flake-utils/11707dc2f618dd54ca8739b309ec4fc024de578b?narHash=sha256-l0KFg5HjrsfsO/JpG%2Br7fRrqm12kzFHyUHqHCVpMMbI%3D' (2024-11-13)
• Added input 'flake-utils/systems':
'github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e?narHash=sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768%3D' (2023-04-09)
• Added input 'nixpkgs':
'github:NixOS/nixpkgs/375ab11873f71477e1e9afc240dd815d00ce05bf?narHash=sha256-WB8bx4RyG1hjt49/yafemlpImojvq/vWpVQFW0/DVjI%3D' (2025-08-19)
warning: Git tree '/home/amy/codeberg/nix-book/source/new-flake/python-flake/hello-python' is dirty
this derivation will be built:
/nix/store/ja37v0cwhw7pyiwxabn7gb1mdimy423y-hello-flake-python.drv
building '/nix/store/ja37v0cwhw7pyiwxabn7gb1mdimy423y-hello-flake-python.drv'...
Hello from inside a Python program built with a Nix flake!</pre>
</div>
</div>
@ -3868,7 +3876,7 @@ repo, and commit all important files.</p>
<div class="content">
<pre class="nowrap">$ git add flake.lock
$ git commit -a -m 'initial commit'
[master (root-commit) 175745f] initial commit
[master (root-commit) e321fd2] initial commit
4 files changed, 127 insertions(+)
create mode 100644 flake.lock
create mode 100644 flake.nix
@ -4439,7 +4447,7 @@ mkShell <span class="tok-p">{</span>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2025-08-19 21:51:18 IST
Last updated 2025-08-19 22:16:58 IST
</div>
</div>
</body>

View file

@ -51,5 +51,7 @@ earlier. That's not particularly convenient, but it does demonstrate
that the package remains in the store for future use.
....
$ /nix/store/qskl8ajlgnl654fhgsmv74yv8x9r3kzg-hello-flake/bin/hello-flake
$# executable=$(which hello-flake)
$# echo '$ '${executable}
$# ${executable}
....

File diff suppressed because it is too large Load diff