Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declaring perSystem output that is not a package #241

Open
lenianiva opened this issue Aug 17, 2024 · 1 comment
Open

Declaring perSystem output that is not a package #241

lenianiva opened this issue Aug 17, 2024 · 1 comment

Comments

@lenianiva
Copy link

lenianiva commented Aug 17, 2024

I want to declare an output in perSystem.packages or perSystem that is not a package. The use case is that an upstream project (Lean4 in this example) has a function buildPackage which generates a custom set of attributes containing metadata, but the set of attributes is itself not a package. I need to expose this metadata to downstream users.

{
  description = "Mystery";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    flake-parts.url = "github:hercules-ci/flake-parts";
    mystery-builder = {
      ...
    };
  };

  outputs = inputs @ {
    self,
    nixpkgs,
    flake-parts,
    mystery-builder,
    ...
  } : flake-parts.lib.mkFlake { inherit inputs; } {
    flake = {
    };
    systems = [
      "x86_64-linux"
      "x86_64-darwin"
    ];
    perSystem = { system, pkgs, ... }: let
      builder = mystery-builder.packages.${system};
      project = builder.buildPackage {
        src = ./.;
      };
    in rec {
      packages = {
        inherit (project) sharedLib executable;
        inherit project;
        default = project.executable;
      };
    };
  };
}

In this case I want to expose the output project. If I do this directly, I get

       error: A definition for option `perSystem.x86_64-linux.packages.project' is not of type `package'. Definition values:
       - In `/nix/store/id24xzy1kvigzs141gz2ncxc8n2pl0sf-source/flake.nix, via option perSystem':
           {
             allExternalDeps = [
               {
                 allExternalDeps = [
                   {
           ...

Is there a way to expose this output so I can use it in another derivation in the form of mystery.packages.${system}.project?

@lenianiva
Copy link
Author

legacyPackages would work here, but IMHO it needs a better name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant