GithubHelp home page GithubHelp logo

Comments (15)

gvolpe avatar gvolpe commented on August 16, 2024 1

Try master, it generates this: https://github.com/gvolpe/dconf2nix/blob/master/output/json.nix

from dconf2nix.

gvolpe avatar gvolpe commented on August 16, 2024

How about this? This is how dconf2nix generates the entry.

"org/gnome/shell/extensions/sound-output-device-chooser" = {
  ports-settings = ''
    {"version":2,"ports":[]}
  '';
};

from dconf2nix.

lbssousa avatar lbssousa commented on August 16, 2024
"org/gnome/shell/extensions/sound-output-device-chooser" = {
  ports-settings = ''
    {"version":2,"ports":[]}
  '';
};

With this form, home-manager switch ends up with that error message:

Starting home manager activation
Activating checkFilesChanged
Activating checkLinkTargets
Activating writeBoundary
Activating installPackages
replacing old 'home-manager-path'
installing 'home-manager-path'
Activating dconfSettings
error: Key file contains line “'” which is not a key-value pair, group, or comment

from dconf2nix.

gvolpe avatar gvolpe commented on August 16, 2024

Okay. You're going to have to ask that to the Home Manager folks, maybe JSON is not even supported. If it requires escaping quotes or some different implementation, I'd be happy to work on it, but we need to be sure that HM supports it.

from dconf2nix.

johanbrandhorst avatar johanbrandhorst commented on August 16, 2024

Double quoting the JSON string and escaping the quotes inside works in my testing, though I don't know if we want to wait for some official clarification on what style is preferred.

from dconf2nix.

gvolpe avatar gvolpe commented on August 16, 2024

@johanbrandhorst can you share input and expected output? If that works for you, I can work on it. I don't use any JSON-like entries so this is not a problem for me :)

from dconf2nix.

johanbrandhorst avatar johanbrandhorst commented on August 16, 2024

Sure thing. The following input:

panel-element-positions='{"0":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":true,"position":"stackedBR"}],"1":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":true,"position":"stackedBR"}]}'

Should ideally produce the following output:

panel-element-positions = "{\"0\":[{\"element\":\"showAppsButton\",\"visible\":false,\"position\":\"stackedTL\"},{\"element\":\"activitiesButton\",\"visible\":false,\"position\":\"stackedTL\"},{\"element\":\"leftBox\",\"visible\":true,\"position\":\"stackedTL\"},{\"element\":\"taskbar\",\"visible\":true,\"position\":\"stackedTL\"},{\"element\":\"centerBox\",\"visible\":true,\"position\":\"stackedBR\"},{\"element\":\"rightBox\",\"visible\":true,\"position\":\"stackedBR\"},{\"element\":\"dateMenu\",\"visible\":true,\"position\":\"stackedBR\"},{\"element\":\"systemMenu\",\"visible\":true,\"position\":\"stackedBR\"},{\"element\":\"desktopButton\",\"visible\":true,\"position\":\"stackedBR\"}],\"1\":[{\"element\":\"showAppsButton\",\"visible\":false,\"position\":\"stackedTL\"},{\"element\":\"activitiesButton\",\"visible\":false,\"position\":\"stackedTL\"},{\"element\":\"leftBox\",\"visible\":true,\"position\":\"stackedTL\"},{\"element\":\"taskbar\",\"visible\":true,\"position\":\"stackedTL\"},{\"element\":\"centerBox\",\"visible\":true,\"position\":\"stackedBR\"},{\"element\":\"rightBox\",\"visible\":true,\"position\":\"stackedBR\"},{\"element\":\"dateMenu\",\"visible\":true,\"position\":\"stackedBR\"},{\"element\":\"systemMenu\",\"visible\":true,\"position\":\"stackedBR\"},{\"element\":\"desktopButton\",\"visible\":true,\"position\":\"stackedBR\"}]}"; 

from dconf2nix.

gvolpe avatar gvolpe commented on August 16, 2024

Ah okay so you meant escaping the double-quotes within the main double-quotes. I think this could be a potential workaround but let's wait a bit for the HM folks, I believe the current output produced by dconf2nix should be the way to go (raw JSON wrapped in double single-quotes, which allow multiline strings) since it's perfectly valid Nix.

from dconf2nix.

johanbrandhorst avatar johanbrandhorst commented on August 16, 2024

The current output of that input is not double single quotes in my experience. It produces:

panel-element-positions = "'{"0":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":true,"position":"stackedBR"}],"1":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":true,"position":"stackedBR"}]}'";

from dconf2nix.

johanbrandhorst avatar johanbrandhorst commented on August 16, 2024

master does indeed work fine for me, but I found a separate issue, will raise it separately.

from dconf2nix.

lbssousa avatar lbssousa commented on August 16, 2024

I've received the following feedback from nix-community/home-manager#2096 (comment):

The issue seems to be that multiline strings written in that fashion have a leading newline.

I don't use the dconf module/configuration so I don't know whether HM could always strip the first newline of a string.

It could break some wild configuration out there I suppose.

According to him, the following Nix code:

# Generated via dconf2nix: https://github.com/gvolpe/dconf2nix
{ lib, ... }:

let
  mkTuple = lib.hm.gvariant.mkTuple;
in
{
  dconf.settings = {
    "org/gnome/shell/extensions/sound-output-device-chooser" = {
      ports-settings = ''
        {"version":2,"ports":[]}
      '';
    };
  };
}

may lead to the following dconf setting:

[org/gnome/shell/extensions/sound-output-device-chooser]
ports-settings='{"version":2,"ports":[]}
'

The question is: whose is the responsability from removing this trailing newline: HM itself (may it break other HM settings?), HM dconf module (can it be done for this module only?) or dconf2nix (it should generate ports-settings = ''{"version":2,"ports":[]}'';)?

from dconf2nix.

rycee avatar rycee commented on August 16, 2024

HM master should now properly escape literal newlines in strings, which should fix the issue of invalid INI file generation.

from dconf2nix.

gvolpe avatar gvolpe commented on August 16, 2024

That's great to hear! I'll try it out soon as I can, and close this issue if all the tests pass.

from dconf2nix.

maydayv7 avatar maydayv7 commented on August 16, 2024

This issue seems to be fixed, with dconf2nix built from master (and dash-to-panel)

from dconf2nix.

gvolpe avatar gvolpe commented on August 16, 2024

Thanks for confirming @maydayv7 , I actually forgot to check. I'll close the issue then.

from dconf2nix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.