1
-2
-3
#!/usr/bin/env sh
-
-cowsay "Hello from your flake!"
-
-From f266726f4d73131bf21b217ca57652bd4bb17b42 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Amy=20de=20Buitl=C3=A9ir?= In this case, we need to write the derivation ourselves.
-We can use Unresolved directive in recipes/devshell/main.adoc - include::non-flake/main-generated.adoc[leveloffset=+1]If the nix derivation requires
nixpkgsdefault.nix as a model.
+We can use default.nix (from the hello-nix repo) as a model.
Line 15 should be replaced with:
1
-2
-3
#!/usr/bin/env sh
-
-cowsay "Hello from your flake!"
-
- 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
-40
-41
{
- 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-with-cow";
-
- src = ./.;
-
- unpackPhase = "true";
-
- buildPhase = ":";
-
- installPhase =
- ''
- mkdir -p $out/bin
- cp $src/hello-with-cow $out/bin
- chmod +x $out/bin/hello-with-cow
- '';
-
- buildInputs = [ pkgs.cowsay ];
- };
- default = hello;
- };
-
- apps = rec {
- hello = flake-utils.lib.mkApp { drv = self.packages.${system}.hello; };
- default = hello;
- };
- }
- );
-}
-
-Here’s a demonstration using the flake.
-$ nix run -this derivation will be built: - /nix/store/rlg4ym95l3jh9mv2mc1yd6qf0i2px844-hello-with-cow.drv -building '/nix/store/rlg4ym95l3jh9mv2mc1yd6qf0i2px844-hello-with-cow.drv'... -/nix/store/ps5mk6rvk7917f6ls58hz0ifs3580mq0-hello-with-cow/bin/hello-with-cow: line 3: cowsay: command not found-
Unresolved directive in recipes/build/main.adoc - include::flake/main-generated.adoc[leveloffset=+1]
@@ -5474,7 +5364,7 @@ Hello from your flake!