From d4eb863b3c069f37d748e95e7943ddaefaeae3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amy=20de=20Buitl=C3=A9ir?= Date: Sat, 13 Sep 2025 16:16:54 +0100 Subject: [PATCH] temp --- index.html | 127 +++++++++++++++++- .../recipes/build/nixpkg/tempwork/flake.nix | 6 +- 2 files changed, 126 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 9f8fce0..c31f6f3 100644 --- a/index.html +++ b/index.html @@ -215,7 +215,8 @@
  • 10.5. Build/runtime environments
  • 10.6. An (old-style) Nix shell with access to a flake
  • @@ -4878,8 +4879,124 @@ Line 15 should be replaced with:

    10.5. Build/runtime environments

    +
    +

    10.5.1. Access a top level package from the Nixpkgs/NixOS repo

    +
    +
    hello-with-cow
    +
    +
    1
    +2
    +3
    #!/usr/bin/env sh
    +
    +cowsay "Hello from your flake!"
    +
    +
    +
    +
    +
    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
    +34
    +35
    +36
    +37
    +38
    +39
    {
    +  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
    +      {
    +        packages = rec {
    +          hello = pkgs.stdenv.mkDerivation rec {
    +            name = "hello-flake";
    +
    +            src = ./.;
    +
    +            unpackPhase = "true";
    +
    +            buildPhase = ":";
    +
    +            installPhase =
    +              ''
    +                mkdir -p $out/bin
    +                cp $src/hello-flake $out/bin/hello-flake
    +                chmod +x $out/bin/hello-flake
    +              '';
    +          };
    +          default = hello;
    +        };
    +
    +        apps = rec {
    +          hello = flake-utils.lib.mkApp { drv = self.packages.${system}.hello; };
    +          default = hello;
    +        };
    +      }
    +    );
    +}
    +
    +
    +
    -

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

    +

    Here’s a demonstration using the flake.

    +
    +
    +
    +
    $ nix run
    +this derivation will be built:
    +  /nix/store/k2w6258690zjhdf6y59vfpfiz7d67jb1-hello-flake.drv
    +building '/nix/store/k2w6258690zjhdf6y59vfpfiz7d67jb1-hello-flake.drv'...
    +error: builder for '/nix/store/k2w6258690zjhdf6y59vfpfiz7d67jb1-hello-flake.drv' failed with exit code 1;
    +       last 8 log lines:
    +       > Running phase: unpackPhase
    +       > Running phase: patchPhase
    +       > Running phase: updateAutotoolsGnuConfigScriptsPhase
    +       > Running phase: configurePhase
    +       > no configure script, doing nothing
    +       > Running phase: buildPhase
    +       > Running phase: installPhase
    +       > cp: cannot stat '/nix/store/mhmgp4r3vihp0ar76ik7ah5q9djzhrdf-tempwork/hello-flake': No such file or directory
    +       For full logs, run:
    +         nix log /nix/store/k2w6258690zjhdf6y59vfpfiz7d67jb1-hello-flake.drv
    +

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

    @@ -4893,8 +5010,9 @@ Line 15 should be replaced with:

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

    +
    -

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

    +

    10.5.2. 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, “Flakes”.

    @@ -5048,6 +5166,7 @@ by specifying the full path to hello-nix.

    $ hello-nix # this will fail
     bash: line 40: hello-nix: command not found
     $ nix develop
    +building '/nix/store/0qzgar07id1cpygx9yyxfsvls1w2jf0c-hello-again-env.drv'...
     $ hello-nix
     Hello from your nix package!
    @@ -5116,7 +5235,7 @@ Hello from your flake!
    diff --git a/source/recipes/build/nixpkg/tempwork/flake.nix b/source/recipes/build/nixpkg/tempwork/flake.nix index 22b491d..63fbedd 100644 --- a/source/recipes/build/nixpkg/tempwork/flake.nix +++ b/source/recipes/build/nixpkg/tempwork/flake.nix @@ -12,7 +12,7 @@ { packages = rec { hello = pkgs.stdenv.mkDerivation rec { - name = "hello-flake"; + name = "hello-with-cow"; src = ./.; @@ -23,8 +23,8 @@ installPhase = '' mkdir -p $out/bin - cp $src/hello-flake $out/bin/hello-flake - chmod +x $out/bin/hello-flake + cp $src/hello-with-cow $out/bin + chmod +x $out/bin/hello-with-cow ''; }; default = hello;