Closed FunctionalHacker closed 2 years ago
Thanks! I'm happy dotdrop helps :+1:
I don't know termux but I understand the issue, maybe some of the below ideas might help.
The use of dynvariables
to set the distro is a good idea, maybe some of the below are returning something that helps you identify termux:
uname
if availablecat /etc/*release*
$OS
, $OSTYPE
, $PREFIX
, etctermux-setup-storage
)Another way would be for you to define two types of profiles:
os_arch
, os_termux
, etc that would act as meta profile (that are never directly used but instead included by other profiles)host_home
, host_office
, etcEach Host profiles would include
an OS profile to inherit all their dotfiles (and variables) as well as defining their own.
Also in the OS profiles you would define a variable like os: some-distro
that you could use in your templates with {%@@ if os == "some-distro" @@%}
. You could then refine your if branches to a single test using os
instead of profile
.
profiles:
os_arch:
variables:
os: arch
dotfiles:
- f_xinitrc
os_termux:
variables:
os: termux
dotfiles:
- f_something
os_home:
include:
- os_arch
dotfiles:
- f_vimrc
os_work:
include:
- os_termux
dotfiles:
- f_someconfig
But of course I could also let dotdrop handle the detection of the OS and provide a variable for that (similar to the pre-defined template variables) but knowing the infinite amount of distros and OS, I have the feeling this will never be complete.
Thanks a lot for the ideas! I think with these I can get Termux working and make my current setup even better. I will leave this open and report my findings after I'm done.
But of course I could also let dotdrop handle the detection of the OS and provide a variable for that (similar to the pre-defined template variables) but knowing the infinite amount of distros and OS, I have the feeling this will never be complete.
I feel like this is something that would be of value to many users but I agree, it's impossible to get it to be 100% reliable and it would require some maintenance in the long run. Then again, we could just add support for a few OS'es at first to try it out and if people find it useful, I'm sure some PR's would be opened with support for more.
There seems to be some libraries for python that have implemented something similar. distro seems worth checking out.
Ok, I'll work a bit on the OS detection part and will ping you when I have something. Thanks for the pointer!
@FunctionalHacker I made an attempt at enriching variables in the enrich-variables branch.
As described here, a few variables are populated (when not defined by the user already) and available in templates such as os
, release
, etc. This should allow to more easily handle if
branch depending on OS/releases/distros/versions.
This is a first attempt and we can add more pre-defined variables in the future but maybe you want to give it a try?
@deadc0de6 awesome! I'm a bit busy with work for the next few days but I will surely try this on the weekend. I actually got termux to work with a hacky workaround, hopeful this would result in a cleaner setup.
Hello, I'm a happy user of dotdrop for many years now, so first of all thanks a lot for this wonderful software.
What I am trying to achieve I want to use dotdrop on Termux. The problem is, Termux (nor Android) use hostnames which is the way dotdrop detects profiles. I have already set up a profile called "localhost" and this solves most of my problems. Now I would like to do a bit of templating to deliver modified dotfile versions for my Termux setup only.
What I have tried so far
lsb_release
This command is not available for (this is being worked on to some extent)/etc/os-release
Same as aboveActually now that I think of it, detecting the distro would be beneficial for many other cases. Right now, I have many template conditions for groups of profiles
This is because I have to handle some things differently on machines that run a different distro. I run a mix of Arch Linux and Ubuntu. So the above if block could be simplified quite a bit by using the distro instead of the profile information.
I understand Termux is a bit out of the scope for dotdrop but I just wanted to open up some discussion since I could not find anything on it on the net. Someone in the future might save a bit of time by finding this discussion from Google. Any ideas are welcome.