Extend NixOS: Difference between revisions

imported>Bzm3r
Simplifying language, focusing purpose.
imported>Bzm3r
mNo edit summary
Line 1: Line 1:
This tutorial shows how to extend a NixOS configuration to include custom [[{{ic|systemd}}]] units, by creating a [[{{ic|systemd}}]] unit IRC client every time a system session starts. Beginning by adding functionality directly to a {{ic|configuration.nix}} file, it then shows how to abstract the functionality into a separate NixOS [[module]].  
This tutorial shows how to extend a NixOS configuration to include custom [[systemd]] units, by creating a [[systemd]] unit that initializes IRC client every time a system session starts. Beginning by adding functionality directly to a {{ic|configuration.nix}} file, it then shows how to abstract the functionality into a separate NixOS [[module]].  


= The Problem =
= The Problem =
Line 7: Line 7:
It is possible to find a variety of different ways to do this, but a simple modern approach that fits well within NixOS's {{declarative model}} is to declare a {{ic|systemd}} unit which initializes the IRC client upon session login by a user.
It is possible to find a variety of different ways to do this, but a simple modern approach that fits well within NixOS's {{declarative model}} is to declare a {{ic|systemd}} unit which initializes the IRC client upon session login by a user.


Assume that our IRC client is {{ic|irssi}} as the IRC client. We'll run it inside a [https://wiki.archlinux.org/title/GNU_Screen {{ic|screen}}] daemon, which apart from allowing us to {{multiplex}} our terminal sessions, also enables the IRC session to continue even after we log out of our shell session.
Assume that our IRC client is {{ic|irssi}} as the IRC client. We'll run it inside a [https://wiki.archlinux.org/title/GNU_Screen screen] daemon, which apart from allowing us to [https://en.wikipedia.org/wiki/Terminal_multiplexer multiplex] our terminal sessions, also enables the IRC session to continue even after we log out of our shell session.


= Implementations =
= Implementations =
Line 13: Line 13:
== Quick Implementation ==
== Quick Implementation ==


NixOS provides [https://search.nixos.org/options?channel=23.05&show=systemd a {{ic|systemd}} module] with a wide variety of configuration options. A small number of those (which you can check out on {{NixOS search}}) allows us to implement this small snippet within our {{ic|configuration.nix}}:
NixOS provides [https://search.nixos.org/options?channel=23.05&show=systemd a systemd module] with a wide variety of configuration options. A small number of those (which you can check out on {{NixOS search}}) allows us to implement this little snippet within our {{ic|configuration.nix}}:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">