Okay. Time to learn some more #nix than just using it for local development!
I have a server running #nixos 23.05 and I want to set up some services that I have written myself. The first service is a simple IRC bot written in Haskell.
Where do I begin?
It should basically end up with a binary on the server and a service that is pretty much just this:
```
[Service]
ExecStart=/some/where/my_silly_bot
Restart=always
```
Do I create some config in the git repo and refer to it from the nixos server? Am I creating a “module”? (I duckduckwent it, but not even knowing what concepts I should search for made it a bit difficult. )
@eh go into nixpkgs and look into some modules, you don't need to create a module, you can just build a systemd service unit :)
systemd.services.myprogram = { ... };
@raito Thanks!
I think I need to begin even earlier than that, though. Where would I put `systemd.services.myprogram = { … }`? Should that go in my nixos config? What will it point to? How would a binary end up on my server?
(Feel free to tell me to go read the fine manual if there is one you can point to! )
@eh It should go anywhere in the NixOS configuration, the binary would have to be packaged itself and you need to import it, e.g. you can run (pkgs.callPackage ./my-binary.nix { }) which will give you a derivation containing a bin/ folder with your binary, you can put it in environment.systemPackages or whatever.
If you are only interested into a systemd service:
systemd.services.myprogram = { serviceConfig.ExecStart = "${my-binary}/bin/my-binary"; };
would work.
@eh relevant documentation:
- callPackage design pattern
- how to package a Haskell program in nixpkgs
- NixOS modules making use of systemd.services
@eh the best place to get answers to this kind of stuff is probably https://matrix.to/#/#nix:nixos.org