Learn flakes the fun way

This commit is contained in:
Daniel Flanagan 2024-07-08 12:40:25 -05:00
parent 72e86a7324
commit dcf840dc6f

22
post.md
View file

@ -152,7 +152,7 @@ index 99d6d52..81e98c9 100644
devShells = pkgsFor (pkgs: { devShells = pkgsFor (pkgs: {
``` ```
```bash ```console
$ docker load < $(nix build .#docker-image --print-out-paths) $ docker load < $(nix build .#docker-image --print-out-paths)
Loaded image: what-is-my-ip-docker:c9g6x30invdq1bjfah3w1aw5w52vkdfn Loaded image: what-is-my-ip-docker:c9g6x30invdq1bjfah3w1aw5w52vkdfn
$ docker run -it what-is-my-ip-docker:c9g6x30invdq1bjfah3w1aw5w52vkdfn $ docker run -it what-is-my-ip-docker:c9g6x30invdq1bjfah3w1aw5w52vkdfn
@ -168,19 +168,6 @@ diff --git a/flake.nix b/flake.nix
index 99d6d52..81e98c9 100644 index 99d6d52..81e98c9 100644
--- a/flake.nix --- a/flake.nix
+++ b/flake.nix +++ b/flake.nix
@@ -10,6 +10,12 @@
in {
packages = pkgsFor (pkgs: {
default = pkgs.callPackage ./what-is-my-ip.nix {};
+ container = pkgs.dockerTools.buildImage {
+ name = "what-is-my-ip-container";
+ config = {
+ Cmd = ["${self.outputs.packages.${pkgs.system}.default}/bin/what-is-my-ip"];
+ };
+ };
});
devShells = pkgsFor (pkgs: {
@@ -20,5 +26,27 @@ @@ -20,5 +26,27 @@
''; '';
}; };
@ -219,13 +206,10 @@ $ ./result/bin/run-nixos-vm
nixos login: alice nixos login: alice
Password: Password:
[alice@nixos:~]$ which what-is-my-ip $ readlink $(which what-is-my-ip)
/etc/profiles/per-user/alice/bin/what-is-my-ip
[alice@nixos:~]$ readlink $(which what-is-my-ip)
/nix/store/lr6wlz2652r35rwzc79samg77l6iqmii-what-is-my-ip/bin/what-is-my-ip /nix/store/lr6wlz2652r35rwzc79samg77l6iqmii-what-is-my-ip/bin/what-is-my-ip
[alice@nixos:~]$ what-is-my-ip $ what-is-my-ip
24.5.113.148 24.5.113.148
``` ```