Initial commit

This commit is contained in:
Mats Rauhala 2021-11-19 20:15:27 +02:00
commit 8ba34427d3
4 changed files with 299 additions and 0 deletions

25
flake.lock Normal file
View File

@ -0,0 +1,25 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1637345130,
"narHash": "sha256-UoR2tCBvMFdCNxQDSrnc08MbwOMH2mYbQo8ZwZH00I0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "41aaf69b7dd245611467fa7344dd244eacd915d1",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

8
flake.nix Normal file
View File

@ -0,0 +1,8 @@
{
description = "XMonad module";
outputs = { self, nixpkgs }: {
nixosModule = import ./modules/xmonad/default.nix;
};
}

View File

@ -0,0 +1,31 @@
# Create the xmonad.dhall end result with all the binaries resolved
#
# Use it as such: callPackage ./buildXmonad.nix {} ./xmonad.dhall { inherit teams; }
{ lib, xmonad-masser, dhallPackages, runCommand }:
path:
packages:
let
xmonadDeps = with dhallPackages;
buildDhallDirectoryPackage {
name = "xmonad-masser";
src = "${xmonad-masser}/share/x86_64-linux-ghc-8.10.7/xmonad-masser-0.1.0.0/dhall";
file = "package.dhall";
source = false;
document = false;
dependencies = [ (Prelude.overridePackage { file = "package.dhall"; }) ];
};
xmonadInput = runCommand "packages.dhall"
packages
''
substituteAll ${path} $out
'';
xmonadConfig = with dhallPackages; buildDhallPackage {
name = "xmonad.dhall";
code = xmonadInput;
dependencies = [ Prelude xmonadDeps ];
source = true;
};
in xmonadConfig

235
modules/xmonad/default.nix Normal file
View File

@ -0,0 +1,235 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.xmonad;
xmonadConfig = with pkgs; callPackage ./buildXmonad.nix {inherit (pkgs.haskellPackages) xmonad-masser; } cfg.dhallConfigPath cfg.packages;
gifs = with pkgs; stdenv.mkDerivation {
name = "gifs";
src = fetchurl {
url = "https://gateway.pinata.cloud/ipfs/QmQRb5Zt9QRbd6VuUuQ44wfkBaN4BYWfeH9JALpM2DU9dJ/animated.tar.gz";
sha256 = "14qb9y9zkmz13yl87713ib0wjcri727kgd3dwn0d6jrh94z948sq";
};
installPhase = ''
mkdir $out
ls $out
cp -rv *.{gif,mp4} $out/
'';
};
saver_mpv = pkgs.writeScript "saver_mpv" ''
#!${pkgs.bash}/bin/bash
PATH=${makeBinPath [pkgs.mpv pkgs.coreutils pkgs.findutils]}:$PATH
video=`find ${gifs} -type f | sort -R | head -n 1`
mpv \
--no-input-terminal \
--really-quiet \
--scale=oversample \
--loop \
--no-stop-screensaver \
--wid="''${XSCREENSAVER_WINDOW}" \
--no-audio "$video" &
exec ${pkgs.xsecurelock}/libexec/xsecurelock/saver_blank
'';
lock = pkgs.writeScript "lock.sh" ''
#!${pkgs.bash}/bin/bash
PATH=${makeBinPath [pkgs.gnupg pkgs.coreutils pkgs.findutils]}:$PATH
gpg-connect-agent reloadagent /bye
export XSECURELOCK_SAVER=${saver_mpv}
export XSECURELOCK_PASSWORD_PROMPT="emoticon"
${pkgs.xsecurelock}/bin/xsecurelock
'';
in {
options = {
programs.xmonad = {
enable = mkEnableOption "Enable xmonad";
dhallConfigPath = mkOption {
type = types.path;
};
packages = mkOption {
type = types.attrsOf types.package;
default = {};
};
};
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
source-code-pro
dmenu
gnome3.zenity
rofi
haskellPackages.xmobar
xlibs.xmodmap
xlibs.xev
xlibs.xset
xorg.xbacklight
xclip
xcalib
i3lock
];
services.screen-locker = {
enable = true;
lockCmd = "${lock}";
};
services.random-background = {
enable = true;
enableXinerama = true;
imageDirectory = "%h/backgrounds";
};
services.picom = {
enable = true;
activeOpacity = "1.0";
inactiveOpacity = "0.95";
backend = "glx";
fade = true;
fadeDelta = 5;
opacityRule = [ "100:name *= 'i3lock'"];
};
xsession = {
enable = true;
windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
extraPackages = h: [h.xmonad-contrib h.xmonad-masser];
config =
let toAppKey = k: _: "${k} :: FilePath";
toApp = k: v: ''Application {_applicationName = "${k}", _applicationAction = "${v}"}'';
applications = concatStringsSep "\n , " (mapAttrsToList toApp cfg.applications);
orNothingStr = x: if null == x then "Nothing" else ''Just "${x}"'';
quoted = x: ''"${x}"'';
toTopic = k: v: ''TopicRule {_topicRuleName = "${k}", _topicRuleHome = ${orNothingStr v.home}, _topicRuleAction = ${orNothingStr v.action}, _topicRuleClasses = [${concatStringsSep ", " (map quoted v.classes)}]}'';
topics = concatStringsSep "\n , " (mapAttrsToList toTopic cfg.topics);
toSearch = k: v: ''Search {_searchName="${k}", _searchKey="${v.key}", _searchUrl="${v.url}"}'';
searches = concatStringsSep "\n , " (mapAttrsToList toSearch cfg.searches);
in pkgs.writeText "xmonad.hs"
''
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NamedFieldPuns #-}
module Main where
-- This is autogenerated file, don't touch
import XMonad.Config.MasseR
main :: IO ()
main = masser
'';
};
initExtra = ''
xmodmap ~/.Xmodmap
${pkgs.xcape}/bin/xcape -e 'Hyper_L=Tab'
'';
};
services.dunst = {
enable = true;
settings = {
global = {
geometry = "300x5-30+20";
indicate_hidden = "yes";
sort = "yes";
word_wrap = "no";
stack_duplicates = "yes";
show_indicators = "yes";
browser = "${pkgs.firefox}/bin/firefox";
transparency = "0";
separator_height = "2";
padding = "8";
horizontal_padding = 8;
frame_width = "8";
frame_color = "#aaaaaa";
separator_color = "frame";
font = "Monospace 8";
format = "<b>%s</b>\\n%b";
};
urgency_low = {
background = "#222222";
foreground = "#888888";
};
urgency_normal = {
background = "#285577";
foreground = "#ffffff";
};
urgency_critical = {
background = "#900000";
foreground = "#ffffff";
frame_color = "#ff0000";
};
};
};
services.unclutter = {
enable = true;
};
home.file.".xmonad/xmonad.dhall".source = xmonadConfig + "/source.dhall";
# programs.xmonad =
# let
# musicToggle = pkgs.writeScript "musictoggle" ''
# ${pkgs.mpc_cli}/bin/mpc toggle
# '';
# # musicCurrent = with pkgs; writeScript "musiccurrent" ''
# # export PATH=${lib.makeBinPath [sp gawk]}
# # sp current | awk '/^Title/ {$1 = ""; print $0}'
# # '';
# musicCurrent = with pkgs; writeScript "musiccurrent" ''
# export PATH=${lib.makeBinPath [mpc_cli]}
# mpc --format "%title%" current
# '';
# xmobarConf = pkgs.writeText "xmobar" ''
# Config {
# font = "xft:Inconsolata-9"
# , bgColor = "#3F3F3F"
# , fgColor = "#DCDCCC"
# , position = Top
# , lowerOnStart = True
# , pickBroadest = True
# , commands = [
# Run MultiCpu ["-t", "CPU: <total>%"] 30
# , Run Memory ["-t", "Mem: <usedbar> (<cache>M)"] 3600
# , Run Date "%a %b %_d %Y %H:%M:%S" "date" 20
# , Run StdinReader
# , Run Battery [ "--template" , "Batt: <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>"
# ] 120
# , Run DynNetwork [ "--template" , "<dev>: <tx>kB/s|<rxbar>kB/s"
# , "--Low" , "1000" -- units: B/s
# , "--High" , "500000" -- units: B/s
# , "--normal" , "darkorange"
# , "--high" , "darkred"
# ] 30
# ]
# , sepChar = "%"
# , alignSep = "}{"
# , template = "%StdinReader% }{%dynnetwork% | %battery% | %multicpu% | %memory% | <fc=#FFFFCC>%date%</fc>"
# }
# '';
# # browser = "${pkgs.qutebrowser}/bin/qutebrowser";
# chromiumApp = name: url: pkgs.writeScriptBin "${name}" ''
# ${pkgs.chromium}/bin/chromium --user-data-dir=~/.config/chromium-${name} --app=${url}
# '';
# custom_teams = chromiumApp "teams" "https://teams.microsoft.com";
# flowdock = chromiumApp "flowdock" "https://flowdock.com/app";
# wiki = chromiumApp "wiki" "https://wiki.relexsolutions.com";
# xmonadConfig = with pkgs; callPackage ./buildXmonad.nix {} cfg.dhallConfigPath cfg.packages;
# in
# {
# enable = true;
# configPackage = xmonadConfig;
# };
};
}