1
0
mirror of https://github.com/ellmau/nixos.git synced 2025-12-20 09:39:39 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
9a6538737c
Add haskell devshell for xmonad.hs file 2023-04-13 15:03:50 +02:00
dd50e786ff
First setup for xmonad 2023-04-13 14:56:12 +02:00
11 changed files with 330 additions and 3 deletions

View File

@ -27,7 +27,8 @@
enable = true; enable = true;
sway.enable = false; sway.enable = false;
i3.enable = false; i3.enable = false;
plasma.enable = true; plasma.enable = false;
xmonad.enable = true;
# set dpi if used in mobile applications # set dpi if used in mobile applications
# dpi = 180; # dpi = 180;
}; };

View File

@ -571,6 +571,26 @@
(use-package lsp-ui) (use-package lsp-ui)
;; haskell
(use-package haskell-mode
:diminish subword-mode
:hook
(haskell-mode . turn-on-haskell-doc)
(haskell-mode . subword-mode))
(use-package haskell
:ensure haskell-mode)
(use-package haskell-font-lock
:ensure haskell-mode)
(use-package lsp-haskell
:if die-orga/workstation
:demand t)
(use-package shakespeare-mode)
(use-package company-cabal
:defer t
:init
(with-eval-after-load 'company
(add-to-list 'company-backends '(company-cabal))))
;; misc ;; misc
(use-package academic-phrases (use-package academic-phrases
:defer t :defer t

View File

@ -22,6 +22,7 @@ with lib; {
''; '';
}; };
i3.enable = mkEnableOption "enable i3"; i3.enable = mkEnableOption "enable i3";
xmonad.enable = mkEnableOption "Use xmonad";
}; };
config = let config = let
cfg = config.elss.graphical; cfg = config.elss.graphical;
@ -40,7 +41,7 @@ with lib; {
in in
mkIf cfg.enable { mkIf cfg.enable {
elss.users.x11.enable = elss.users.x11.enable =
if cfg.i3.enable if cfg.i3.enable || cfg.xmonad.enable
then true then true
else false; else false;
elss.networking.useNetworkManager = true; elss.networking.useNetworkManager = true;
@ -74,6 +75,8 @@ with lib; {
printing.enable = true; printing.enable = true;
}; };
security.pam.services.lightdm.enableGnomeKeyring = true;
sound.enable = true; sound.enable = true;
hardware = { hardware = {

25
modules/xmonad.nix Normal file
View File

@ -0,0 +1,25 @@
{
config,
pkgs,
lib,
...
}:
with lib; {
config = let
cfg = config.elss.graphical.xmonad;
in
mkIf cfg.enable {
services = {
xserver = {
enable = true;
windowManager.xmonad.enable = true;
layout = "us";
xkbOptions = "eurosign:e";
};
gnome.gnome-keyring.enable = true;
printing.enable = true;
};
security.pam.services.lightdm.enableGnomeKeyring = true;
};
}

View File

@ -0,0 +1 @@
use flake

112
users/ellmau/conf/xmonad/flake.lock generated Normal file
View File

@ -0,0 +1,112 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils-plus": {
"inputs": {
"flake-utils": "flake-utils_2"
},
"locked": {
"lastModified": 1657226504,
"narHash": "sha256-GIYNjuq4mJlFgqKsZ+YrgzWm0IpA4axA3MCrdKYj7gs=",
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"rev": "2bf0f91643c2e5ae38c1b26893ac2927ac9bd82a",
"type": "github"
},
"original": {
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1681269223,
"narHash": "sha256-i6OeI2f7qGvmLfD07l1Az5iBL+bFeP0RHixisWtpUGo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "87edbd74246ccdfa64503f334ed86fa04010bab9",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1681303793,
"narHash": "sha256-JEdQHsYuCfRL2PICHlOiH/2ue3DwoxUX7DJ6zZxZXFk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "fe2ecaf706a5907b5e54d979fbde4924d84b65fc",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"flake-utils-plus": "flake-utils-plus",
"nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -0,0 +1,47 @@
{
description = "basic tool setup flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus";
};
outputs = {
self,
nixpkgs,
nixpkgs-unstable,
flake-utils,
flake-utils-plus,
...
} @ inputs:
{}
// (flake-utils.lib.eachDefaultSystem (
system: let
unstable = import nixpkgs-unstable {
inherit system;
};
pkgs = import nixpkgs {
inherit system;
};
in rec {
devShell = pkgs.mkShell {
name = "xmonad";
nativeBuildInputs = [
# add packages here, like
# pkgs.clingo
(pkgs.ghc.withPackages
(haskellPackages: [
haskellPackages.dbus
haskellPackages.monad-logger
haskellPackages.hostname
haskellPackages.xmonad
haskellPackages.xmonad-contrib
]))
pkgs.haskell-language-server
];
};
}
));
}

View File

@ -0,0 +1,81 @@
module Main where
import Data.Ratio
import XMonad hiding ((|||))
import XMonad.Hooks.FadeInactive
import XMonad.Hooks.FadeWindows
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.StatusBar
import XMonad.Util.EZConfig
import Network.HostName (getHostName)
-- Imports for Polybar --
import qualified Codec.Binary.UTF8.String as UTF8
import qualified DBus as D
import qualified DBus.Client as D
import XMonad.Hooks.DynamicLog
main :: IO ()
main' :: D.Client -> IO ()
main = mkDbusClient >>= main'
main' dbus = do
hostname <- io $ getHostName
xmonad . docks . ewmhFullscreen . ewmh $ def
{ terminal = "alacritty"
, logHook = polybarLogHook dbus
}
mkDbusClient :: IO D.Client
mkDbusClient = do
dbus <- D.connectSession
D.requestName dbus (D.busName_ "org.xmonad.log") opts
return dbus
where
opts = [D.nameAllowReplacement, D.nameReplaceExisting, D.nameDoNotQueue]
-- Emit a DBus signal on log updates
dbusOutput :: D.Client -> String -> IO ()
dbusOutput dbus str =
let opath = D.objectPath_ "/org/xmonad/Log"
iname = D.interfaceName_ "org.xmonad.Log"
mname = D.memberName_ "Update"
signal = D.signal opath iname mname
body = [D.toVariant $ UTF8.decodeString str]
in D.emit dbus $ signal { D.signalBody = body }
polybarHook :: D.Client -> PP
polybarHook dbus =
let wrapper c s | s /= "NSP" = wrap ("%{F" <> c <> "} ") " %{F-}" s
| otherwise = mempty
blue = "#2E9AFE"
gray = "#7F7F7F"
orange = "#ea4300"
purple = "#9058c7"
red = "#722222"
in def { ppOutput = dbusOutput dbus
, ppCurrent = wrapper blue
, ppVisible = wrapper gray
, ppUrgent = wrapper orange
, ppHidden = wrapper gray
, ppHiddenNoWindows = wrapper red
, ppTitle = shorten 100 . wrapper purple
}
fadeHook :: Rational -> Rational -> X ()
fadeHook act inact = fadeOutLogHook $ fadeAllBut exceptions act inact
where exceptions = isFullscreen
<||> className =? "firefox"
<||> className =? "Chromium-browser"
fadeAllBut :: Query Bool -> Rational -> Rational -> Query Rational
fadeAllBut qry amt inact = do isInactive <- isUnfocused
isQry <- qry
if isQry
then return 1
else if isInactive
then return inact
else return amt
polybarLogHook dbus = fadeHook 0.95 0.75 <+> dynamicLogWithPP (polybarHook dbus)

View File

@ -15,6 +15,7 @@
./mako.nix ./mako.nix
./nextcloud.nix ./nextcloud.nix
./polybar.nix ./polybar.nix
./xmonad.nix
./zsh.nix ./zsh.nix
./sway.nix ./sway.nix

View File

@ -7,7 +7,14 @@
}: }:
with lib; { with lib; {
config = let config = let
cfg = nixosConfig.elss.graphical.i3; cfg = nixosConfig.elss.graphical.xmonad;
xmonad = ''
[module/xmonad]
type = custom/script
exec = ${pkgs.xmonad-log}/bin/xmonad-log
tail = true
'';
in in
mkIf cfg.enable { mkIf cfg.enable {
services.polybar = { services.polybar = {
@ -357,6 +364,7 @@ with lib; {
MONITOR=$m polybar --reload aux & MONITOR=$m polybar --reload aux &
done; done;
''; '';
extraConfig = xmonad;
}; };
}; };
} }

28
users/ellmau/xmonad.nix Normal file
View File

@ -0,0 +1,28 @@
{
config,
pkgs,
lib,
nixosConfig,
...
}:
with lib; {
config = let
cfg = nixosConfig.elss.graphical.xmonad;
in
mkIf cfg.enable {
xsession = {
enable = true;
windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
extraPackages = haskellPackages: [
haskellPackages.dbus
haskellPackages.monad-logger
haskellPackages.hostname
];
config = mkDefault conf/xmonad/xmonad.hs;
};
};
};
}