Skip to content
This repository was archived by the owner on Sep 1, 2025. It is now read-only.
This repository was archived by the owner on Sep 1, 2025. It is now read-only.

Allow users to customize outputs list #1223

@Ten0

Description

@Ten0

I'm considering using this project.

IIUC, I currently have two ways to generate an "output" for the CLI:

  1. use a builtin, and that will generate an arbirary number of targets depending on some magic in makes' own code
  2. use an extension, which always means creating a folder for the target, and having a main.nix in that folder.

What I want to achieve is the following directory structure:

project1
        /service1/<main or makes>.nix
        /service2/<main or makes>.nix
project2
        /service1/<main or makes>.nix
makes/service.nix

and I want my possible "OUTPUT"s in the CLI to look like this:

/project1/service1/build
/project1/service1/test
/project1/service1/run
/project1/service1/deploy
/project1/service2/build
/project1/service2/test
/project1/service2/run
/project1/service2/deploy
/project2/service1/build
/project2/service1/test
/project2/service1/run
/project2/service1/deploy

where the build/test/run/deploy outputs behavior are all defined by my /makes/service.nix

That means I need to be able to customize:

  • The list of targets that are made available from a <main or makes>.nixs (so that with a single nix file in a service folder I can declare the multiple targets that I need)
  • The arguments that are passed to the <main or makes>.nixs (to be able to pass import ./makes/service.nix)

My understanding is that this is not possible currently, and instead any such service.nix would have to be declared as a builtin in makes itself, and then I would put only the configuration of that in some makes.nix, which also means I could only instantiate one of each of those per makes.nix, whereas my ideal syntax would probably be:

# /project1/service1/<main or makes>.nix
{ args, service, pkgs, ... }: service { name = "a"; }
# /makes/service.nix
{ args, pkgs, makeScript, deployContainerImage, outputAttrSet, ... }:
let
  build = { /* ... */ };
  docker = pkgs.dockerTools.buildLayeredImage { /* ... */ };
  # Where args are the arguments pased as [ARGS...] to the CLI and may be used here
in
outputAttrSet {
  inherit build;
  deploy = deployContainerImage {
    images = [{
      src = docker;
      registry = { /* ... */ };
    }];
  };
  test = { /* ... */};
  run = makeScript { /* ... */ };
}

(where outputAttrSet would convert from the attrset of output to probably [{ name, derivation }], allowing for further customization if required)

Is it actually already possible to achieve something like this? If so, how? If not, is this something that could maybe be made possible in the future or are there any clear blockers?

Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions