$ nix run nixpkgs#cowsay "Moo!" @@ -4057,7 +4044,7 @@ including defining environments that you will use more than once.10.1.2. Flakes
-A flake defined in a local file
+Run a flake defined in a local file
$ nix run ~/codeberg/hello-flake @@ -4066,7 +4053,7 @@ Hello from your flake!-@@ -4787,7 +4779,7 @@ mkShell {A flake defined in a remote git repo
+Run a flake defined in a remote git repo
$ nix run git+https://codeberg.org/mhwombat/hello-flake @@ -4093,7 +4080,7 @@ To run a specific branch, use the command below.-A flake defined in a zip archive
+Run a flake defined in a zip archive
$ nix run https://codeberg.org/mhwombat/hello-flake/archive/main.zip @@ -4103,7 +4090,7 @@ Hello from your flake!-A flake defined in a compressed tar archive
+Run a flake defined in a compressed tar archive
$ nix run https://codeberg.org/mhwombat/hello-flake/archive/main.tar.gz @@ -4113,7 +4100,7 @@ Hello from your flake!--Other types of flake references
+Run other types of flake references
@@ -4318,7 +4305,7 @@ sanitized: <strong>some text</strong>10.4. Development shells
-+10.4.1. A top level package from the Nixpkgs/NixOS repo
+10.4.1. Access a top level package from the Nixpkgs/NixOS repo
flake.nix@@ -4385,7 +4372,7 @@ $ cowsay "Moo!"-10.4.2. A flake
+10.4.2. Access a flake
In this example, we will use a flake defined in a remote git repo. However, you can use any of the flake reference styles defined in Section 10.1.2, “Flakes”.
@@ -4503,7 +4490,7 @@ Hello from your flake!-+10.4.3. A Haskell library package in the nixpkgs repo (without a
+.cabalfile)10.4.3. Access a Haskell library package in the nixpkgs repo (without a
.cabalfile)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.
@@ -4598,6 +4585,136 @@ $ runghc Main.hs "I have 3 cats, 2 dogs, and 0 zebras."++10.4.4. Access to a Haskell package on your local computer
+++Ex: Access three Haskell packages +(
+pandoc-linear-table,pandoc-logic-proof, andpandoc-columns) +that are on my hard drive.++flake.nix++++
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33{ + description = "Pandoc build system for maths web"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + haskell-flake.url = "github:srid/haskell-flake"; + pandoc-linear-table.url = "/home/amy/github/pandoc-linear-table"; + pandoc-logic-proof.url = "/home/amy/github/pandoc-logic-proof"; + 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; + imports = [ inputs.haskell-flake.flakeModule ]; + + perSystem = { self', pkgs, ... }: { + haskellProjects.default = { + # use my versions of some Haskell pagkages instead of the nixpkgs versions + packages = { + pandoc-linear-table.source = inputs.pandoc-linear-table; + pandoc-logic-proof.source = inputs.pandoc-logic-proof; + pandoc-columns.source = inputs.pandoc-columns; + pandoc-query.source = inputs.pandoc-query; + }; + }; + + # haskell-flake doesn't set the default package, but you can do it here. + packages.default = self'.packages.pandoc-maths-web; + }; + }; +} ++10.4.5. Set an environment variable
+++Set the value of the environment variable FOO to “bar”.
++flake.nix++++
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShells = rec { + default = pkgs.mkShell { + packages = [ pkgs.cowsay ]; + }; + }; + } + ); +} +@@ -4648,131 +4765,6 @@ Hello from your flake!/// SKIP include::non-flake/main-generated.adoc[leveloffset=+1]
--10.6. Access to a Haskell package on your local computer
---Ex: Access three Haskell packages -(
-pandoc-linear-table,pandoc-logic-proof, andpandoc-columns) -that are on my hard drive.--10.6.1. In
-shell.nix--shell.nix----
1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -10 -11 -12 -13 -14 with (import <nixpkgs> {}); -let - pandoc-linear-table = haskellPackages.callCabal2nix "pandoc-linear-table" /home/amy/github/pandoc-linear-table {}; - pandoc-logic-proof = haskellPackages.callCabal2nix "pandoc-logic-proof" /home/amy/github/pandoc-logic-proof {}; - pandoc-columns = haskellPackages.callCabal2nix "pandoc-columns" /home/amy/github/pandoc-columns {}; -in -mkShell { - buildInputs = [ - pandoc - pandoc-linear-table - pandoc-logic-proof - pandoc-columns - ]; -} ---10.7. Access to a Haskell package on your local computer, with inter-dependencies
---Ex: Access four Haskell packages -(
-pandoc-linear-table,pandoc-logic-proof,pandoc-columnsandpandoc-maths-web) -that are on my hard drive. -The fourth package depends on the first three to build.--10.7.1. In
-shell.nix--shell.nix----
1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 with (import <nixpkgs> {}); -let - pandoc-linear-table = haskellPackages.callCabal2nix "pandoc-linear-table" /home/amy/github/pandoc-linear-table {}; - pandoc-logic-proof = haskellPackages.callCabal2nix "pandoc-logic-proof" /home/amy/github/pandoc-logic-proof {}; - pandoc-columns = haskellPackages.callCabal2nix "pandoc-columns" /home/amy/github/pandoc-columns {}; - pandoc-maths-web = haskellPackages.callCabal2nix "pandoc-maths-web" /home/amy/github/pandoc-maths-web - { - inherit pandoc-linear-table pandoc-logic-proof pandoc-columns; - }; -in -mkShell { - buildInputs = [ - pandoc - pandoc-linear-table - pandoc-logic-proof - pandoc-columns - pandoc-maths-web - ]; -} --10.8. Set an environment variable
---Ex: Set the value of the environment variable FOO to “bar”
---10.8.1. In
-shell.nix--shell.nix----
1 -2 -3 -4 -5 -6 with (import <nixpkgs> {}); -mkShell { - shellHook = '' - export FOO="bar" - ''; -} -