mirror of
https://codeberg.org/mhwombat/nix-book.git
synced 2026-01-18 20:47:54 +08:00
temp
This commit is contained in:
parent
d9ba23304f
commit
e9e4271a47
7 changed files with 95 additions and 142 deletions
|
|
@ -5144,8 +5144,8 @@ However, you can use any of the flake reference styles defined in <a href="#flak
|
|||
<span class="normal">3</span>
|
||||
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><span class="tok-ch">#!/usr/bin/env sh</span>
|
||||
|
||||
<span class="tok-nb">echo</span><span class="tok-w"> </span><span class="tok-s2">"I'm a flake, but I'm running a command defined in a non-flake package."</span>
|
||||
hello-nix
|
||||
<span class="tok-nb">echo</span><span class="tok-w"> </span><span class="tok-s2">"I'm a flake, and I'm running a command defined in a another flake."</span>
|
||||
hello-flake
|
||||
</pre></div></td></tr></table></div></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -5594,7 +5594,7 @@ Hello from your flake!</pre>
|
|||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Last updated 2025-09-15 15:53:36 IST
|
||||
Last updated 2025-09-15 15:55:03 IST
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
|||
128
source/recipes/build/flake/tempwork/flake.lock
generated
128
source/recipes/build/flake/tempwork/flake.lock
generated
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -5,7 +5,7 @@ $ mkdir tempwork
|
|||
$ cd tempwork
|
||||
$ cp ../hello-again ../flake.nix .
|
||||
$ git add hello-again flake.nix
|
||||
$ nix develop
|
||||
$ nix build
|
||||
$ git add flake.lock
|
||||
$ git commit -a -m temp
|
||||
////
|
||||
|
|
@ -18,7 +18,7 @@ here we will focus on making it available at runtime.
|
|||
We will write a flake to package a very simple shell script.
|
||||
All it does is invoke `hello-nix`, which is the input we added <<#devshell-nix-non-flake,earlier>>.
|
||||
|
||||
[source,shell,linenums]
|
||||
[source,bash,linenums]
|
||||
.hello-again
|
||||
....
|
||||
$# cat hello-again
|
||||
|
|
|
|||
77
source/recipes/build/nix-non-flake/tempwork/flake.lock
generated
Normal file
77
source/recipes/build/nix-non-flake/tempwork/flake.lock
generated
Normal file
|
|
@ -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
|
||||
}
|
||||
|
|
@ -2,13 +2,17 @@
|
|||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
hello-flake.url = "git+https://codeberg.org/mhwombat/hello-flake";
|
||||
hello-nix = {
|
||||
url = "git+https://codeberg.org/mhwombat/hello-nix";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, hello-flake }:
|
||||
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
|
||||
{
|
||||
packages = rec {
|
||||
|
|
@ -27,13 +31,13 @@
|
|||
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)
|
||||
# modify the hello-again script so it can find hello-nix
|
||||
HELLO=$(type -p hello-nix)
|
||||
sed "s_hello-nix_"$HELLO"_" --in-place $out/bin/hello-again
|
||||
'';
|
||||
|
||||
|
||||
buildInputs = [ hello-flake ];
|
||||
buildInputs = [ helloNix ];
|
||||
};
|
||||
default = hello;
|
||||
};
|
||||
4
source/recipes/build/nix-non-flake/tempwork/hello-again
Executable file
4
source/recipes/build/nix-non-flake/tempwork/hello-again
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
echo "I'm a flake, but I'm running a command defined in a non-flake package."
|
||||
hello-nix
|
||||
Loading…
Add table
Add a link
Reference in a new issue