NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.3k stars 14.27k forks source link

Settings/layout is re-ordered when building which causes the frontend to behave different than expected. #321803

Open bahmrockk opened 5 months ago

bahmrockk commented 5 months ago

Describe the bug

When translating the nix config to yaml the order of the layout-block within settings get destroyed. This is expected nix-behavior - but according to the homepage dashboard documentation ( https://gethomepage.dev/latest/configs/settings/ ) the order here is critical for the display order of items. I'm aware that this is expected from the default nix-to-yaml mechanics but I have no idea how I could address this in homepages context to still maintain a custom layout.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a new settings-block with a layouts-part:

      color = "slate";
      theme = "dark"; 
      layout = 
      {
          Media = {};
          Organization = {};
          Printers = {};
          Administration = {
            initiallyCollapsed = "true";
          };
          "Web Tools" = {};
          "AI Tools" = {};
        };
    };
  2. Observe that the generated file in /etc/hompage-dashboard/settings.yaml looks like this:

    layout:
    AI Tools: {}
    Administration:
    initiallyCollapsed: 'true'
    Media: {}
    Organization: {}
    Printers: {}
    Stock Stuff: {}
    Web Tools: {}
    theme: dark

Expected behavior

The layout-block needs to be able to follow a given order as this defines the order in which items are presented within the dashboard itself. Perhaps this can't be done but I wanted at least to raise the awareness :-)

Notify maintainers

@jnsgruk ping and thanks for the work!

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

`` - system:"x86_64-linux"`


Add a :+1: reaction to issues you find important.

bahmrockk commented 5 months ago

After a bit more trial and error I realized that Homepage accepts lists instead of mappings as well.

For anyone stumbling across this. This is the formatting for lists:

      [
        {  Media = {}; }
      ....
     ]

re/ this report: I suggest to simply expand the options documentation for settings by adding an example, analogue to the one in services.

To have a working suggestion in the room: Example:

{
   theme = "dark";
  layout = [
    { 
       Section B = { }; 
     }
     { 
        Section A = 
          {
            header = "false";
          };
     }
   }; 
  ] ;
}

I hope this example conveys my suggestion well enough!

jnsgruk commented 5 months ago

Hey! Thanks for figuring this out and sorry for the slight delay in response. If you want to create a PR to update the module docs I'd be happy to review it?

bahmrockk commented 5 months ago

No worries - and I'll happily give it a go, will take a few days though! I have to read into how to do that first :-)

jnsgruk commented 5 months ago

No problem, feel free to reach out if you need a hand!