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

feat: Support reading default init sources from ~/.hermit.hcl #434

Closed
wants to merge 2 commits into from

Conversation

lox
Copy link
Contributor

@lox lox commented Feb 12, 2025

This PR introduces a new init_sources field to the Hermit user configuration file (~/.hermit.hcl). This field allows users to specify a default set of sources to be used when initializing a new Hermit environment with the hermit init command.

Example ~/.hermit.hcl:

init_sources = [
  "https://github.com/lox/private-hermit-packages.git", 
  "https://github.com/cashapp/hermit-packages.git"
]

This means any call to hermit init will use these sources.

@lox lox marked this pull request as ready for review February 12, 2025 04:29
@lox
Copy link
Contributor Author

lox commented Feb 12, 2025

I'm testing it with:

rm -rf ~/test-hermit; mkdir ~/test-hermit; go run ./cmd/hermit -t init ~/test-hermit

I see the sources added correctly to ~/test-hermit/bin/hermit.hcl.

I couldn't see any existing tests for the area, any suggestions there?

@nickajacks1
Copy link
Contributor

I couldn't see any existing tests for the area, any suggestions there?

Perhaps it makes sense to add tests in it/full?
LoadUserConfig would probably need to be updated to be able to load from a custom path though.

@lox
Copy link
Contributor Author

lox commented Feb 12, 2025

I can't seem to get rid of this log line:

2025/02/12 15:29:58 ~/.hermit.hcl: 2:1: found extra fields "init_sources"

@lox lox force-pushed the lox/user-config-sources branch from 146f5fb to b27f060 Compare February 13, 2025 04:17
@lox
Copy link
Contributor Author

lox commented Feb 13, 2025

@nickajacks1 tests added!

@nickajacks1
Copy link
Contributor

@lox I got some failed tests when running the full test, can you check that?
Example

  34) Hermit Isolated Runtime dependencies can call isolatedenv2 binary from testenv
      When call ./bin/isolatedenv2

      34.1) The stderr should be blank

              expected: blank (unset or zero length string)
                   got: "userConfigPath:
              2025/02/16 18:07:47 : read /home/njackson/source/hermit/it/full/testenv: is a directory
              userConfigPath:
              2025/02/16 18:07:47 : read /home/njackson/source/hermit/it/full/testenv: is a directory
              userConfigPath:
              2025/02/16 18:07:48 : read /home/njackson/source/hermit/it/full/testenv: is a directory"

            # spec/it_spec.sh:439

@lox lox force-pushed the lox/user-config-sources branch from b27f060 to d98bac4 Compare February 17, 2025 22:26
@alecthomas
Copy link
Collaborator

Maybe you want github-token-auth to be read from there as well?

@lox
Copy link
Contributor Author

lox commented Feb 18, 2025

Yup, absolutely, was going to do that in another PR unless you want it here @alecthomas

Allow users to specify default sources for new environments in
~/.hermit.hcl using the init-sources configuration option. These
sources will be used when initializing a new environment unless
overridden by command-line arguments.
@lox lox force-pushed the lox/user-config-sources branch from d98bac4 to 88b6f97 Compare February 18, 2025 05:51
@lox lox closed this Feb 18, 2025
alecthomas added a commit that referenced this pull request Feb 21, 2025
Adds support for user-level configuration defaults in Hermit. Users can
now define default settings in their ~/.hermit.hcl file that will be
applied to all new Hermit environments.

**Example ~/.hermit.hcl:**

```hcl
defaults {
  sources = [
    "https://github.com/lox/private-hermit-packages.git", 
    "https://github.com/cashapp/hermit-packages.git"
  ]
}
```

Also allows the user config file to be defined with `HERMIT_USER_CONFIG`
or `--user-config`.


This replaces the more narrowly scoped
#434.

---------

Co-authored-by: Alec Thomas <[email protected]>
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.

3 participants