mirror of
https://codeberg.org/mhwombat/nix-book.git
synced 2026-05-13 22:31:12 +08:00
temp
This commit is contained in:
parent
dc9e86cfd1
commit
84c9fcabba
5 changed files with 44 additions and 10 deletions
|
|
@ -4842,10 +4842,8 @@ Hello from your flake!</pre>
|
|||
<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>
|
||||
<div class="paragraph">
|
||||
<p>Occasionally you might want to run a short Haskell program that depends on a Haskell library,
|
||||
but you don’t want to bother writing a cabal file.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Example: Access the <code>containers</code> package from the <code>haskellPackages</code> set in the nixpkgs repo.</p>
|
||||
but you don’t want to bother writing a cabal file.
|
||||
In this example, we will access the <code>containers</code> package from the <code>haskellPackages</code> set in the nixpkgs repo.</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="title">flake.nix</div>
|
||||
|
|
@ -5575,7 +5573,7 @@ Hello from your flake!</pre>
|
|||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Last updated 2025-09-13 20:09:02 IST
|
||||
Last updated 2025-09-13 20:11:05 IST
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
pandoc-columns.url = "/home/amy/github/pandoc-columns";
|
||||
pandoc-query.url = "/home/amy/codeberg/pandoc-query";
|
||||
};
|
||||
|
||||
outputs = inputs@{ self, nixpkgs, flake-parts, pandoc-linear-table, pandoc-logic-proof, pandoc-columns, pandoc-query, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = nixpkgs.lib.systems.flakeExposed;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,21 @@
|
|||
= Access to a Haskell package on your local computer
|
||||
= Access to a Haskell package defined in a flake
|
||||
|
||||
Ex: Access three Haskell packages
|
||||
////
|
||||
$ mkdir tempwork
|
||||
$ cd tempwork
|
||||
$ cp ../flake.nix .
|
||||
$ git add flake.nix
|
||||
$ nix develop
|
||||
$ git add flake.lock
|
||||
$ git commit -a -m temp
|
||||
////
|
||||
|
||||
|
||||
In this example we will access three Haskell packages
|
||||
(`pandoc-linear-table`, `pandoc-logic-proof`, and `pandoc-columns`)
|
||||
that are on my hard drive.
|
||||
that are defined as flakes on my hard drive.
|
||||
We are using `haskell-flake`, so the development environment is
|
||||
set up automatically; no need to define `devShells`.
|
||||
|
||||
[source,nix,linenums]
|
||||
.flake.nix
|
||||
|
|
@ -10,4 +23,15 @@ that are on my hard drive.
|
|||
include::flake.nix[]
|
||||
....
|
||||
|
||||
// TODO Add demo
|
||||
Here's a demonstration using the shell.
|
||||
|
||||
....
|
||||
$# ../../../../../start-shell nix develop <<EOL
|
||||
$ cabal info pandoc-columns
|
||||
$# EOL
|
||||
....
|
||||
|
||||
////
|
||||
Good adoc0 scripts clean up after themselves.
|
||||
$ cd .. ; rm -rf tempwork # clean up
|
||||
////
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
$ mkdir tempwork
|
||||
$ cd tempwork
|
||||
$ cp ../flake.nix ../Main.hs .
|
||||
$ git add flake.nix
|
||||
$ git add Main.hs flake.nix
|
||||
$ nix develop
|
||||
$ git add flake.lock
|
||||
$ git commit -a -m temp
|
||||
|
|
|
|||
11
source/recipes/devshell/haskell-pkg/tempwork/Main.hs
Normal file
11
source/recipes/devshell/haskell-pkg/tempwork/Main.hs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import Data.Map
|
||||
|
||||
m :: Map String Int
|
||||
m = fromList [("cats", 3), ("dogs", 2)]
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
let cats = findWithDefault 0 "cats" m
|
||||
let dogs = findWithDefault 0 "dogs" m
|
||||
let zebras = findWithDefault 0 "zebras" m
|
||||
print $ "I have " ++ show cats ++ " cats, " ++ show dogs ++ " dogs, and " ++ show zebras ++ " zebras."
|
||||
Loading…
Add table
Add a link
Reference in a new issue