snowfallorg / nix-software-center

A simple gtk4/libadwaita software center to easily install and manage nix packages
GNU General Public License v3.0
529 stars 16 forks source link

FR: support for multi-files configuration.nix #33

Open Zahrun opened 1 year ago

Zahrun commented 1 year ago

My main configuration file is /etc/nixox/configuration.nix, however, I keep my environment.systemPackages in aroun.nix and have import in configuration.nix via

imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      ./aroun.nix
    ];

If the sofware-center parser could open the files under imports, parse them, and find the location of environment.systemPackages, that would be great

cf. https://github.com/vlinkz/nixos-conf-editor/issues/7

vlinkz commented 1 year ago

May not be exactly what you're looking for, but if you have a specific file containing environment.systemPackages that you want the software center to use, selecting that instead of configuration.nix in the preferences should work. But parsing imports is definitely something that would greatly expand configuration flexibility using this program!

Zahrun commented 1 year ago

Yes, for now I just point to the file where I have most of my systemPackages, and that works fine for me. As per the NixOS manual, it is possible to have multiple definitions of the same option, see https://nixos.org/manual/nixos/stable/index.html#sec-modularity.

Note that both configuration.nix and kde.nix define the option environment.systemPackages. When multiple modules define an option, NixOS will try to merge the definitions. In the case of environment.systemPackages, that’s easy: the lists of packages can simply be concatenated. The value in configuration.nix is merged last, so for list-type options, it will appear at the end of the merged list. If you want it to appear first, you can use mkBefore.