NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.08k stars 14.13k forks source link

XMonad + contrib/extras, not working(?) #23545

Closed NeQuissimus closed 7 years ago

NeQuissimus commented 7 years ago

Issue description

Since the XMonad 0.13 and the extras jailbreak have hit the channels, something odd has happened to extras/contrib.

This is what I get when I xmonad --recompile


xmonad.hs:3:1: error:
    Failed to load interface for ‘XMonad.Actions.CycleWS’
    Use -v to see a list of the files searched for.

xmonad.hs:4:1: error:
    Failed to load interface for ‘XMonad.Hooks.DynamicLog’
    Use -v to see a list of the files searched for.

xmonad.hs:5:1: error:
    Failed to load interface for ‘XMonad.Hooks.ManageDocks’
    Use -v to see a list of the files searched for.

xmonad.hs:6:1: error:
    Failed to load interface for ‘XMonad.Hooks.ManageHelpers’
    Use -v to see a list of the files searched for.

xmonad.hs:7:1: error:
    Failed to load interface for ‘XMonad.Hooks.EwmhDesktops’
    Use -v to see a list of the files searched for.

xmonad.hs:8:1: error:
    Failed to load interface for ‘XMonad.Layout.NoBorders’
    Use -v to see a list of the files searched for.

xmonad.hs:9:1: error:
    Failed to load interface for ‘XMonad.Util.Run’
    Use -v to see a list of the files searched for.

xmonad.hs:10:1: error:
    Failed to load interface for ‘XMonad.Util.EZConfig’
    Use -v to see a list of the files searched for.

It would seem that there are things missing? I am not at all familiar with XMonad short of using it :)

Any help would be appreciated.

My config (which worked with 0.12 + extras/contrib):

import Control.Monad (liftM2)
import XMonad
import XMonad.Actions.CycleWS
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.EwmhDesktops
import XMonad.Layout.NoBorders
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO
import qualified Data.Map as M
import qualified XMonad.StackSet as W

myWorkspaces = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" ]

myManageHook = composeAll [
    isFullscreen --> (doF W.focusDown <+> doFullFloat)
    , isDialog --> doFloat
    , className =? "Franz" --> doShift "0"
    , className =? "Firefox" --> viewShift "9"
    , className =? "Sublime" --> viewShift "2"
    , appName =? "desktop_window" --> doIgnore
    ]
    where viewShift = doF . liftM2 (.) W.greedyView W.shift

myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ [
  ((modm, xK_Return), spawn $ XMonad.terminal conf),
  ((modm .|. shiftMask, xK_l), spawn "/nix/store/x3a3mm43fp9207qbdh5dm6746af354y4-i3lock-fancy-unstable-2016-10-13_rev546ce2e/bin/i3lock-fancy"),
  ((modm, xK_d), spawn "/nix/store/i7pv464gkkmax2yh5dhb8i90w33rh1mw-dmenu-4.6/bin/dmenu_run"),
  ((modm, xK_w), kill),
  ((modm, xK_Left), windows W.focusUp),
  ((modm, xK_Right), windows W.focusDown),
  ((modm .|. shiftMask, xK_Left), windows W.swapUp),
  ((modm .|. shiftMask, xK_Right), windows W.swapDown)
  ]
  ++ [((m .|. modm, k), windows $ f i)
     | (i, k) <- zip (XMonad.workspaces conf) ([xK_1 .. xK_9] ++ [ xK_0 ])
     , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]

main = do
  xmproc <- spawnPipe "/nix/store/hkj4i1sj63bl753a50i29cw8afwsyrs6-xmobar-0.24.3/bin/xmobar /etc/xmobar/config"
  xmonad $ def {
    focusedBorderColor = "#F0F0F0",
    handleEventHook = docksEventHook <+> handleEventHook def,
    keys = myKeys,
    layoutHook = avoidStruts $ layoutHook def,
    logHook = dynamicLogWithPP xmobarPP
                    { ppOrder = \(ws:l:t:_) -> ws : [t]
                    , ppOutput = hPutStrLn xmproc
                    , ppTitle = xmobarColor "green" "" . shorten 50 },
    manageHook = myManageHook <+> manageDocks <+> manageHook def,
    modMask = mod4Mask,
    normalBorderColor = "#666666",
    terminal = "xterm",
    workspaces = myWorkspaces
  }
kristoff3r commented 7 years ago

It looks like it can't find xmonad-contrib, what is in your configuration.nix? I'm using XMonad with contrib and it works fine for me on unstable.

kristoff3r commented 7 years ago

Also, aren't those paths into the store a little unreliable? I think it's better to add xmobar and the other programs you spawn to your configuration.nix instead.

NeQuissimus commented 7 years ago

I have an import into my configuration: (~/.xmonad is a symlink to /etc/xmonad for me)

{ config, lib, pkgs, ... }:
rec {
  services.xserver.windowManager.xmonad = {
    enable = true;
    enableContribAndExtras = true;
    extraPackages = with pkgs.haskellPackages; haskellPackages: [ xmobar ];
  };

  # nixpkgs.config.packageOverrides = pkgs: {
    # haskellPackages = pkgs.haskellPackages.override { overrides = self: super: { xmonad = pkgs.lib.overrideDerivation super.xmonad (old: { patches = [ ./nixpkgs/xmonad-nix.patch ]; });};};
  # };

  # See https://github.com/NixOS/nixpkgs/issues/20258
  environment.etc."xmonad/xmonad.hs".text = ''
    import Control.Monad (liftM2)
    import XMonad
    import XMonad.Actions.CycleWS
    import XMonad.Hooks.DynamicLog
    import XMonad.Hooks.ManageDocks
    import XMonad.Hooks.ManageHelpers
    import XMonad.Hooks.EwmhDesktops
    import XMonad.Layout.NoBorders
    import XMonad.Util.Run(spawnPipe)
    import XMonad.Util.EZConfig(additionalKeys)
    import System.IO
    import qualified Data.Map as M
    import qualified XMonad.StackSet as W

    myWorkspaces = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" ]

    myManageHook = composeAll [
        isFullscreen --> (doF W.focusDown <+> doFullFloat)
        , isDialog --> doFloat
        , className =? "Franz" --> doShift "0"
        , className =? "Firefox" --> viewShift "9"
        , className =? "Sublime" --> viewShift "2"
        , appName =? "desktop_window" --> doIgnore
        ]
        where viewShift = doF . liftM2 (.) W.greedyView W.shift

    myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ [
      ((modm, xK_Return), spawn $ XMonad.terminal conf),
      ((modm .|. shiftMask, xK_l), spawn "${pkgs.i3lock-fancy}/bin/i3lock-fancy"),
      ((modm, xK_d), spawn "${pkgs.dmenu}/bin/dmenu_run"),
      ((modm, xK_w), kill),
      ((modm, xK_Left), windows W.focusUp),
      ((modm, xK_Right), windows W.focusDown),
      ((modm .|. shiftMask, xK_Left), windows W.swapUp),
      ((modm .|. shiftMask, xK_Right), windows W.swapDown)
      ]
      ++ [((m .|. modm, k), windows $ f i)
         | (i, k) <- zip (XMonad.workspaces conf) ([xK_1 .. xK_9] ++ [ xK_0 ])
         , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
      ++ [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
         | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]

    main = do
      xmproc <- spawnPipe "${pkgs.haskellPackages.xmobar}/bin/xmobar /etc/xmobar/config"
      xmonad $ def {
        focusedBorderColor = "#F0F0F0",
        handleEventHook = docksEventHook <+> handleEventHook def,
        keys = myKeys,
        layoutHook = avoidStruts $ layoutHook def,
        logHook = dynamicLogWithPP xmobarPP
                        { ppOrder = \(ws:l:t:_) -> ws : [t]
                        , ppOutput = hPutStrLn xmproc
                        , ppTitle = xmobarColor "green" "" . shorten 50 },
        manageHook = myManageHook <+> manageDocks <+> manageHook def,
        modMask = mod4Mask,
        normalBorderColor = "#666666",
        terminal = "xterm",
        workspaces = myWorkspaces
      }
  '';

  environment.etc."xmobar/config".text = ''
    Config { font = "xft:Font Awesome:size=9, xft:DejaVu Sans Mono:size=8:antialias=true"
       , additionalFonts = []
       , borderColor = "black"
       , border = BottomB
       , bgColor = "black"
       , fgColor = "grey"
       , alpha = 255
       , position = Bottom
       , textOffset = -1
       , iconOffset = -1
       , lowerOnStart = False
       , pickBroadest = False
       , persistent = False
       , hideOnStart = False
       , iconRoot = "."
       , allDesktops = True
       , overrideRedirect = False
       , commands = [ Run DynNetwork [ "--template" , "<dev>: <rx>kB/s | <tx>kB/s" ] 10
                    , Run MultiCpu [ "--template" , "Cpu: <total0>% | <total1>% | <total2>% | <total3>%" ] 10
                    , Run Memory ["-t","Mem: <used>"] 10
                    , Run Com "uname" ["-r"] "" 36000
                    , Run Date "%A, %d.%m.%Y %H:%M:%S" "date" 10
                    , Run Battery        [ "--template" , "<acstatus>"
                             , "--Low"      , "10"        -- units: %
                             , "--High"     , "80"        -- units: %
                             , "--low"      , "darkred"
                             , "--normal"   , "darkorange"
                             , "--high"     , "darkgreen"

                             , "--" -- battery specific options
                                       -- discharging status
                                       , "-o"  , "<left>% (<timeleft>)"
                                       -- AC "on" status
                                       , "-O"  , "<fc=#dAA520>Charging</fc>"
                                       -- charged status
                                       , "-i"  , "<fc=#006000>Charged</fc>"
                             ] 50
                    , Run StdinReader
                    ]
       , sepChar = "%"
       , alignSep = "}{"
       , template = "%StdinReader% }{  %multicpu% |  %memory% MiB |  %dynnetwork% |  %date% |  %battery% |  %uname%"
       }
  '';
}

configuration.nix looks like this

{ config, lib, pkgs, ... }:

{
  imports = [ ./ux305c-hardware.nix ./xmonad-config.nix ./ux305c-wifi.nix ];

  boot = {
    cleanTmpDir = true;

    initrd.kernelModules = ["ahci" "aesni-intel"];

    kernel.sysctl = {
      "vm.dirty_writeback_centisecs" = 1500;
      "vm.drop_caches" = 1;
      "vm.laptop_mode" = 5;
      "vm.swappiness" = 1;
    };

    kernelPackages = pkgs.linuxPackages_4_9;

    loader = {
      efi.canTouchEfiVariables = true;
      systemd-boot.enable = true;
    };
  };

  environment.systemPackages = with pkgs; [
    # Basics
    binutils
    conky
    dmenu
    gitMinimal
    htop
    i3lock-fancy
    parcellite
    upower
  ];

  fonts = {
    enableFontDir = true;

    fonts = with pkgs; [
      dejavu_fonts
      font-awesome-ttf
      nerdfonts
      source-code-pro
    ];

    fontconfig.defaultFonts.monospace = [ "DejaVu Sans Mono" ];
  };

  hardware = {
    cpu.intel.updateMicrocode = true;
    pulseaudio.enable = false;
  };

  i18n = {
    consoleKeyMap = "us";
    defaultLocale = "en_US.UTF-8";
  };

  networking = {
    hostName = "nixus";

    extraHosts = ''
      127.0.0.1 nixus
      0.0.0.0 ftp.au.debian.org
    '';

    firewall = {
      allowedTCPPorts = [ 22 ];
      allowPing = false;
      enable = true;
    };
  };

  nix = {
    binaryCaches = [ https://cache.nixos.org ];
    buildCores = 8;

    extraOptions = ''
      auto-optimise-store = true
      binary-caches-parallel-connections = 3
      connect-timeout = 10
    '';

    gc = {
      automatic = true;
      dates = "18:00";
      options = "--delete-older-than 30";
    };

    maxJobs = 4;

    nrBuildUsers = 30;
    trustedBinaryCaches = [ https://cache.nixos.org ];
    useSandbox = true;
  };

  powerManagement = {
    enable = true;
    cpuFreqGovernor = "ondemand";
  };

  programs = {
    ssh = {
      agentTimeout = "4h";
      extraConfig = ''
        Host *
          ConnectTimeout 60
          ServerAliveInterval 240
          ConnectionAttempts 60
      '';
      knownHosts = [
        {
          hostNames = [ "pine" "pine.nequissimus.com" "10.30.27.128" ];
          publicKey = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLd5r3p3khAwHU8h2W/vCk872XV9iOqL3GvwofWkw5xbtljG1AnTPeBjxHVAaQCagrrJGA9iGope2g6A6ydpvn4=";
        }
        {
          hostNames = [ "github.com" "192.30.252.*" "192.30.253.*" "192.30.254.*" "192.30.255.*" ];
          publicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
        }
      ];
      startAgent = true;
    };

    zsh = {
      enable = true;
      promptInit = ''
        autoload -U promptinit && promptinit && prompt clint
      '';
    };
  };

  security = {
    hideProcessInformation = true;

    sudo = {
        enable = true;
        wheelNeedsPassword = true;
    };
  };

  services = {
    dnsmasq = {
      enable = true;
      servers = [ "8.8.8.8" "8.8.4.4" "64.6.64.6" "64.6.65.6" ];
    };

    locate.enable = true;

    nixosManual.enable = false;

    ntp = {
      enable = true;
      servers = [ "0.ca.pool.ntp.org" "1.ca.pool.ntp.org" "2.ca.pool.ntp.org" "3.ca.pool.ntp.org" ];
    };

    openssh = {
      enable = true;
      passwordAuthentication = false;
      permitRootLogin = "no";
    };

    upower.enable = true;

    xserver = {
      autorun = true;
      defaultDepth = 24;
      displayManager = {
        sessionCommands = with pkgs; lib.mkAfter ''
          ${xorg.xsetroot}/bin/xsetroot -solid black &
          ${xorg.xsetroot}/bin/xsetroot -cursor_name left_ptr &
          ${coreutils}/bin/sleep 5 && ${parcellite}/bin/parcellite &
        '';
        slim.enable = true;
        xserverArgs = [ "-logfile" "/var/log/X.log" ];
      };
      enable = true;
      exportConfiguration = true;
      resolutions = [{x = 1920; y = 1080;} {x = 1280; y = 800;} {x = 1024; y = 768;}];
      synaptics = {
        enable = true;
        tapButtons = false;
        twoFingerScroll = true;
      };
      videoDriver = "intel";
      xkbOptions = "ctrl:nocaps";
    };
  };

  system = {
    autoUpgrade = {
      channel = "https://nixos.org/channels/nixos-unstable-small";
      dates = "19:00";
      enable = true;
    };
    stateVersion = "17.03";
  };

  time = {
    timeZone = "America/Toronto";
  };

  users = {
    defaultUserShell = "${pkgs.zsh}/bin/zsh";

    extraUsers.nequi = {
     createHome = true;
     extraGroups = [ "docker" "wheel" ];
     group = "users";
     home = "/home/nequi";
     name = "nequi";
     uid = 1000;
     useDefaultShell = true;

     openssh.authorizedKeys.keys = [
      "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA7Jdj3a0bXoMTTE7dTLtAuB3aY5ZCTvWGhmlYYYFC/D timsteinbach@iPixel.local"
     ];
    };
  };

  virtualisation = {
    docker = {
      enable = true;
      storageDriver = "btrfs";
    };

    virtualbox.host.enable = true;
  };
}
NeQuissimus commented 7 years ago

OK, so it has taken me a few days to figure this out but the solution is dead simple: Don't install another instance of XMonad into your user environment :D Somehow I had managed to do so...