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

Request: literally create files #5417

Open
upidapi opened this issue May 19, 2024 · 0 comments
Open

Request: literally create files #5417

upidapi opened this issue May 19, 2024 · 0 comments
Assignees

Comments

@upidapi
Copy link

upidapi commented May 19, 2024

Description

Add some way to create literal files (not just symlinks to files). This might be achievable by adding "home.file.<name>.mode", like environment.etc does for it's files. Where the default value is "symlink" but if you set to to, for example 700. Then it would just create a file with said permission (700).

Why?

This would be nice to have for files that programs feel a need to write to, but you need some default value/text, and you don't want to save the programs changes. You cant just use .source = (mkOutOfStoreSymlink "your-config/some-file"). Since this would propegate the changes that the program does to your config.

An example of where this would be nice is Vesktop. Where .config/vesktop/state.json has to have the field "firstLaunch" to avoid the welcome / initial config screen. But Vesktop writes to this file to save some other stuff like window pos/size etc. So id like to avoid having those changes show in my config since it dirties the git history.

The alternative is something like this:

    # vesktop checks if state.json has the "firstLaunch" to
    # determin if it should show the "Welcome to vesktop" page
    home.activation = {
      # We have to do it like this since vesktop needs be able to
      # write to it (a symlink to the store would have been unwritabe)
      # If vesktop cant write to it then it chrashes
      createVesktiopStateJson = let
        state_path = "~/.config/vesktop/state.json";
        data = builtins.toJSON {
          # (the other setting dont matter)
          firstLaunch = false; # the value of this is ignored lol
        };
      in
        lib.hm.dag.entryAfter ["linkGeneration"] ''
          echo '${data}' > ${state_path}
        '';
    };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants