mirror of
https://codeberg.org/mhwombat/nix-book.git
synced 2026-01-07 14:27:24 +08:00
temp
This commit is contained in:
parent
c25a0c2650
commit
e2aa713c19
7 changed files with 143 additions and 196 deletions
61
index.html
61
index.html
|
|
@ -1900,7 +1900,7 @@ location of the executable, if we’re curious.</p>
|
|||
<div class="literalblock">
|
||||
<div class="content">
|
||||
<pre class="nowrap">$ which hello-flake
|
||||
/nix/store/qskl8ajlgnl654fhgsmv74yv8x9r3kzg-hello-flake/bin/hello-flake</pre>
|
||||
/nix/store/y0i81pxnbrg8jpvqp886b4lrzh7wb0ni-hello-flake/bin/hello-flake</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
|
|
@ -1910,7 +1910,7 @@ directly available.</p>
|
|||
<div class="literalblock">
|
||||
<div class="content">
|
||||
<pre class="nowrap">$ exit
|
||||
$ hello-flake # Won't work outside development shell
|
||||
$ hello-flake # Fails outside development shell
|
||||
bash: line 24: hello-flake: command not found</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1921,7 +1921,7 @@ that the package remains in the store for future use.</p>
|
|||
</div>
|
||||
<div class="literalblock">
|
||||
<div class="content">
|
||||
<pre class="nowrap">$ /nix/store/qskl8ajlgnl654fhgsmv74yv8x9r3kzg-hello-flake/bin/hello-flake
|
||||
<pre class="nowrap">$ /nix/store/y0i81pxnbrg8jpvqp886b4lrzh7wb0ni-hello-flake/bin/hello-flake
|
||||
Hello from your flake!</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2825,7 +2825,7 @@ Here’s the modified <code>hello-flake</code> file.</p>
|
|||
</div>
|
||||
<div class="literalblock">
|
||||
<div class="content">
|
||||
<pre class="nowrap">$ ./hello-flake # Won't work
|
||||
<pre class="nowrap">$ ./hello-flake # Fails
|
||||
./hello-flake: line 3: cowsay: command not found</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2974,7 +2974,7 @@ $ exit</pre>
|
|||
</div>
|
||||
<div class="literalblock">
|
||||
<div class="content">
|
||||
<pre class="nowrap">$ nix run # Won't work
|
||||
<pre class="nowrap">$ nix run # Fails
|
||||
warning: Git tree '/home/amy/codeberg/nix-book/source/modify-hello-flake/hello-flake' is dirty
|
||||
/nix/store/rnjqkk7a8sz6wrm1qb1hxssy7qlgaa85-hello-flake/bin/hello-flake: line 3: cowsay: command not found</pre>
|
||||
</div>
|
||||
|
|
@ -3172,7 +3172,7 @@ don’t need to <code>git push</code> the changes until we’re ready to
|
|||
<div class="literalblock">
|
||||
<div class="content">
|
||||
<pre class="nowrap">$ git commit hello-flake flake.nix -m 'added bovine feature'
|
||||
[main a10700e] added bovine feature
|
||||
[main cb77c4d] added bovine feature
|
||||
2 files changed, 13 insertions(+), 1 deletion(-)
|
||||
$ nix run
|
||||
________________________
|
||||
|
|
@ -3381,7 +3381,7 @@ You can come back to this section later to learn more.</p>
|
|||
<div class="literalblock">
|
||||
<div class="content">
|
||||
<pre class="nowrap">$ nix shell nixpkgs#ghc
|
||||
$ runghc Main.hs # Won't work
|
||||
$ runghc Main.hs # Fails
|
||||
|
||||
Main.hs:1:1: error: [GHC-87110]
|
||||
Could not find module ‘Network.HostName’.
|
||||
|
|
@ -3400,7 +3400,7 @@ Let’s exit that shell and try again, this time adding the <code>hostname</
|
|||
<div class="content">
|
||||
<pre class="nowrap">$ exit
|
||||
$ nix shell nixpkgs#ghc nixpkgs#hostname
|
||||
$ runghc Main.hs # Won't work
|
||||
$ runghc Main.hs # Fails
|
||||
|
||||
Main.hs:1:1: error: [GHC-87110]
|
||||
Could not find module ‘Network.HostName’.
|
||||
|
|
@ -3423,7 +3423,7 @@ The package we want is in the <em>package set</em> called <code>haskellPackages<
|
|||
<div class="content">
|
||||
<pre class="nowrap">$ exit
|
||||
$ nix shell nixpkgs#ghc nixpkgs#haskellPackages.hostname
|
||||
$ runghc Main.hs # Won't work
|
||||
$ runghc Main.hs # Fails
|
||||
|
||||
Main.hs:1:1: error: [GHC-87110]
|
||||
Could not find module ‘Network.HostName’.
|
||||
|
|
@ -3770,7 +3770,7 @@ warning: creating lock file '"/home/amy/codeberg/nix-book/source/new-flake/haske
|
|||
• Added input 'haskell-flake':
|
||||
'github:srid/haskell-flake/2acbf1c9bb7aac38b59dcc3c1bd78911cf37e42c?narHash=sha256-jwZT6Ns4BXlrFHaXjZgZwfhSaw8nTCTKZ8fCDylrONM%3D' (2025-09-14)
|
||||
• Added input 'nixpkgs':
|
||||
'github:nixos/nixpkgs/6d7ec06d6868ac6d94c371458fc2391ded9ff13d?narHash=sha256-fEvTiU4s9lWgW7mYEU/1QUPirgkn%2BodUBTaindgiziY%3D' (2025-09-13)
|
||||
'github:nixos/nixpkgs/88cef159e47c0dc56f151593e044453a39a6e547?narHash=sha256-kYhNxLlYyJcUouNRazBufVfBInMWMyF%2B44xG/xar2yE%3D' (2025-09-14)
|
||||
warning: Git tree '/home/amy/codeberg/nix-book/source/new-flake/haskell-flake/hello-haskell' is dirty</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3788,6 +3788,11 @@ The important thing for now is that the build succeeded.</p>
|
|||
<div class="content">
|
||||
<pre class="nowrap">$ nix run
|
||||
warning: Git tree '/home/amy/codeberg/nix-book/source/new-flake/haskell-flake/hello-haskell' is dirty
|
||||
these 2 derivations will be built:
|
||||
/nix/store/b67dd3m503q30yiwfgav3xzz88bb91h4-hello-flake-haskell-source-1.0.0.drv
|
||||
/nix/store/bgjyjh7282728b2qff37ldygg80zk4m1-hello-flake-haskell-1.0.0.drv
|
||||
building '/nix/store/b67dd3m503q30yiwfgav3xzz88bb91h4-hello-flake-haskell-source-1.0.0.drv'...
|
||||
building '/nix/store/bgjyjh7282728b2qff37ldygg80zk4m1-hello-flake-haskell-1.0.0.drv'...
|
||||
Hello from Haskell inside a Nix flake!
|
||||
Your hostname is: wombat11k</pre>
|
||||
</div>
|
||||
|
|
@ -3807,7 +3812,7 @@ We need to add this to the 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) d35f8fd] initial commit
|
||||
[master (root-commit) c64c57a] initial commit
|
||||
5 files changed, 170 insertions(+)
|
||||
create mode 100644 LICENSE
|
||||
create mode 100644 Main.hs
|
||||
|
|
@ -4009,7 +4014,7 @@ First we’ll try building the package manually.
|
|||
</div>
|
||||
<div class="literalblock">
|
||||
<div class="content">
|
||||
<pre class="nowrap">$ python -m build # Won't work
|
||||
<pre class="nowrap">$ python -m build # Fails
|
||||
/nix/store/iyff8129iampdw13nlfqalzhxy8y1hi9-python3-3.13.6/bin/python: No module named build</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4212,7 +4217,7 @@ something like this.</p>
|
|||
</div>
|
||||
<div class="literalblock">
|
||||
<div class="content">
|
||||
<pre class="nowrap">$ nix build # Won't work
|
||||
<pre class="nowrap">$ nix build # Fails
|
||||
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:
|
||||
|
|
@ -4236,7 +4241,7 @@ warning: creating lock file '"/home/amy/codeberg/nix-book/source/new-flake/pytho
|
|||
• Added input 'flake-utils/systems':
|
||||
'github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e?narHash=sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768%3D' (2023-04-09)
|
||||
• Added input 'nixpkgs':
|
||||
'github:NixOS/nixpkgs/5ad881b15fb2b63c2f127533ca59f840fcc24c3f?narHash=sha256-P8XdKg87fR5PpCjIgMH%2B05PDwhdmlNrigsvChdHfyaw%3D' (2025-09-14)
|
||||
'github:NixOS/nixpkgs/dd16e0b60390586a261a4e28fc180a91212fe010?narHash=sha256-yM1FFsRiyESij/lzbdBMCUoFOKMoShHu0CAexnBWzTM%3D' (2025-09-15)
|
||||
warning: Git tree '/home/amy/codeberg/nix-book/source/new-flake/python-flake/hello-python' is dirty</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4254,6 +4259,9 @@ The important thing for now is that the build succeeded.</p>
|
|||
<div class="content">
|
||||
<pre class="nowrap">$ nix run
|
||||
warning: Git tree '/home/amy/codeberg/nix-book/source/new-flake/python-flake/hello-python' is dirty
|
||||
this derivation will be built:
|
||||
/nix/store/kr0aywqsm9v8ds4mc909iaan2yaqmjq3-hello-flake-python.drv
|
||||
building '/nix/store/kr0aywqsm9v8ds4mc909iaan2yaqmjq3-hello-flake-python.drv'...
|
||||
Hello from inside a Python program built with a Nix flake!</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -4272,7 +4280,7 @@ We need to add this to the 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) 2af9bd5] initial commit
|
||||
[master (root-commit) deac9ed] initial commit
|
||||
4 files changed, 127 insertions(+)
|
||||
create mode 100644 flake.lock
|
||||
create mode 100644 flake.nix
|
||||
|
|
@ -4655,7 +4663,7 @@ sanitized: <strong>some text</strong></pre>
|
|||
</div>
|
||||
<div class="literalblock">
|
||||
<div class="content">
|
||||
<pre class="nowrap">$ cowsay "Moo!" # Won't work; dependency not available
|
||||
<pre class="nowrap">$ cowsay "Moo!" # Fails; dependency not available
|
||||
bash: line 17: cowsay: command not found
|
||||
$ nix develop
|
||||
$ cowsay "Moo!" # Works in development environment
|
||||
|
|
@ -4780,7 +4788,7 @@ we see that this flake provides both a package and an app called <code>hello</co
|
|||
</div>
|
||||
<div class="literalblock">
|
||||
<div class="content">
|
||||
<pre class="nowrap">$ hello-flake # Won't work; dependency not available
|
||||
<pre class="nowrap">$ hello-flake # Fails; dependency not available
|
||||
bash: line 40: hello-flake: command not found
|
||||
$ nix develop
|
||||
$ hello-flake # Works in development environment
|
||||
|
|
@ -4885,18 +4893,23 @@ together with the <em>high-level workflow</em> described in <a href="#_developme
|
|||
</div>
|
||||
<div class="literalblock">
|
||||
<div class="content">
|
||||
<pre class="nowrap">$ runghc Main.hs # Won't work; dependency not available
|
||||
<pre class="nowrap">$ runghc Main.hs # Fails; dependency not available
|
||||
|
||||
Main.hs:1:1: error: [GHC-87110]
|
||||
Could not find module ‘Data.List.Extra’.
|
||||
Could not find module ‘Text.Pandoc.Filters.Columns’.
|
||||
Use :set -v to see a list of the files searched for.
|
||||
|
|
||||
1 | import Data.List.Extra
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
1 | import Text.Pandoc.Filters.Columns
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
$ nix develop
|
||||
$ runghc Main.hs # Works in development environemnt
|
||||
"abcde"
|
||||
"XYZ"</pre>
|
||||
|
||||
Main.hs:1:1: error: [GHC-87110]
|
||||
Could not find module ‘Text.Pandoc.Filters.Columns’.
|
||||
Use :set -v to see a list of the files searched for.
|
||||
|
|
||||
1 | import Text.Pandoc.Filters.Columns
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -5461,7 +5474,7 @@ Hello from your flake!</pre>
|
|||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Last updated 2025-09-15 14:41:47 IST
|
||||
Last updated 2025-09-15 14:48:12 IST
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue