From 5dcadd370efaaecf4b18f41831f837fdb2b11845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amy=20de=20Buitl=C3=A9ir?= Date: Mon, 15 Sep 2025 15:37:53 +0100 Subject: [PATCH] temp --- index.html | 125 ++++++++++++++++- .../recipes/build/flake/tempwork/flake.lock | 128 ------------------ source/recipes/build/flake/tempwork/flake.nix | 21 --- source/recipes/build/nix-non-flake/flake.nix | 4 +- .../nix-non-flake/tempwork/flake.lock | 77 +++++++++++ .../devshell/nix-non-flake/tempwork/flake.nix | 27 ++++ 6 files changed, 224 insertions(+), 158 deletions(-) delete mode 100644 source/recipes/build/flake/tempwork/flake.lock delete mode 100644 source/recipes/build/flake/tempwork/flake.nix create mode 100644 source/recipes/devshell/nix-non-flake/tempwork/flake.lock create mode 100644 source/recipes/devshell/nix-non-flake/tempwork/flake.nix diff --git a/index.html b/index.html index 573195e..1653662 100644 --- a/index.html +++ b/index.html @@ -286,8 +286,9 @@ pre.pygments .tok-il { color: #666666 } /* Literal.Number.Integer.Long */
  • 10.5. Build/runtime environments
  • 10.6. An (old-style) Nix shell with access to a flake
  • @@ -5128,15 +5129,127 @@ Line 15 should be replaced with:

    See Section 8.2, “Introducing a dependency”.

    + +
    +

    10.5.2. Access a flake

    -

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

    +

    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, “Run a flake”.

    +
    +
    +
    flake.nix
    +
    +
     1
    + 2
    + 3
    + 4
    + 5
    + 6
    + 7
    + 8
    + 9
    +10
    +11
    +12
    +13
    +14
    +15
    +16
    +17
    +18
    +19
    +20
    +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 ];
    +          };
    +        };
    +      }
    +    );
    +}
    +
    +
    +
    +
    +

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

    +
    +
    +
    +
    hello-flake.packages.${system}.hello
    +
    +
    +
    +

    Why is the first part hello-flake and the last part hello? +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.

    +
    +
    +

    You can find the outputs of a flake using the nix flake show command.

    +
    +
    +
    +
    $ nix flake show git+https://codeberg.org/mhwombat/hello-flake
    +git+https://codeberg.org/mhwombat/hello-flake?ref=refs/heads/main&rev=2d9363f255c44a41be2e5291dd624e078e7f4139
    +├───apps
    +│   ├───aarch64-darwin
    +│   │   ├───default: app: no description
    +│   │   └───hello: app: no description
    +│   ├───aarch64-linux
    +│   │   ├───default: app: no description
    +│   │   └───hello: app: no description
    +│   ├───x86_64-darwin
    +│   │   ├───default: app: no description
    +│   │   └───hello: app: no description
    +│   └───x86_64-linux
    +│       ├───default: app: no description
    +│       └───hello: app: no description
    +└───packages
    +    ├───aarch64-darwin
    +    │   ├───default omitted (use '--all-systems' to show)
    +    │   └───hello omitted (use '--all-systems' to show)
    +    ├───aarch64-linux
    +    │   ├───default omitted (use '--all-systems' to show)
    +    │   └───hello omitted (use '--all-systems' to show)
    +    ├───x86_64-darwin
    +    │   ├───default omitted (use '--all-systems' to show)
    +    │   └───hello omitted (use '--all-systems' to show)
    +    └───x86_64-linux
    +        ├───default: package 'hello-flake'
    +        └───hello: package 'hello-flake'
    +
    +
    +
    +

    Examining the output of this command, +we see that this flake provides both a package and an app called hello.

    +
    +
    +

    Here’s a demonstration using the flake.

    +
    +
    +
    +
    $ nix run
    +error: flake 'git+file:///home/amy/codeberg/nix-book?dir=source/recipes/build/flake/tempwork' does not provide attribute 'apps.x86_64-linux.default', 'defaultApp.x86_64-linux', 'packages.x86_64-linux.default' or 'defaultPackage.x86_64-linux'
    +

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

    -

    10.5.2. Access to a Haskell package defined in a flake

    +

    10.5.3. 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) @@ -5220,7 +5333,7 @@ set up automatically; no need to define devShells.

    -

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

    +

    10.5.4. 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”.

    @@ -5455,7 +5568,7 @@ Hello from your flake!
    diff --git a/source/recipes/build/flake/tempwork/flake.lock b/source/recipes/build/flake/tempwork/flake.lock deleted file mode 100644 index af219d2..0000000 --- a/source/recipes/build/flake/tempwork/flake.lock +++ /dev/null @@ -1,128 +0,0 @@ -{ - "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": 1757945769, - "narHash": "sha256-z/SdByTaDnEx4Zj0pyMwzY+uKxV/2TpQQ6ZKijKc2t0=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "62b2408b85dc46dab0b8ca4250471b9cb23425f0", - "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/build/flake/tempwork/flake.nix b/source/recipes/build/flake/tempwork/flake.nix deleted file mode 100644 index 0db427b..0000000 --- a/source/recipes/build/flake/tempwork/flake.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ - 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 ]; - }; - }; - } - ); -} diff --git a/source/recipes/build/nix-non-flake/flake.nix b/source/recipes/build/nix-non-flake/flake.nix index 53107d1..3d6f9a9 100644 --- a/source/recipes/build/nix-non-flake/flake.nix +++ b/source/recipes/build/nix-non-flake/flake.nix @@ -11,9 +11,7 @@ outputs = { self, nixpkgs, flake-utils, hello-nix }: flake-utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs { - inherit system; - }; + pkgs = import nixpkgs { inherit system; }; helloNix = import hello-nix { inherit pkgs; }; in { diff --git a/source/recipes/devshell/nix-non-flake/tempwork/flake.lock b/source/recipes/devshell/nix-non-flake/tempwork/flake.lock new file mode 100644 index 0000000..1a78216 --- /dev/null +++ b/source/recipes/devshell/nix-non-flake/tempwork/flake.lock @@ -0,0 +1,77 @@ +{ + "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" + } + }, + "hello-nix": { + "flake": false, + "locked": { + "lastModified": 1757705465, + "narHash": "sha256-sJCQ9+8Dy+QF9ISaupp42+mGbuXtFyqbX85tWzeNPOI=", + "ref": "refs/heads/main", + "rev": "56044f61231c996e4ab795de1da89e5f79db3f4f", + "revCount": 5, + "type": "git", + "url": "https://codeberg.org/mhwombat/hello-nix" + }, + "original": { + "type": "git", + "url": "https://codeberg.org/mhwombat/hello-nix" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1757945769, + "narHash": "sha256-z/SdByTaDnEx4Zj0pyMwzY+uKxV/2TpQQ6ZKijKc2t0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "62b2408b85dc46dab0b8ca4250471b9cb23425f0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "hello-nix": "hello-nix", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "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/nix-non-flake/tempwork/flake.nix b/source/recipes/devshell/nix-non-flake/tempwork/flake.nix new file mode 100644 index 0000000..b4b97a6 --- /dev/null +++ b/source/recipes/devshell/nix-non-flake/tempwork/flake.nix @@ -0,0 +1,27 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + hello-nix = { + url = "git+https://codeberg.org/mhwombat/hello-nix"; + flake = false; + }; + }; + + outputs = { self, nixpkgs, flake-utils, hello-nix }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + helloNix = import hello-nix { inherit pkgs; }; + in + { + devShells = rec { + default = pkgs.mkShell { + packages = [ helloNix ]; + }; + }; + } + ); +}