Extend NixOS: Difference between revisions

imported>Ixxie
update pkgs.lib to lib to bring this up to date.
imported>Ixxie
No edit summary
Line 50: Line 50:
We can use the <code>mkIf</code> function in the <code>configuration.nix</code> file to add conditional behavior. Here's the new implementation:
We can use the <code>mkIf</code> function in the <code>configuration.nix</code> file to add conditional behavior. Here's the new implementation:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
  {config, pkgs, ...}:
  {config, pkgs, lib, ...}:
   
   
  {
  {
   systemd.services = pkgs.lib.mkIf (config.networking.hostname == "my-server") {
   systemd.services = lib.mkIf (config.networking.hostname == "my-server") {
       ircSession = {
       ircSession = {
         wantedBy = [ "multi-user.target" ];  
         wantedBy = [ "multi-user.target" ];  
Line 67: Line 67:
   };
   };
   
   
   environment.systemPackages = pkgs.lib.mkIf (config.networking.hostname == "my-server") [ pkgs.screen ];
   environment.systemPackages = lib.mkIf (config.networking.hostname == "my-server") [ pkgs.screen ];
   
   
   # ... usual configuration ...
   # ... usual configuration ...