From c07ac3b6c05ada77749ba2ed97c7112bda9d80c8 Mon Sep 17 00:00:00 2001 From: Charlie Groves Date: Sun, 8 May 2022 22:18:17 -0400 Subject: [PATCH] Fix examples to work with Nix >= 2.7 (#467) --- blog/nix-flakes-1-2022-02-21.markdown | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/blog/nix-flakes-1-2022-02-21.markdown b/blog/nix-flakes-1-2022-02-21.markdown index e28ec80..ae189e3 100644 --- a/blog/nix-flakes-1-2022-02-21.markdown +++ b/blog/nix-flakes-1-2022-02-21.markdown @@ -207,12 +207,12 @@ Let's take a closer look at the higher level things in the flake: your `flake.nix`. Ditto with "flake input" referring to the `inputs` attribute of your `flake.nix`.](conversation://Cadey/enby) -When you ran `nix build` earlier, it defaulted to building the package in -`defaultPackage`. You can also build the `go-hello` package by running this +When you ran `nix build` earlier, it defaulted to building the `default` entry +in `packages`. You can also build the `default` package by running this command: ```console -$ nix build .#go-hello +$ nix build .#default ``` And if you want to build the copy I made for this post: @@ -234,11 +234,13 @@ simplify that above `nix build` and `./result/bin/go-hello` cycle into a single `go-hello` to be the default app: ```nix -# below defaultPackage +# below packages -defaultApp = forAllSystems (system: { - type = "app"; - program = "${self.packages.${system}.go-hello}/bin/go-hello"; +apps = forAllSystems (system: { + default = { + type = "app"; + program = "${self.packages.${system}.default}/bin/go-hello"; + }; }); ``` @@ -281,8 +283,10 @@ can add it to your `flake.nix` using this: devShell = forAllSystems (system: let pkgs = nixpkgsFor.${system}; - in pkgs.mkShell { - buildInputs = with pkgs; [ go gopls goimports go-tools ]; + in { + default = pkgs.mkShell { + buildInputs = with pkgs; [ go gopls gotools go-tools ]; + }; }); ```