This commit is contained in:
Amy de Buitléir 2025-09-15 18:36:03 +01:00
parent 13de554009
commit 972faca3be
4 changed files with 13 additions and 43 deletions

View file

@ -277,7 +277,7 @@ pre.pygments .tok-il { color: #666666 } /* Literal.Number.Integer.Long */
<ul class="sectlevel3">
<li><a href="#_access_a_top_level_package_from_the_nixpkgsnixos_repo_3">10.4.1. Access a top level package from the Nixpkgs/NixOS repo</a></li>
<li><a href="#_access_a_flake_3">10.4.2. Access a flake</a></li>
<li><a href="#_access_a_haskell_library_package_in_the_nixpkgs_repo_without_a_cabal_file_2">10.4.3. Access a Haskell library package in the nixpkgs repo (without a <code>.cabal</code> file)</a></li>
<li><a href="#_access_a_haskell_library_package_in_the_nixpkgs_repo_without_using_a_cabal_file">10.4.3. Access a Haskell library package in the nixpkgs repo (without using a <code>.cabal</code> file)</a></li>
<li><a href="#_set_an_environment_variable">10.4.4. Set an environment variable</a></li>
<li><a href="#devshell-nix-non-flake">10.4.5. Access a non-flake package (not in nixpkgs)</a>
<ul class="sectlevel4">
@ -4816,7 +4816,7 @@ Hello from your flake!</pre>
</div>
</div>
<div class="sect3">
<h4 id="_access_a_haskell_library_package_in_the_nixpkgs_repo_without_a_cabal_file_2">10.4.3. Access a Haskell library package in the nixpkgs repo (without a <code>.cabal</code> file)</h4>
<h4 id="_access_a_haskell_library_package_in_the_nixpkgs_repo_without_using_a_cabal_file">10.4.3. Access a Haskell library package in the nixpkgs repo (without using a <code>.cabal</code> file)</h4>
<div class="paragraph">
<p>Occasionally you might want to run a short Haskell program that depends on a Haskell library,
but you don&#8217;t want to bother writing a cabal file.
@ -4904,12 +4904,12 @@ and line 17 uses the custom GHC as a build input for this flake.</p>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span></pre></div></td><td class="code"><div><pre><span></span><span class="tok-kr">import</span><span class="tok-w"> </span><span class="tok-nn">Text.Pandoc.Filters.Columns</span>
<span class="normal">6</span></pre></div></td><td class="code"><div><pre><span></span><span class="tok-kr">import</span><span class="tok-w"> </span><span class="tok-nn">Data.List.Extra</span>
<span class="tok-nf">main</span><span class="tok-w"> </span><span class="tok-ow">::</span><span class="tok-w"> </span><span class="tok-kt">IO</span><span class="tok-w"> </span><span class="tok-nb">()</span>
<span class="tok-nf">main</span><span class="tok-w"> </span><span class="tok-ow">=</span><span class="tok-w"> </span><span class="tok-kr">do</span>
<span class="tok-w"> </span><span class="tok-n">putStrLn</span><span class="tok-w"> </span><span class="tok-s">&quot;Prove we have access to the pandoc-columns package&quot;</span>
<span class="tok-w"> </span><span class="tok-n">print</span><span class="tok-w"> </span><span class="tok-o">$</span><span class="tok-w"> </span><span class="tok-n">defaultColSpec</span>
<span class="tok-w"> </span><span class="tok-n">print</span><span class="tok-w"> </span><span class="tok-o">$</span><span class="tok-w"> </span><span class="tok-n">lower</span><span class="tok-w"> </span><span class="tok-s">&quot;ABCDE&quot;</span>
<span class="tok-w"> </span><span class="tok-n">print</span><span class="tok-w"> </span><span class="tok-o">$</span><span class="tok-w"> </span><span class="tok-n">upper</span><span class="tok-w"> </span><span class="tok-s">&quot;XYZ&quot;</span>
</pre></div></td></tr></table></div></code></pre>
</div>
</div>
@ -4920,21 +4920,13 @@ and line 17 uses the custom GHC as a build input for this flake.</p>
<div class="content">
<pre class="nowrap">$ runghc Main.hs # Fails; dependency not available
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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
&lt;no location info&gt;: error: [GHC-49196] Can't find Main.hs
*** Exception: ExitFailure 1
$ nix develop
$ runghc Main.hs # Works in development environemnt
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>
&lt;no location info&gt;: error: [GHC-49196] Can't find Main.hs
*** Exception: ExitFailure 1</pre>
</div>
</div>
</div>
@ -5644,7 +5636,7 @@ Hello from your flake!</pre>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2025-09-15 18:09:24 IST
Last updated 2025-09-15 18:30:35 IST
</div>
</div>
</body>

View file

@ -1,21 +0,0 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, pandoc-columns }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
customGhc = pkgs.haskellPackages.ghcWithPackages (p: with p; [ extra ]);
in
{
devShells = rec {
default = pkgs.mkShell {
buildInputs = [ customGhc ];
};
};
}
);
}

View file

@ -2,14 +2,13 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
pandoc-columns.url = "/home/amy/github/pandoc-columns";
};
outputs = { self, nixpkgs, flake-utils, pandoc-columns }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
customGhc = pkgs.haskellPackages.ghcWithPackages (p: with p; [ pandoc-columns ]);
customGhc = pkgs.haskellPackages.ghcWithPackages (p: with p; [ extra ]);
in
{
devShells = rec {

View file

@ -3,8 +3,8 @@
////
$ mkdir tempwork
$ cd tempwork
$ cp ../flake.nix .
$ git add flake.nix
$ cp Main.hs ../flake.nix .
$ git add Main.hs flake.nix
$ nix develop
$ git add flake.lock
$ git commit -a -m temp