Skip to content

nix flake: use lib.mkAfter put the host list at the end #2814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

toastal
Copy link
Contributor

@toastal toastal commented Jan 30, 2025

At present, if a user uses networking.stevenBlockHosts.enable = true in tandem with networking.extraHosts, the extraHosts will put be put after which makes it very difficult to see the custom adds with even the $PAGER operating a bit slow due to file size. I would propose putting this project’s hosts at the end of the hosts file. Meaning:

{
  networking = {
    stevenBlockHosts.enable = true;
    extraHosts = ''
      127.0.0.1 myproject.localhost
    '';
  };
}

will now output

127.0.0.1 localhost
::1 localhost

127.0.0.1 myproject.localhost

# Title: StevenBlack/hosts with the fakenews extension
#
# …

NOTE: using lib.* like #2813 to avoid a potential merge conflict


Also has been open @ https://gitlab.com/StevenBlack/hosts/-/merge_requests/3

@toastal toastal force-pushed the nix-mkafter branch 2 times, most recently from db1d052 to dd05205 Compare February 22, 2025 14:42
@toastal toastal force-pushed the nix-mkafter branch 2 times, most recently from 8888ec1 to b2d5175 Compare March 9, 2025 03:33
@toastal toastal changed the title nix flake: use lib.mkAfter to allow extraHosts nix flake: use lib.mkAfter put the host list at the end Mar 11, 2025
@toastal toastal force-pushed the nix-mkafter branch 2 times, most recently from dbb555e to 2e56bfe Compare April 4, 2025 12:50
@toastal toastal force-pushed the nix-mkafter branch 2 times, most recently from d2af908 to c770cb7 Compare May 4, 2025 04:44
@toastal toastal force-pushed the nix-mkafter branch 2 times, most recently from b1aebb4 to d0e9a5d Compare May 22, 2025 20:43
At present, if a user uses ``networking.stevenBlockHosts.enable = true``
in tandem with ``networking.extraHosts``, the ``extraHosts`` will put be
put after which makes it very difficult to see the custom adds with even
the ``$PAGER`` operating a bit slow due to file size. I would propose
putting this project’s hosts at the end of the hosts file. Meaning:

.. code:: nix

  {
    networking = {
      stevenBlockHosts.enable = true;
      extraHosts = ''
        127.0.0.1 myproject.localhost
      '';
    };
  }

will now output

.. code::

  127.0.0.1 localhost
  ::1 localhost

  127.0.0.1 myproject.localhost

  # Title: StevenBlack/hosts with the fakenews extension
  #
  # …

Format: text/x-rst
Copy link
Contributor

@Pandapip1 Pandapip1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too familiar with the mkOrder-like nix functions, but this looks sane to me. Have not tested this, however, and this does seem like it has the potential of breaking things.

@toastal
Copy link
Contributor Author

toastal commented Jun 3, 2025

@Pandapip1 mkOrder will let you ‘unprioritize’ an appended string/list. In this case, since this hosts lists is 10s of 1000s of lines long, it is a pain to find your custom settings as even the $PAGER will chug on opening a file this long. But also Unix’s head is faster than tail due to how files work so this could really help those reading their settings.

@benjamb
Copy link

benjamb commented Jun 3, 2025

Not too familiar with the mkOrder-like nix functions, but this looks sane to me. Have not tested this, however, and this does seem like it has the potential of breaking things.

Agreed, changing the order has the potential to change the behaviour for users. Perhaps this could be controlled via another config option?

@toastal
Copy link
Contributor Author

toastal commented Jun 3, 2025 via email

@Pandapip1
Copy link
Contributor

I'm gonna assume that the author of this PR has tested this. Assuming it works correctly, this is good to merge and seems like a reasonable change.

@toastal
Copy link
Contributor Author

toastal commented Jun 4, 2025

@Pandapip1 I have tested for several months since I first opened the merge request on GitLab after the maker said GitLab was a supported mirror. …Hence many rebases.

@Pandapip1
Copy link
Contributor

Sounds like this should be merged then :shipit:

@benjamb
Copy link

benjamb commented Jun 10, 2025

I suppose given it's the first match that will be used, thus any overrides would need to be at the top, this does make sense. I think any chance of this changing the behaviour for any users is pretty slim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants