functional.cafe is one of the many independent Mastodon servers you can use to participate in the fediverse.
functional.cafe is an instance for people interested in functional programming and languages.

Server stats:

214
active users

Okay. Time to learn some more than just using it for local development!

I have a server running 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. 😇)

Public

@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 = { ... };

Public

@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! 😅)

Public

@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.

Public

@eh relevant documentation:

- callPackage design pattern
- how to package a Haskell program in nixpkgs
- NixOS modules making use of systemd.services

Public

@raito Thank you so much! I’ll do some reading and experimentation.

Public

@eh the best place to get answers to this kind of stuff is probably matrix.to/#/#nix:nixos.org

matrix.toYou're invited to talk on MatrixYou're invited to talk on Matrix