Conversation
Wrap github-cli `gh` using nix-wrapper-module
take the env block out of drv block inside config block
Add `import = [ wlib.modules.default ];`
wrapperModules/g/gh/module.nix
Outdated
| buildPhase = '' | ||
| runHook preBuild | ||
| mkdir -p "${placeholder config.outputName}/gh-config" | ||
| cp "$(cat "$configYmlPath")" "${placeholder config.outputName}/gh-config/config.yml" |
There was a problem hiding this comment.
Since we are already doing some complicated thing here to build the directory, we can make this do placeholders without much extra effort, if you want?
If you set config.drv.nativeBuildInputs = [ pkgs.remarshal_0_17 ];
You can then configContent = builtins.toJSON config.settings;
and json2yaml $configContentPath "${placeholder config.outputName}/gh-config/config.yml" instead of this copy command.
Which is how they do it in nixpkgs
Alternatively, if you don't want all that, we should be able to simplify this line to
cp "$configYml" "${placeholder config.outputName}/gh-config/config.yml"
and then remove the passAsFile, which is not necessary in this case. configYml in this case as it is currently written contains a path. A single path is very very unlikely to ever exceed the max length for a variable. So if we are going to continue using .generate, you don't need passAsFile there either.
pass configYml directly to buildPhase
|
So, I found a problem with this approach. It tries to write to its config directory, which is now in the store. Any chance we can do this with |
|
Uh, yeah, I wanted to tell you about this problem. A similar one arises where the file Also there's this issue on home-manager. Seems that |
|
home manager handles it by putting these files in system locations, such that hosts.yml is writable despite config.yml not being writable. Because they have an activation script. And We could set the variable to somewhere outside the store and do runShell and copy it there from the store at runtime before it runs if it isnt maybe? Make sure to make that path configurable and save any files that are there with some extension, also configurable? Its annoying though. If we did that, you should make the thing you call via runShell also available in the drv to run separately, and some way to choose if it is to ran at runtime automatically or not. It also looks like they list ALL settings as environment variables. Maybe we just list them all out as explicit options? I somewhat did that for the tmux stuff. But then you, or somebody at least, would have to add more when they add more (if they do). However, it looks like that is a standardized mapping There is a GH_UPPERCASED version of each setting https://cli.github.com/manual/gh_help_environment https://cli.github.com/manual/gh_config You should investigate to see if that is an actual thing and they automatically map that intentionally, or just a convention they follow. Im out of ideas for now though |
Wrap github-cli
ghusing nix-wrapper-modules.