Fix examples to work with Nix >= 2.7 (#467)

This commit is contained in:
Charlie Groves 2022-05-08 22:18:17 -04:00 committed by GitHub
parent 06d4bf7d69
commit c07ac3b6c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 9 deletions

View File

@ -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 ];
};
});
```