From d351582364a545a13a5ac7165498d0f6b0762e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amy=20de=20Buitl=C3=A9ir?= Date: Mon, 15 Sep 2025 18:02:05 +0100 Subject: [PATCH] temp --- index.html | 43 +++--- source/book.adoc | 1 + source/recipes/build/main.adoc | 4 +- source/recipes/devshell/flake/main.adoc0 | 6 +- .../devshell/flake/tempwork/flake.lock | 128 ++++++++++++++++++ .../recipes/devshell/flake/tempwork/flake.nix | 21 +++ 6 files changed, 179 insertions(+), 24 deletions(-) create mode 100644 source/recipes/devshell/flake/tempwork/flake.lock create mode 100644 source/recipes/devshell/flake/tempwork/flake.nix diff --git a/index.html b/index.html index 050b33c..cfeb023 100644 --- a/index.html +++ b/index.html @@ -291,8 +291,9 @@ pre.pygments .tok-il { color: #666666 } /* Literal.Number.Integer.Long */
  • 10.6. An (old-style) Nix shell with access to a flake
  • @@ -324,7 +325,8 @@ and as a downloadable

    I would like to thank the patient people on the NixOS Discourse Forum who answered my many questions, -especially cdepillabout, FedericoSchonborn, tejing and smkuehnhold.

    +especially cdepillabout, FedericoSchonborn, tejing and smkuehnhold. +Any mistakes in this book are my own, however.

    @@ -5260,16 +5262,7 @@ hello-flake

    Line 5 adds hello-flake as an input to this flake, Line 8 allows the output function to reference hello-flake. As expected, we need to add hello-flake as a build input, which we do in line 35. -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.

    - -
    -

    There are various ways to deal with this problem. -In this case we simply edited the script (lines 30-32) as we install it, -by specifying the full path to hello-nix.

    -
    -
    -

    Let’s take a closer look at the buildInputs expression from line 35.

    +Let’s take a closer look at the buildInputs expression from line 35.

    @@ -5282,6 +5275,14 @@ The first part refers to the name we assigned in the input section of our flake, and the last part is the name of the package or app we want. (See Section 3.1, “Flake outputs” for how to identify flake outputs.)

    +
    +

    Line 35 does make hello-flake 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. +There are various ways to deal with this problem. +In this case we simply edited the script (lines 30-32) as we install it, +by specifying the full path to hello-nix.

    +
    @@ -5310,12 +5311,17 @@ I'm a flake, and I'm running a command defined in a another flake. Hello from your flake! + +
    +

    10.5.3. Access a Haskell library package in the nixpkgs repo

    -

    Unresolved directive in recipes/build/main.adoc - include::haskell-pkg/main-generated.adoc[leveloffset=+1]

    +

    If you use haskell-flake (see Section 9.1.5, “The Nix flake”) +nothing special needs to be added to flake.nix. +Simply list your Haskell package dependencies to your cabal file as you normally would.

    -

    10.5.3. Access to a Haskell package defined in a flake

    +

    10.5.4. Access to a Haskell package defined in a flake

    In this example we will access three Haskell packages (pandoc-linear-table, pandoc-logic-proof, and pandoc-columns) @@ -5394,12 +5400,9 @@ set up automatically; no need to define devShells.

    -
    -

    Unresolved directive in recipes/build/main.adoc - include::env-var/main-generated.adoc[leveloffset=+1]

    -
    -

    10.5.4. Access a non-flake package (not in nixpkgs)

    +

    10.5.5. Access a non-flake package (not in 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, “Run a flake”.

    @@ -5630,7 +5633,7 @@ Hello from your flake!
    diff --git a/source/book.adoc b/source/book.adoc index 81a93d8..19480a6 100644 --- a/source/book.adoc +++ b/source/book.adoc @@ -29,6 +29,7 @@ I would like to thank the patient people on the https://discourse.nixos.org/[NixOS Discourse Forum] who answered my many questions, especially `cdepillabout`, `FedericoSchonborn`, `tejing` and `smkuehnhold`. +Any mistakes in this book are my own, however. include::intro/main.adoc[leveloffset=+1] diff --git a/source/recipes/build/main.adoc b/source/recipes/build/main.adoc index 8907f74..f34972c 100644 --- a/source/recipes/build/main.adoc +++ b/source/recipes/build/main.adoc @@ -4,10 +4,8 @@ include::nixpkg/main.adoc[leveloffset=+1] include::flake/main-generated.adoc[leveloffset=+1] -include::haskell-pkg/main-generated.adoc[leveloffset=+1] +include::haskell-pkg/main.adoc[leveloffset=+1] include::haskell-flake/main-generated.adoc[leveloffset=+1] -include::env-var/main-generated.adoc[leveloffset=+1] - include::nix-non-flake/main-generated.adoc[leveloffset=+1] diff --git a/source/recipes/devshell/flake/main.adoc0 b/source/recipes/devshell/flake/main.adoc0 index a4ff83e..8a2d780 100644 --- a/source/recipes/devshell/flake/main.adoc0 +++ b/source/recipes/devshell/flake/main.adoc0 @@ -13,12 +13,16 @@ $ git commit -a -m temp 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 <<#flakeref>>. -[source,nix,linenums,highlight='5,16'] +[source,nix,linenums,highlight='5,8,16'] .flake.nix .... $# cat flake.nix .... +Line 5 adds `hello-flake` as an input to this flake. +Line 8 allows the output function to reference `hello-flake`. +Line 16 adds `hello-flake` as a build input for this flake. + Let's take a closer look at the `buildInputs` expression from line 16. .... diff --git a/source/recipes/devshell/flake/tempwork/flake.lock b/source/recipes/devshell/flake/tempwork/flake.lock new file mode 100644 index 0000000..aabac4f --- /dev/null +++ b/source/recipes/devshell/flake/tempwork/flake.lock @@ -0,0 +1,128 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "hello-flake": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1757875192, + "narHash": "sha256-JBkm6NAOYjR3Sc3BxJ2ijrTqW8Ga0NlN9GPUJ/NUsGM=", + "ref": "refs/heads/main", + "rev": "2d9363f255c44a41be2e5291dd624e078e7f4139", + "revCount": 25, + "type": "git", + "url": "https://codeberg.org/mhwombat/hello-flake" + }, + "original": { + "type": "git", + "url": "https://codeberg.org/mhwombat/hello-flake" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1757873102, + "narHash": "sha256-kYhNxLlYyJcUouNRazBufVfBInMWMyF+44xG/xar2yE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "88cef159e47c0dc56f151593e044453a39a6e547", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1757952092, + "narHash": "sha256-BcfTLFCU7elUJ2dwyt0iTjxsz/XLh+8ZygDcFwy6xPE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fd76dc9e7c68ac7c3941ba2af2bedcd79c5cf4ed", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "hello-flake": "hello-flake", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/source/recipes/devshell/flake/tempwork/flake.nix b/source/recipes/devshell/flake/tempwork/flake.nix new file mode 100644 index 0000000..0db427b --- /dev/null +++ b/source/recipes/devshell/flake/tempwork/flake.nix @@ -0,0 +1,21 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + hello-flake.url = "git+https://codeberg.org/mhwombat/hello-flake"; + }; + + outputs = { self, nixpkgs, flake-utils, hello-flake }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShells = rec { + default = pkgs.mkShell { + buildInputs = [ hello-flake.packages.${system}.hello ]; + }; + }; + } + ); +}