llakala / nixos

My NixOS config
3 stars 1 forks source link

Improve our mkHost functions to be less repetitive #36

Closed llakala closed 3 weeks ago

llakala commented 3 weeks ago

After redoing the functions to be simpler, they end up resulting in a usage like this:

framework = myLib.mkNixos
{
  hostname = "framework";
};

The repetition of the hostname here is a bit silly. Ideally, it would create the hostname without the need to over-specify it.

Potential references: https://github.com/lilyb01/dotfiles/blob/526532e2193dec53f610cfbbadd9e5aeb746fa82/hosts/flake-module.nix#L6 https://github.com/Harmos274/nixfiles/blob/d00481cbf47225c8c0b981c8d73ab7e202de2c5b/lib/default.nix https://github.com/Goxore/nixconf/blob/22d969809cbfdad01133d5bbafa47617d0427c24/myLib/default.nix#L26

Also, searching things like mkHost, mkSystem, mkNixos, mkHome, etc on Github would probably give other helpful examples.

llakala commented 3 weeks ago

For an overengineered example, this one is awesome: https://github.com/Gerschtli/nix-config/blob/fe9549e6e398c0c35bf22bd29a6ecb92ba19e7de/flake.nix

llakala commented 3 weeks ago

Gorgeous: https://github.com/MattSturgeon/nix-config/blob/e98a93e3df0796413c413e223ea81f5d6af45f0e/hosts/flake-module.nix#L84

llakala commented 3 weeks ago

Done, with huge thanks to @MattSturgeon for having a wonderful resource with guessUsername and guessHostname.