Skip to content

Conversation

@kakkun61
Copy link
Contributor

@kakkun61 kakkun61 commented Sep 3, 2024

What is this

This make options.run's readOnly true.

And configFile and installStages will be public so that a customized run may use them.

Why is this

For instance a repository having Git submodules will use additional flake inputs which is the same with the submodules.

$ git submodule add … foo
{ inputs.foo.url = "…";;
  outputs = { self, foo, ... }: {
    # build or do something after storing foo contents to ./foo
    # like: preBuild = "ln -s ${submodules.otlp-protobufs}/* -t proto";
  };
}

In this case we want to customize run to store foo before running pre-commit command similarly like:

git-hooks.lib.${system}.run {
  src = ./.;
  hooks = pre-commit-hooks;
  imports = [
    ({ config, lib, pkgs, ... }: {
      run = pkgs.runCommand "pre-commit-run" {buildInputs = [pkgs.git config.package];} ''
        set +e
        HOME=$PWD
        cp -R ${config.rootSrc} src
        chmod -R +w src
        ln -fs ${config.configFile} src/.pre-commit-config.yaml
        # 👇 Inserted
        mkdir src/foo
        ln -s ${foo}/* -t src/foo
        # 👆
        cd src

      '';
    })
  ];
};

This change supports more complex use cases.

@sandydoo sandydoo merged commit b6ee9db into cachix:master Mar 1, 2025
6 checks passed
@kakkun61 kakkun61 deleted the customizable-run branch March 1, 2025 17:06
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

Successfully merging this pull request may close these issues.

2 participants