Could someone check my code formatting and see if this looks better? Also do I have any packages that are redundant or not needed due to another package?

configuration.nix

home.nix

flake.nix

I have a gut feeling i might have extra packages in here that arent needed maybe?

At a glance, I’m not a fan of your indentation, but formatting is subjective. If you want something resembling an “objective” check, try a formatter. I think these are still the main options currently:

I probably dislike your formatting in part because you use hard tabs and GitHub defaults to a 4 space length, which goes against the usual 2 spaces for nix code, proving the age old argument for spaces over tabs still holds in 2023 even if nobody prints code anymore. And also showing that formatting is still the oldest bikeshedding exercise in the discipline.

You might not realize this is possible, so I’ll also point out you can write attrsets without splitting them apart. This usually gives you a natural grouping of blocks of related code, e.g. instead of how you currently configure the boot options, I find this much more legible:

boot = {
  loader = {
    systemd-boot.enable = true;
    efi.canTouchEfiVariables = true;
  };

  kernelPackages = pkgs.linuxPackages_zen;
  kernelModules = [ "drivetemp" ];
  kernelParams = [ "reboot=acpi" "coretemp" ];
};

The way you inconsistently split your flake inputs drives me particularly mad.

statix will also nag about this, making me hopeful it’s not just my fringe opinion. But again, formatting is subjective. I’ve seen people do what you do, and as much as I despise it some of them have written far more nix than I have.


You definitely do, but your package list is really, really, long, would take a while to dig through all of it. I’d suggest installing those packages over time, and not all at once, so you have time to figure out how what is supposed to work.

As an example, bluez and all the bluetooth related things should be installed using hardware.bluetooth.enable instead.

You also have lm_sensors listed twice in there, which I’m surprised doesn’t give you an error.

thanks, what method would you recommend for formatting? I havent done much with code since I was in AP Computer Science in High School

In general, I use autoformatters when they exist, or style guides when they do not, and don’t do anything else. Doing so means that nobody has to waste time bikeshedding, because it’s clearly defined what the format should be, and if you still want to bikeshed, I can tell you to take it upstream where it is not bikeshedding by definition.

It also means you’ll be writing your code in a style that conforms to the style of a large group of people using the language you’re writing in, which means that it follows an expected pattern and is therefore naturally more readable.

So, pick one of the two projects I linked, and just run your code through them. They’ll do fine.

Similar projects exist for most programming languages if you want to do non-nix things, there is a vscode plugin for php for example, given you seem to do a lot of php and use vscode.

AP Computer Science in High School

Man, given your bio I’m amazed there are places where CS was even an option in High School back then. Welcome back, I suppose, things have changed a bit!

Yeah you ain’t kidding LOL 1996-1997 was nuts, we learned in Pascal back then LOL
And before that BASIC :stuck_out_tongue:

@TLATER Can you check the updated format?
Here are the links to my nix files:
configuration.nix
home.nix
flake.nix
mysql.nix
vscode.nix
wordpress.nix

I think it looks good, ill have to go through my apps later the system is working at least :male_detective:

Yep, looks much better to me. Do also give statix a try at some point :slight_smile:

I just had a quick look at your package list and there’s definitely some redundant stuff there:

  • NixOS bundles some things (like the GNU coreutils) per default, so you don’t need to add e.g. which to environment.systemPackages`.
  • Installing libraries does nothing in NixOS, so these can be removed (e.g. libuvc).

To clean up the config, I’d recommend you just remove everything from the package list that you don’t recognize. This usually means that you don’t need it and otherwise you can just add it back when you notice that it’s missing.

Also, anything in environment.systemPackages does not need to be added to home.packages. Right now, you’re essentially telling NixOS twice that you want those packages to be installed.