diff options
| author | nin <nineinchnade@gmail.com> | 2017-12-14 21:13:46 +0100 | 
|---|---|---|
| committer | nin <nineinchnade@gmail.com> | 2017-12-14 21:13:46 +0100 | 
| commit | 37771ad34e18e0657636c8d0eb5b7392e3b89ba6 (patch) | |
| tree | 8abda683b425494d2a273fc42d7573499b97a657 /lass/3modules | |
| parent | 7ed6fd18bb99884889a76ad9f597193861f44dc9 (diff) | |
| parent | 04f7ae22d6d0720d06f78c712eb9cd245cefce82 (diff) | |
Merge remote-tracking branch 'prism/master'
Diffstat (limited to 'lass/3modules')
| -rw-r--r-- | lass/3modules/default.nix | 1 | ||||
| -rw-r--r-- | lass/3modules/screenlock.nix | 2 | ||||
| -rw-r--r-- | lass/3modules/xresources.nix | 15 | ||||
| -rw-r--r-- | lass/3modules/xserver/default.nix | 101 | ||||
| -rw-r--r-- | lass/3modules/xserver/xserver.conf.nix | 40 | 
5 files changed, 151 insertions, 8 deletions
diff --git a/lass/3modules/default.nix b/lass/3modules/default.nix index e14e39bc2..81b52c306 100644 --- a/lass/3modules/default.nix +++ b/lass/3modules/default.nix @@ -11,6 +11,7 @@ _:      ./screenlock.nix      ./umts.nix      ./usershadow.nix +    ./xserver      ./xresources.nix    ];  } diff --git a/lass/3modules/screenlock.nix b/lass/3modules/screenlock.nix index 06ca1f27d..e16ce9868 100644 --- a/lass/3modules/screenlock.nix +++ b/lass/3modules/screenlock.nix @@ -23,7 +23,7 @@ let        before = [ "sleep.target" ];        wantedBy = [ "sleep.target" ];        environment = { -        DISPLAY = ":0"; +        DISPLAY = ":${toString config.services.xserver.display}";        };        serviceConfig = {          SyslogIdentifier = "screenlock"; diff --git a/lass/3modules/xresources.nix b/lass/3modules/xresources.nix index 074963022..017dbff2b 100644 --- a/lass/3modules/xresources.nix +++ b/lass/3modules/xresources.nix @@ -4,16 +4,13 @@  #prefix with Attribute Name  #ex: urxvt -# -#  with builtins;  with lib;  let -  inherit (import ../../tv/4lib { inherit pkgs lib; }) shell-escape; -  inherit (pkgs) writeScript; +  inherit (pkgs) writeScript writeText;  in @@ -46,12 +43,16 @@ in    config =      let        cfg = config.services.xresources; -      xres = concatStringsSep "\n" (attrValues cfg.resources); +      xres = writeText "xresources" (concatStringsSep "\n" (attrValues cfg.resources));      in mkIf cfg.enable {          services.xserver.displayManager.sessionCommands = '' -          echo ${shell-escape xres} | xrdb -merge +          ${pkgs.xorg.xrdb}/bin/xrdb -merge ${xres}          ''; +        environment.systemPackages = [ +          (pkgs.writeDashBin "updateXresources" '' +            ${pkgs.xorg.xrdb}/bin/xrdb -merge ${xres} +          '') +        ];        }; -  } diff --git a/lass/3modules/xserver/default.nix b/lass/3modules/xserver/default.nix new file mode 100644 index 000000000..462c6deef --- /dev/null +++ b/lass/3modules/xserver/default.nix @@ -0,0 +1,101 @@ +{ config, pkgs, ... }@args: +with import <stockholm/lib>; +let + +  out = { +    options.lass.xserver = api; +    config = mkIf cfg.enable imp; +  }; + +  user = config.krebs.build.user; + +  cfg = config.lass.xserver; +  xcfg = config.services.xserver; +  api = { +    enable = mkEnableOption "lass xserver"; +  }; +  imp = { + +    services.xserver = { +      # Don't install feh into systemPackages +      # refs <nixpkgs/nixos/modules/services/x11/desktop-managers> +      desktopManager.session = mkForce []; + +      enable = true; +      display = 11; +      tty = 11; +    }; + +    systemd.services.display-manager.enable = false; + +    systemd.services.xmonad = { +      wantedBy = [ "multi-user.target" ]; +      requires = [ "xserver.service" ]; +      environment = { +        DISPLAY = ":${toString xcfg.display}"; + +        XMONAD_STARTUP_HOOK = pkgs.writeDash "xmonad-startup-hook" '' +          ${pkgs.xorg.xhost}/bin/xhost +LOCAL: & +          ${xcfg.displayManager.sessionCommands} +          wait +        ''; + +        XMONAD_DATA_DIR = "/tmp"; +      }; +      serviceConfig = { +        SyslogIdentifier = "xmonad"; +        ExecStart = "${pkgs.xmonad-lass}/bin/xmonad"; +        ExecStop = "${pkgs.xmonad-lass}/bin/xmonad --shutdown"; +        User = user.name; +        WorkingDirectory = user.home; +      }; +    }; + +    systemd.services.xserver = { +      after = [ +        "systemd-udev-settle.service" +        "local-fs.target" +        "acpid.service" +      ]; +      reloadIfChanged = true; +      environment = { +        XKB_BINDIR = "${pkgs.xorg.xkbcomp}/bin"; # Needed for the Xkb extension. +        XORG_DRI_DRIVER_PATH = "/run/opengl-driver/lib/dri"; # !!! Depends on the driver selected at runtime. +        LD_LIBRARY_PATH = concatStringsSep ":" ( +          [ "${pkgs.xorg.libX11}/lib" "${pkgs.xorg.libXext}/lib" ] +          ++ concatLists (catAttrs "libPath" xcfg.drivers)); +      }; +      serviceConfig = { +        SyslogIdentifier = "xserver"; +        ExecReload = "${pkgs.coreutils}/bin/echo NOP"; +        ExecStart = toString [ +          "${pkgs.xorg.xorgserver}/bin/X" +          ":${toString xcfg.display}" +          "vt${toString xcfg.tty}" +          "-config ${import ./xserver.conf.nix args}" +          "-logfile /dev/null -logverbose 0 -verbose 3" +          "-nolisten tcp" +          "-xkbdir ${pkgs.xkeyboard_config}/etc/X11/xkb" +          (optional (xcfg.dpi != null) "-dpi ${toString xcfg.dpi}") +        ]; +      }; +    }; +    services.xresources.resources.dpi = '' +      ${optionalString (xcfg.dpi != null) "Xft.dpi: ${toString xcfg.dpi}"} +    ''; +    systemd.services.urxvtd = { +      wantedBy = [ "multi-user.target" ]; +      reloadIfChanged = true; +      serviceConfig = { +        SyslogIdentifier = "urxvtd"; +        ExecReload = "${pkgs.coreutils}/bin/echo NOP"; +        ExecStart = "${pkgs.rxvt_unicode_with-plugins}/bin/urxvtd"; +        Restart = "always"; +        RestartSec = "2s"; +        StartLimitBurst = 0; +        User = user.name; +      }; +    }; +  }; + +in out diff --git a/lass/3modules/xserver/xserver.conf.nix b/lass/3modules/xserver/xserver.conf.nix new file mode 100644 index 000000000..6f34e0150 --- /dev/null +++ b/lass/3modules/xserver/xserver.conf.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +with import <stockholm/lib>; + +let +  cfg = config.services.xserver; +in + +pkgs.stdenv.mkDerivation { +  name = "xserver.conf"; + +  xfs = optionalString (cfg.useXFS != false) +    ''FontPath "${toString cfg.useXFS}"''; + +  inherit (cfg) config; + +  buildCommand = +    '' +      echo 'Section "Files"' >> $out +      echo $xfs >> $out + +      for i in ${toString config.fonts.fonts}; do +        if test "''${i:0:''${#NIX_STORE}}" == "$NIX_STORE"; then +          for j in $(find $i -name fonts.dir); do +            echo "  FontPath \"$(dirname $j)\"" >> $out +          done +        fi +      done + +      for i in $(find ${toString cfg.modules} -type d); do +        if test $(echo $i/*.so* | wc -w) -ne 0; then +          echo "  ModulePath \"$i\"" >> $out +        fi +      done + +      echo 'EndSection' >> $out + +      echo "$config" >> $out +    ''; +}  | 
