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

Feature: Allow dotfiles to target root #22

Open
RaphGL opened this issue Jun 7, 2023 · 7 comments
Open

Feature: Allow dotfiles to target root #22

RaphGL opened this issue Jun 7, 2023 · 7 comments
Labels
enhancement New feature or request
Milestone

Comments

@RaphGL
Copy link
Owner

RaphGL commented Jun 7, 2023

While stow allows changing where to deploy dotfiles via flags tuckr does not, this makes so that one still needs stow to be installed on the system despite tuckr being as capable as it to track and manage dotfiles.

Root targeting should be implemented and allow users to manage global configuration from their home if they so wish.
Note: This has to take into account that when run as sudo the home path becomes the root's

Possible idiom for targeting root:

├── root
│   └── tuckrfiles
│       └── usr
│           └── local
│               └── etc
└── tuckrfiles
@RaphGL RaphGL added the enhancement New feature or request label Jun 7, 2023
@RaphGL
Copy link
Owner Author

RaphGL commented Sep 8, 2024

When targetting root, an easy way to mark a group as "root targeting" is by provide a sigil

@ seems to be a decent sigil option not used by any of the major shells
So groups that are targeting root could be used like so:

$ tuckr status
                                        
     ╭────────────┬───────────────╮     
     │ Symlinked  │ Not Symlinked │     
     ├────────────┼───────────────┤     
     │ alacritty  │ @pacman       │     
     │ bash       │               │     
     │ bspwm      │               │     
     │ zathura    │               │
     │ zsh        │               │     
     ╰────────────┴───────────────╯   

when using @ one has to be in running as root, tuckr knows that you're running as root by using system calls to know which user called sudo

$ sudo tuckr add @pacman

Globbing should ignore root targeting groups.
If root groups are used without root permissions an error should be emitted.

@RaphGL RaphGL added this to the 0.12.0 milestone Sep 18, 2024
@SlyCedix
Copy link
Contributor

SlyCedix commented Jan 6, 2025

In powershell the @ is reserved as the splat operator

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_splatting?view=powershell-7.4&viewFallbackFrom=powershell-6

Also, I don't think that root groups should be limited to root permissions, since it is not necessarily true that a user does not have access to the directory being configured, even when it is relative to the root. Say for example the destination directory exists in a mounted drive under /mnt.

This is probably doubly an issue for windows since configuration files tend to exist in a wide variety of places, not relative to the %USERPROFILE% directory. Accessing another drive without explicitly creating a sym-link that can be followed relative to the %USERPROFILE% is currently impossible, for example.

@RaphGL
Copy link
Owner Author

RaphGL commented Jan 6, 2025

In powershell the @ is reserved as the splat operator

I haven't used powershell extensively so I didn't know that. My unix bias really is showing :P

Also, I don't think that root groups should be limited to root permissions

You're 100% correct, I was just laser focused on being able to symlink binaries into one of the root $PATH directories. I'm definitely take that into consideration.

@RaphGL
Copy link
Owner Author

RaphGL commented Jan 7, 2025

I've been looking into which sigils are valid in the major shells out there and using something like ^group seems to work.
Shells tested: powershell, tcsh (used by BSDs), zsh (default on MacOS), bash (default on Linux), fish and dash.

Besides using ^group, I think I can get rid of the Configs/root directory altogether. While fixing a previous issue I saw that ^group is a valid file name on pretty much all the file systems and OSes we target. So we can just have something like this instead:

├── ^tuckrfiles
│       └── usr
│           └── local
│               └── etc
└── tuckrfiles

@SlyCedix
Copy link
Contributor

SlyCedix commented Jan 8, 2025

I haven't used powershell extensively so I didn't know that. My unix bias really is showing :P

If I had my way I'd not touch windows at all. Unfortunately, a lot of software approved by the government/military only ever supports windows, so high-security environments tend to only use unix for servers and embedded systems.

Another thing to note is that on windows, drives are mounted next to eachother, rather than as mounted directories relative to root. so you may need special provisions for users on windows selecting the drive. Perhaps treating each drive letter as a folder relative to the root. C:\Users\Public\... => /c/Users/Public/.... This is essentially how wine handles its emulated windows file system.

@SlyCedix
Copy link
Contributor

Another thing that that should be considered is some way to reference a folder by an environment variable, for example, %. This would allow for deployment of something where the path is not necessarily known.

Groups
└── cargo
    └── %CARGO_HOME
        └── config.toml

Using this embedded group mnemonic style means you could have single groups that access both the root directory, an env variable directory, and a home directory folder all at once.

Groups
└── cargo
    ├── %CARGO_HOME # Value of $CARGO_HOME
    ├── ^.cargo     # /.cargo/
    └── .cargo      # $HOME/.cargo/

Note that while % is the environment variable special character in cmd.exe on windows, the name must be fully enclosed: %CARGO_HOME%, so it can be used here.

@RaphGL
Copy link
Owner Author

RaphGL commented Jan 10, 2025

That's a very smart idea. I think that's much better than what I had in mind :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants