home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

base.nix (3966B)


      1 { config, lib, pkgs, ... }:
      2 let
      3   inherit (lib) mkIf mkEnableOption mkDefault mkOption types;
      4   cfg = config.modules.desktop;
      5 in
      6 {
      7   options = {
      8     modules.desktop = {
      9       enable = mkEnableOption "desktop configuration";
     10       plymouth = {
     11         theme = mkOption {
     12           default = "deus_ex";
     13           description = "Plymouth theme to use for boot (hexagon, green_loader, deus_ex, cuts, sphere, spinner_alt)";
     14           type = types.str;
     15         };
     16         themePackage = mkOption {
     17           default = pkgs.my.adi1090x-plymouth;
     18           description = "Plymouth theme package to use";
     19           type = types.package;
     20         };
     21       };
     22     };
     23   };
     24   config = mkIf cfg.enable {
     25     modules.services.avahi.enable = true;
     26     # Enable netbootxyz if systemd-boot is enabled
     27     boot = {
     28       loader.systemd-boot.netbootxyz.enable = config.core.boot.systemd-boot;
     29       # /tmp to be tmpfs
     30       tmp = {
     31         useTmpfs = true;
     32         cleanOnBoot = true;
     33       };
     34       # Enable Plymouth on desktops
     35       plymouth = {
     36         enable = true;
     37         themePackages = [ cfg.plymouth.themePackage ];
     38         theme = cfg.plymouth.theme;
     39       };
     40     };
     41 
     42     # Configure some fonts
     43     fonts = {
     44       # enableFontDir = true;
     45       fontDir.enable = true;
     46       enableGhostscriptFonts = true;
     47       packages = with pkgs; [
     48         cascadia-code
     49         corefonts
     50         dejavu_fonts
     51         # emojione
     52         feh
     53         fira
     54         fira-code
     55         fira-code-nerdfont
     56         fira-code-symbols
     57         fira-mono
     58         font-awesome
     59         go-font
     60 	hack-font
     61         inconsolata
     62         inconsolata-nerdfont
     63         jetbrains-mono
     64         liberation_ttf
     65         nerdfonts
     66         noto-fonts
     67         noto-fonts-cjk
     68         noto-fonts-emoji
     69         noto-fonts-extra
     70         overpass
     71         symbola
     72         twemoji-color-font
     73         ubuntu_font_family
     74         unifont
     75 	recursive
     76       ];
     77     };
     78 
     79     # Enable NetkworManager by default
     80     networking.networkmanager = {
     81       enable = mkDefault true;
     82       unmanaged = [
     83         "interface-name:br-*"
     84         "interface-name:ve-*" # FIXME are those docker's or libvirt's
     85         "interface-name:veth-*" # FIXME are those docker's or libvirt's
     86       ]
     87       # Do not manager wireguard
     88       ++ lib.optionals config.networking.wireguard.enable [ "interface-name:wg0" ]
     89       # Do not manage docker interfaces
     90       ++ lib.optionals config.virtualisation.docker.enable [ "interface-name:docker0" ]
     91       # Do not manager libvirt interfaces
     92       ++ lib.optionals config.virtualisation.libvirtd.enable [ "interface-name:virbr*" ];
     93       plugins = with pkgs; [ networkmanager-openvpn ];
     94       # dispatcherScripts = [{
     95       #   # https://askubuntu.com/questions/1271491/disable-wifi-if-lan-is-connected
     96       #   source = pkgs.writeText "wifi-wired-exclusive" ''
     97       #     #!${pkgs.bash}/bin/bash
     98       #     export LC_ALL=C
     99       # 
    100       #     enable_disable_wifi ()
    101       #     {
    102       #         result=$(${pkgs.networkmanager}/bin/nmcli dev | ${pkgs.gnugrep}/bin/grep "ethernet" | ${pkgs.gnugrep}/bin/grep -w "connected")
    103       #         if [ -n "$result" ]; then
    104       #             ${pkgs.networkmanager}/bin/nmcli radio wifi off
    105       #         else
    106       #             ${pkgs.networkmanager}/bin/nmcli radio wifi on
    107       #         fi
    108       #     }
    109       # 
    110       #     if [ "$2" = "up" ]; then
    111       #         enable_disable_wifi
    112       #     fi
    113       # 
    114       #     if [ "$2" = "down" ]; then
    115       #         enable_disable_wifi
    116       #     fi
    117       #   '';
    118       #   type = "basic";
    119       # }];
    120     };
    121 
    122     nix = {
    123       # Enable SSH-serving nix packages
    124       sshServe.enable = mkDefault true;
    125     };
    126 
    127     services = {
    128       udisks2.enable = true;
    129 
    130       # Make `/run/user/X` larger.
    131       logind.extraConfig = ''
    132         RuntimeDirectorySize=20%
    133       '';
    134 
    135       # Enable printing by default too
    136       printing = {
    137         enable = true;
    138         drivers = [ pkgs.gutenprint ];
    139       };
    140     };
    141   };
    142 }