NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.96k stars 13.33k forks source link

Documentation: hostsblock #264311

Open ShalokShalom opened 9 months ago

ShalokShalom commented 9 months ago

Problem

The hostsblock readme explains to enable a provided systemd service. I am new to Nix, and fail to understand how this is supposed to work, as the provided command reports that the service is not available.

Here is the nix expression: https://github.com/NixOS/nixpkgs/blob/nixos-23.05/pkgs/tools/misc/hostsblock/default.nix And here are the services: https://github.com/gaenserich/hostsblock/tree/master/systemd The README: https://github.com/gaenserich/hostsblock#archinstall

Screenshot_20231030_090438

Checklist

FliegendeWurst commented 9 months ago

Did you add hostsblock to the systemPackages?

ShalokShalom commented 9 months ago

Nope, I had no idea I am supposed to. I did move it to the systemPackages and ran nixos-rebuild switch. It does not find the hostsblock services either.

I am used to hblock just working out of the box (on Arch) and that one is still maintained, while hostsblock seems deprecated.

There, I never needed to configure any systemd services, or anything.

eclairevoyant commented 9 months ago

Since there is no hostsblock module you essentially must make one yourself.

https://nixos.org/manual/nixos/stable/#sect-nixos-systemd-nixos

In order to enable a systemd system service with provided upstream package, use (e.g):

systemd.packages = [ pkgs.packagekit ];

And this is not pacman on arch, adding packages to environment.systemPackages alone is usually insufficient, as packages will never write outside of the store. You have to do some extra steps such as the above.

ShalokShalom commented 9 months ago

So writing a package isnt enough, some packages need modules on top, to do stuff like this, yes?