From f5c1ce6b11f9a056de760ec6b83c224ae6881617 Mon Sep 17 00:00:00 2001 From: Evan Hanson Date: Fri, 2 Dec 2022 16:54:10 +1300 Subject: [PATCH] Add flake example to documentation --- nix.md | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/nix.md b/nix.md index 575b1bd..9a5170b 100644 --- a/nix.md +++ b/nix.md @@ -22,13 +22,39 @@ to pull into scope, for example: } You can use a specific version of the Nix packages collection by setting the -`pkgs` property in the import statement. By default, the `` path is -used: +`pkgs` property of the library. By default, the `` path is used: with import (fetchTarball https://git.sr.ht/~evhan/beaker/archive/master.tar.gz) { - pkgs = import {}; + pkgs = your.nixpkgs.collection; }; +==== With Flakes + +This project can be used directly with Nix flakes, using the same repository +archive URL as an input. + +The following example will pin an input version of this project and force it +to use the same version of `nixpkgs` as the flake itself. The `beaker` library +will be passed to the `outputs` builder, and you can access the helpers for a +specific system via `beaker.packages.${system}`: + + { + inputs = { + beaker.url = "https://git.sr.ht/~evhan/beaker/archive/0.0.17.tar.gz"; + beaker.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, beaker }: + let + system = "x86_64-linux"; + in { + packages.${system}.default = beaker.packages.${system}.eggProgram { + name = "example-flake"; + src = ./.; + }; + }; + } + === Fetching Egg Dependencies [procedure] eggCache attrSet -- 2.45.2