Skip to content

Latest commit

 

History

History
114 lines (86 loc) · 4.09 KB

README_NIXOS.md

File metadata and controls

114 lines (86 loc) · 4.09 KB

Using the agda-algebras library as a Nixpkgs overlay.

Detailed Instructions

  1. Add the Flake URL to Inputs in Your flake.nix: To use the agda-algebras overlay, you need to reference the flake in your project's flake.nix file. This allows Nix to fetch the overlay from your GitHub repository (or another location where the flake is hosted).

    Here's an example flake.nix for a user project:

    {
      description = "Example project using the agda-algebras overlay";
    
      inputs = {
        nixpkgs.url = "github:NixOS/nixpkgs";
        agda-algebras.url = "github:yourusername/agda-algebras";  # Replace with your actual GitHub username and repository name
      };
    
      outputs = { self, nixpkgs, agda-algebras }:
        let
          # Import Nixpkgs with the agda-algebras overlay applied.
          pkgs = import nixpkgs { overlays = [ agda-algebras.overlay ]; };
        in
        {
          # Define a development shell environment that includes agda-algebras.
          devShells.default = pkgs.mkShell {
            buildInputs = [ pkgs.haskellPackages.agda-algebras ];
          };
    
          # Optional: Define other outputs such as packages, apps, etc.
          packages.default = pkgs.stdenv.mkDerivation {
            name = "example-package";
            src = ./.;
            buildInputs = [ pkgs.haskellPackages.agda-algebras ];
          };
        };
    }
  2. Use the Overlay in Your Nixpkgs Configuration: The above example already includes the necessary configuration to use the overlay. By adding agda-algebras.overlay to the overlays list when importing nixpkgs, you ensure that agda-algebras is available as part of haskellPackages.

  3. Install the Library via haskellPackages.agda-algebras: With the overlay applied, you can reference haskellPackages.agda-algebras in your buildInputs. This makes the library available in your development environment or for use in building other packages.

    Example Usage in a Development Shell

    To enter a development shell that includes the agda-algebras library, simply run:

    nix develop

    This command will drop you into a shell environment where haskellPackages.agda-algebras is available, along with all other dependencies specified in the devShell section.

Summary of Instructions

  1. Add the Flake URL: In your project's flake.nix, add the URL of the agda-algebras flake to the inputs section.

    inputs.agda-algebras.url = "github:yourusername/agda-algebras";
  2. Use the Overlay: Apply the agda-algebras overlay by adding it to the overlays list when importing nixpkgs.

    pkgs = import nixpkgs { overlays = [ agda-algebras.overlay ]; };
  3. Install the Library: Reference the library in your buildInputs to include it in your environment.

    buildInputs = [ pkgs.haskellPackages.agda-algebras ];

Complete Example of flake.nix for User Project

Here's the complete flake.nix file for a hypothetical user project using the agda-algebras overlay:

{
  description = "Example project using the agda-algebras overlay";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    agda-algebras.url = "github:yourusername/agda-algebras";  # Replace with your actual GitHub username and repository name
  };

  outputs = { self, nixpkgs, agda-algebras }:
    let
      # Import Nixpkgs with the agda-algebras overlay applied.
      pkgs = import nixpkgs { overlays = [ agda-algebras.overlay ]; };
    in
    {
      # Define a development shell environment that includes agda-algebras.
      devShells.default = pkgs.mkShell {
        buildInputs = [ pkgs.haskellPackages.agda-algebras ];
      };

      # Optional: Define other outputs such as packages, apps, etc.
      packages.default = pkgs.stdenv.mkDerivation {
        name = "example-package";
        src = ./.;
        buildInputs = [ pkgs.haskellPackages.agda-algebras ];
      };
    };
}

By following these detailed instructions, users can easily integrate the agda-algebras library into their Nix-based projects using the overlay mechanism.