From bd082ef03a4120872cc81fe6ee9a429b77c0782d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amy=20de=20Buitl=C3=A9ir?= Date: Mon, 15 Sep 2025 17:31:13 +0100 Subject: [PATCH] temp --- index.html | 5 +- source/hello-flake/main.adoc0 | 14 ++++++ source/recipes/build/flake/tempwork/flake.nix | 47 ------------------- .../recipes/build/flake/tempwork/hello-again | 4 -- source/recipes/devshell/flake/main.adoc0 | 11 +---- .../flake/tempwork/flake.lock | 6 +-- .../recipes/devshell/flake/tempwork/flake.nix | 21 +++++++++ 7 files changed, 42 insertions(+), 66 deletions(-) delete mode 100644 source/recipes/build/flake/tempwork/flake.nix delete mode 100755 source/recipes/build/flake/tempwork/hello-again rename source/recipes/{build => devshell}/flake/tempwork/flake.lock (94%) create mode 100644 source/recipes/devshell/flake/tempwork/flake.nix diff --git a/index.html b/index.html index 0ad1744..e94c9b7 100644 --- a/index.html +++ b/index.html @@ -5249,7 +5249,8 @@ hello-flake
-

Line 5 adds hello-flake as an input to this 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 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.

@@ -5607,7 +5608,7 @@ Hello from your flake!
diff --git a/source/hello-flake/main.adoc0 b/source/hello-flake/main.adoc0 index 2e86417..ffb5c1f 100644 --- a/source/hello-flake/main.adoc0 +++ b/source/hello-flake/main.adoc0 @@ -55,3 +55,17 @@ $# rm temp.sh $# echo '$ '${executable} $# ${executable} .... + +== Flake outputs + +You can find the outputs of a flake using the `nix flake show` command. + +.... +$# echo '$ nix flake show --all-systems git+https://codeberg.org/mhwombat/hello-flake' +$# nix flake show git+https://codeberg.org/mhwombat/hello-flake --quiet | sed -e 's/\x1b\[[0-9;]*m//g' +.... + +Examining the output of this command, +we see that this flake supports multiple architectures +(aarch64-darwin, aarch64-linux, x86_64-darwin and x86_64-linux) +and provides both a package and an app called `hello`. diff --git a/source/recipes/build/flake/tempwork/flake.nix b/source/recipes/build/flake/tempwork/flake.nix deleted file mode 100644 index 329e231..0000000 --- a/source/recipes/build/flake/tempwork/flake.nix +++ /dev/null @@ -1,47 +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 - { - packages = rec { - hello = pkgs.stdenv.mkDerivation rec { - name = "hello-again"; - - src = ./.; - - unpackPhase = "true"; - - buildPhase = ":"; - - installPhase = - '' - mkdir -p $out/bin - cp $src/hello-again $out/bin - chmod +x $out/bin/hello-again - - # modify the hello-again script so it can find hello-flake - HELLO=$(type -p hello-flake) - sed "s_hello-flake_"$HELLO"_" --in-place $out/bin/hello-again - ''; - - - buildInputs = [ hello-flake.packages.${system}.hello ]; - }; - default = hello; - }; - - apps = rec { - hello = flake-utils.lib.mkApp { drv = self.packages.${system}.hello; }; - default = hello; - }; - } - ); -} diff --git a/source/recipes/build/flake/tempwork/hello-again b/source/recipes/build/flake/tempwork/hello-again deleted file mode 100755 index f75e067..0000000 --- a/source/recipes/build/flake/tempwork/hello-again +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh - -echo "I'm a flake, and I'm running a command defined in a another flake." -hello-flake diff --git a/source/recipes/devshell/flake/main.adoc0 b/source/recipes/devshell/flake/main.adoc0 index 5d7dd3a..a4ff83e 100644 --- a/source/recipes/devshell/flake/main.adoc0 +++ b/source/recipes/devshell/flake/main.adoc0 @@ -28,16 +28,7 @@ $# grep buildInputs flake.nix | sed 's/ //g; s/.*\[//; s/\].*//' 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. - -.... -$# echo '$ nix flake show git+https://codeberg.org/mhwombat/hello-flake' -$# nix flake show git+https://codeberg.org/mhwombat/hello-flake --quiet | sed -e 's/\x1b\[[0-9;]*m//g' -.... - -Examining the output of this command, -we see that this flake provides both a package and an app called `hello`. +(See <<_flake_outputs>> for how to identify flake outputs.) Here's a demonstration using the shell. diff --git a/source/recipes/build/flake/tempwork/flake.lock b/source/recipes/devshell/flake/tempwork/flake.lock similarity index 94% rename from source/recipes/build/flake/tempwork/flake.lock rename to source/recipes/devshell/flake/tempwork/flake.lock index af219d2..aabac4f 100644 --- a/source/recipes/build/flake/tempwork/flake.lock +++ b/source/recipes/devshell/flake/tempwork/flake.lock @@ -72,11 +72,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1757945769, - "narHash": "sha256-z/SdByTaDnEx4Zj0pyMwzY+uKxV/2TpQQ6ZKijKc2t0=", + "lastModified": 1757952092, + "narHash": "sha256-BcfTLFCU7elUJ2dwyt0iTjxsz/XLh+8ZygDcFwy6xPE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "62b2408b85dc46dab0b8ca4250471b9cb23425f0", + "rev": "fd76dc9e7c68ac7c3941ba2af2bedcd79c5cf4ed", "type": "github" }, "original": { 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 ]; + }; + }; + } + ); +}