$ nix run https://codeberg.org/mhwombat/hello-flake/archive/main.zip +unpacking 'https://codeberg.org/mhwombat/hello-flake/archive/main.zip' into the Git cache... Hello from your flake!
From 3220cdc8dc287943ae777bf583ba36acb6270200 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Amy=20de=20Buitl=C3=A9ir?=
.cabal file)
nixpkgs
$ nix run https://codeberg.org/mhwombat/hello-flake/archive/main.zip +unpacking 'https://codeberg.org/mhwombat/hello-flake/archive/main.zip' into the Git cache... Hello from your flake!
$ nix run https://codeberg.org/mhwombat/hello-flake/archive/main.tar.gz +unpacking 'https://codeberg.org/mhwombat/hello-flake/archive/main.tar.gz' into the Git cache... Hello from your 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”.
+However, you can use any of the flake reference styles defined in Section 10.1.2, “Run 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”.
+However, you can use any of the flake reference styles defined in Section 10.1.2, “Run 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”.
+However, you can use any of the flake reference styles defined in Section 10.1.2, “Run a flake”.hello
-$ hello-flake
+$ hello-flake # Won't work; dependency not available
bash: line 40: hello-flake: command not found
$ nix develop
-$ hello-flake
+$ hello-flake # Works in development environment
Hello from your flake!
@@ -4833,23 +4834,25 @@ together with the high-level workflow described in 18
19
20
-21{ +21 +22
{ 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 }: + 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 + pkgs = import nixpkgs { inherit system; }; + customGhc = pkgs.haskellPackages.ghcWithPackages (p: with p; [ pandoc-columns ]); + in { devShells = rec { - default = pkgs.mkShell { - buildInputs = [ customGhc ]; - }; + default = pkgs.mkShell { + buildInputs = [ customGhc ]; + }; }; } ); @@ -4868,12 +4871,12 @@ together with the high-level workflow described in 3 4 5 -6
import Data.List.Extra +6
import Text.Pandoc.Filters.Columns main :: IO () main = do - print $ lower "ABCDE" - print $ upper "XYZ" + putStrLn "Prove we have access to the pandoc-columns package" + print $ defaultColSpec
In this example we will access three Haskell packages
-(pandoc-linear-table, pandoc-logic-proof, and pandoc-columns)
-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.
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
-34
{
- 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;
- };
- };
-}
-
-Here’s a demonstration using the shell.
-$ nix develop -$ cabal info pandoc-columns -Warning: The package list for 'hackage.haskell.org' is 22 days old. -Run 'cabal update' to get the latest list of available packages. -* pandoc-columns (program and library) - Synopsis: A pandoc filter that provides a Markdown extension for - columns. - Versions available: 0.2.0.5 - Versions installed: [ Not installed ] - Homepage: https://github.com/mhwombat/pandoc-columns - Bug reports: https://github.com/mhwombat/pandoc-columns/issues - Description: For more information and a tutorial on how to use this - package, please see the README at - <https://github.com/mhwombat/pandoc-columns#readme>. - Category: Text - License: BSD-3-Clause - Author: Amy de Buitléir - Maintainer: amy@nualeargais.ie - Source repo: https://github.com/mhwombat/pandoc-columns.git - Executables: pandoc-columns - Dependencies: base >=4.16.4 && <4.17, pandoc-types >=1.22.2 && <1.23, - pandoc >=2.19.2 && <2.20, base >=4.16.4 && <4.17, - pandoc-types >=1.22.2 && <1.23, pandoc-columns - Cached: No - Modules: - Text.Pandoc.Filters.Columns-
FINISH
-FINISH
-FINISH
-FINISH
-FINISH
-FINISH
-FINISH
-FINISH
-Set the value of the environment variable FOO to “bar”.
In this example, we will use a nix package (not 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”.
+However, you can use any of the flake reference styles defined in Section 10.1.2, “Run a flake”.The hello-nix repo provides a default.nix.
@@ -5126,7 +4989,7 @@ If instead it requires <nixpkgs>, it is not pure and we canno
then it requires nixpkgs so we cannot use it.
-Instead, we have to write our own derivation (see Section 10.4.6.2, “If the nix derivation requires nixpkgs”).
nixpkgs”).
Fortunately the file begins with
@@ -5139,7 +5002,7 @@ Instead, we have to write our own derivation (see Secthen it accepts a package set as an argument,
only using <nixpkgs> if no argument is provided.
-We can use it directly to build hello-nix (see Section 10.4.6.1, “If the nix derivation does not require nixpkgs”).
hello-nix (see Section 10.4.5.1, “If the nix derivation does not require nixpkgs”).
In this example, we will use a nix package (not 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”.
+However, you can use any of the flake reference styles defined in Section 10.1.2, “Run a flake”.We already covered how to add a non-flake input to a flake and build it in Section 10.4.6, “Access a non-flake package (not in nixpkgs)”; +
We already covered how to add a non-flake input to a flake and build it in Section 10.4.5, “Access a non-flake package (not in nixpkgs)”;
here we will focus on making it available at runtime.
We will write a flake to package a very simple shell script.
All it does is invoke hello-nix, which is the input we added earlier.
Lines 5-8 and 17 were explained in Section 10.4.6, “Access a non-flake package (not in nixpkgs)”. +
Lines 5-8 and 17 were explained in Section 10.4.5, “Access a non-flake package (not in nixpkgs)”.
As expected, we need to add helloNix as a build input, which we do in line 36.
That does make it available at build and runtime, but it doesn’t put it on the path,
so our hello-again script won’t be able to find it.