jwaataja / tildeconfig

DSL for managing user space configuration settings
MIT License
0 stars 1 forks source link

Better support for installing system packages #2

Open daboross opened 4 years ago

daboross commented 4 years ago

Hi!

Would it be alright with you if I opened up a few issues on this repo & then sent some PRs? I've recently started really using two computers, so with that use case I've gotten more reason to really use tildeconfig. If you're open to it, I'd like to discuss direct in issues and file some PRs implementing changes.


For this issue, it'd be nice to have more support for system packages. I would implement:

For the os detection, I'm thinking the user (or standard library) could be able to write:

def_os_detection do ||
  result = system('lsb_release --id --short')
  return result.downcase if result
  # silent failure simply means the next os_detection script is called
end

Another alternative might be to abandon OS detection in favor of just knowing about various installers (apt, yum, dnf, pacman) and choosing packages based on those rather than the OS.

Thoughts on whether we want this?

jwaataja commented 4 years ago

I'd definitely like to work on this project more, so feel free to open as many issues and pull requests as you want.

I like this idea of having better OS detection and a def_os_detection method. For the specification of this method, I think on success it should return either a string or a symbol representing the name of the installer it found if it succeeds. If it fails, I think it would be better to explicitly require the method return nil. Usually a method in Ruby returns nil if it doesn't explicitly return anything else, so I think it would be more clear to make that explicit rather than rely on implicit nil returns.

There would also be a question of ordering the checks. I think LIFO would make the most sense because if users want to define their own detect methods, then they would expect those to supersede the built-in ones.

I don't think we would need to choose between lsb_release and detecting if particular package manager commands exist like apt. Having both would make the system more robust. I think it should check for a particular OS using lsb_release or sw_vers first and then fallback to detecting if commands exist.

Finally, if the OS can't be detected, I think the current behavior makes sense which is to print an error message but continue anyway.

If you want to work on this issue, please assign yourself. If you want me to work on it, assign me. Thanks!