~evhan/beaker

d5e67405e4d7da3d3afd566366f0b5e06329d32d — Evan Hanson 1 year, 9 months ago f5c1ce6
More flake documentation
3 files changed, 45 insertions(+), 38 deletions(-)

M flake.lock
M flake.nix
M nix.md
M flake.lock => flake.lock +1 -17
@@ 16,23 16,7 @@
    },
    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs",
        "utils": "utils"
      }
    },
    "utils": {
      "locked": {
        "lastModified": 1667395993,
        "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
        "nixpkgs": "nixpkgs"
      }
    }
  },

M flake.nix => flake.nix +16 -12
@@ 1,16 1,20 @@
{
  inputs = {
    utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, utils }:

  utils.lib.eachDefaultSystem (system:
  outputs = { self, nixpkgs }:
    let
      pkgs = import nixpkgs { inherit system; };
      beaker = import ./beaker.nix { inherit pkgs; };
      helpers = import ./default.nix { inherit pkgs; };
      systems = [ "aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-linux" ];
      forAllSystems = nixpkgs.lib.genAttrs systems;
      callForSystem = path: system: nixpkgs.legacyPackages.${system}.callPackage path {};
      eggHelper = name: system: args: (callForSystem ./. system).${name} args;
    in {
      packages = helpers // { default = beaker; };
    });
      lib = forAllSystems (callForSystem ./.) // {
        eggCache = { system, ... } @ args: eggHelper "eggCache" system args;
        eggDerivation = { system, ... } @ args: eggHelper "eggDerivation" system args;
        eggProgram = { system, ... } @ args: eggHelper "eggProgram" system args;
      };

      packages = forAllSystems (system: rec {
        beaker = callForSystem ./beaker.nix system;
        default = beaker;
      });
    };
}

M nix.md => nix.md +28 -9
@@ 28,15 28,14 @@ You can use a specific version of the Nix packages collection by setting the
      pkgs = your.nixpkgs.collection;
    };

==== With Flakes
==== Using Flakes

This project can be used directly with Nix flakes, using the same repository
archive URL as an input.
To use this project with Nix flakes, add the 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}`:
The following example will pin a version of this project as an input and force
it to use the same version of `nixpkgs` as the flake itself. The `beaker`
library is be passed to the `outputs` builder, and you can access the helpers
for a specific system via `beaker.lib.${system}`:

    {
      inputs = {


@@ 48,13 47,33 @@ specific system via `beaker.packages.${system}`:
        let
          system = "x86_64-linux";
        in {
          packages.${system}.default = beaker.packages.${system}.eggProgram {
            name = "example-flake";
          packages.${system}.default = beaker.lib.${system}.eggProgram {
            name = "example-using-flakes";
            src = ./.;
          };
        };
    }

==== Using Niv

To use this project with [Niv](https://github.com/nmattia/niv), add it
to your project sources:

    niv init
    niv add beaker -t https://git.sr.ht/~evhan/beaker/archive/0.0.17.tar.gz

Then create a `default.nix` with the following contents:

    let
      pkgs = import <nixpkgs> {};
      sources = import ./nix/sources.nix;
      beaker = import sources.beaker { inherit pkgs; };
    in
      beaker.eggProgram {
        name = "example-using-niv";
        src = ./.;
      }

=== Fetching Egg Dependencies

    [procedure] eggCache attrSet