From ab25eaed176895de31aaf5e7fcc5f0a900c2c3ee Mon Sep 17 00:00:00 2001 From: Mats Rauhala Date: Fri, 19 Nov 2021 21:16:56 +0200 Subject: [PATCH] xmonad config --- flake.lock | 94 ++++++++++++++++++++++++++++++++- flake.nix | 10 ++++ macbook/masse.nix | 60 ++++++++++++++++++++++ macbook/xmonad.dhall | 120 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 macbook/xmonad.dhall diff --git a/flake.lock b/flake.lock index 39c6d44..9056499 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "easy-hls-src": { + "inputs": { + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1636606878, + "narHash": "sha256-rLxYl7iYP9vQhSvVlV2uRCdgrqKDz/vN1Z8ZmA8itkM=", + "owner": "jkachmar", + "repo": "easy-hls-nix", + "rev": "edd5710946d46ea40810ef9a708b084d7e05a118", + "type": "github" + }, + "original": { + "owner": "jkachmar", + "repo": "easy-hls-nix", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1637014545, @@ -60,6 +78,21 @@ "type": "github" } }, + "flake-utils_5": { + "locked": { + "lastModified": 1637014545, + "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -247,6 +280,21 @@ "type": "github" } }, + "nixpkgs_4": { + "locked": { + "lastModified": 1615055905, + "narHash": "sha256-Ig7CXgE5C3mwtTVBl8nSTessa1oMAm6Pm/p+T6iAJD8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f3fc074642a25ef5a1423412f09946149237e338", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, "pypi-deps-db": { "flake": false, "locked": { @@ -271,7 +319,51 @@ "myUrxvt": "myUrxvt", "myVim": "myVim", "myZsh": "myZsh", - "nixpkgs": "nixpkgs_3" + "nixpkgs": "nixpkgs_3", + "xmonad-masser": "xmonad-masser", + "xmonad-module": "xmonad-module" + } + }, + "xmonad-masser": { + "inputs": { + "easy-hls-src": "easy-hls-src", + "flake-utils": "flake-utils_5", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1637084914, + "narHash": "sha256-TTuEa8pngrydMP3nbjb4lT94+Cg6blOy1CjhpsxuIhs=", + "owner": "MasseR", + "repo": "xmonad-masser", + "rev": "837656a2d0c685619793fc282c90f59bf24e8494", + "type": "github" + }, + "original": { + "owner": "MasseR", + "repo": "xmonad-masser", + "type": "github" + } + }, + "xmonad-module": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1637345727, + "narHash": "sha256-mt7S6iIt6ethG6E9jF5xlhVpyhfEiEWZHKqNRj1JRgk=", + "ref": "master", + "rev": "8ba34427d36adbb276b4e3d6cd8245574918cdc0", + "revCount": 1, + "type": "git", + "url": "https://git.rauhala.info/MasseR/nix-conf-xmonad" + }, + "original": { + "type": "git", + "url": "https://git.rauhala.info/MasseR/nix-conf-xmonad" } } }, diff --git a/flake.nix b/flake.nix index 5087897..5a5d33e 100644 --- a/flake.nix +++ b/flake.nix @@ -23,6 +23,14 @@ url = "git+https://git.rauhala.info/MasseR/nix-conf-urxvt"; inputs.nixpkgs.follows = "nixpkgs"; }; + xmonad-module = { + url = "git+https://git.rauhala.info/MasseR/nix-conf-xmonad"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + xmonad-masser = { + url = "github:MasseR/xmonad-masser"; + inputs.nixpkgs.follows = "nixpkgs"; + }; kobodl = { url = "github:MasseR/nix-kobodl"; }; @@ -38,10 +46,12 @@ selfModules ++ [ inputs.myZsh.nixosModule inputs.myUrxvt.nixosModule + inputs.xmonad-module.nixosModule ]; overlays = [ inputs.myEmacs.overlay inputs.myVim.overlay + inputs.xmonad-masser.overlay ]; homeConfigurations = diff --git a/macbook/masse.nix b/macbook/masse.nix index f4aeffa..fd92919 100644 --- a/macbook/masse.nix +++ b/macbook/masse.nix @@ -1,5 +1,6 @@ { config, pkgs, ...}: { + nixpkgs.config.allowUnfree = true; programs.command-not-found.enable = true; home.keyboard.layout = "fi"; @@ -70,4 +71,63 @@ programs.myZsh.enable = true; programs.myUrxvt.enable = true; + programs.xmonad = { + enable = true; + dhallConfigPath = ./xmonad.dhall; + packages = with pkgs; + let + prompt = writeScriptBin "prompt" '' + ${pkgs.haskellPackages.xmobar}/bin/xmobar ${xmobarConf} + ''; + xmobarConf = pkgs.writeText "xmobar" '' + Config { + font = "xft:Iosevka-9" + , bgColor = "#3F3F3F" + , fgColor = "#DCDCCC" + , position = Top + , lowerOnStart = True + , commands = [ + Run MultiCpu ["-t", "CPU: %"] 30 + , Run Memory ["-t", "Mem: (M)"] 3600 + , Run Date "%a %b %_d %Y %H:%M:%S" "date" 20 + , Run StdinReader + , Run Battery [ "--template" , "Batt: " + , "--Low" , "10" -- units: % + , "--High" , "80" -- units: % + , "--low" , "darkred" + , "--normal" , "darkorange" + , "--high" , "darkgreen" + + , "--" -- battery specific options + -- discharging status + , "-o" , "% ()" + -- AC "on" status + , "-O" , "Charging" + -- charged status + , "-i" , "Charged" + ] 120 + , Run DynNetwork [ "--template" , ": kB/s|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% | %date%" + } + ''; + + in + { + inherit qutebrowser flameshot calibre spotify hledger obsidian prompt; + hledger_ui = hledger-ui; + element = element-desktop; + signal = signal-desktop; + vim = myVim; + emacs = myEmacs; + urxvt = rxvt-unicode; + }; + }; } diff --git a/macbook/xmonad.dhall b/macbook/xmonad.dhall new file mode 100644 index 0000000..d3276bd --- /dev/null +++ b/macbook/xmonad.dhall @@ -0,0 +1,120 @@ +let Prelude = + https://prelude.dhall-lang.org/v20.1.0/package.dhall + sha256:26b0ef498663d269e4dc6a82b0ee289ec565d683ef4c00d0ebdd25333a5a3c98 + +let Config = + /home/masse/git/xmonad-masser/dhall/package.dhall + sha256:8cca83716bc75d06cb22c7f45091606159404289d9866601817b2ab81170afcb + +let pkgs = + { qutebrowser = "@qutebrowser@" + , prompt = "@prompt@" + , signal = "@signal@" + , element = "@element@" + , emacs = "@emacs@" + , urxvt = "@urxvt@" + , flameshot = "@flameshot@" + , obsidian = "@obsidian@" + , vim = "@vim@" + , calibre = "@calibre@" + , spotify = "@spotify@" + , hledger = "@hledger@" + , hledger-ui = "@hledger_ui@" + } + +let browser = "${pkgs.qutebrowser}/bin/qutebrowser" + +let terminal = "${pkgs.urxvt}/bin/urxvt" +let prompt = "${pkgs.prompt}/bin/prompt" + +let shellIn = \(path : Text) -> "${terminal} -cd ${path}" + +let paths = + let pathElement = \(x : Prelude.Map.Entry Text Text) -> x.mapValue + + in Prelude.Text.concatMapSep + ":" + (Prelude.Map.Entry Text Text) + pathElement + (toMap pkgs) + +let runOnTopic = + \(name : Text) -> + \(action : Text) -> + Config.Topic::{ name, action = [ Config.Command.Spawn action ] } + +let spawn = Config.Command.Spawn + +in Config::{ + , path = paths + , applications = { terminal, prompt = pkgs.prompt } + , topics = + [ runOnTopic "signal" "${pkgs.signal}/bin/signal-desktop" + , runOnTopic "element" "${pkgs.element}/bin/element-desktop" + , runOnTopic "xmonad" (shellIn "/home/masse/git/xmonad-masser") + , runOnTopic "adhoc" (shellIn "/home/masse/code_practice") + , Config.Topic::{ + , name = "zettel" + , action = + [ spawn "${pkgs.obsidian}/bin/obsidian" + , spawn "${pkgs.vim}/bin/vim -g" + ] + } + , runOnTopic "conf" (shellIn "/etc/nixos") + , runOnTopic "web" browser + , Config.Topic::{ + , name = "ledger" + , action = + [ spawn + "${pkgs.vim}/bin/vim -g /home/masse/wikidata/accounting/2021.journal" + , spawn (shellIn "/home/masse/wikidata/accounting") + , spawn + ( shellIn + "/home/masse/wikidata/accounting -e ${pkgs.hledger-ui}/bin/hledger-ui --watch --register checking -U -P" + ) + , spawn + ( shellIn + "/home/masse/wikidata/accounting -e ${pkgs.hledger-ui}/bin/hledger-ui --watch --register savings -U -P" + ) + , spawn + ( shellIn + "/home/masse/wikidata/accounting -e ${pkgs.hledger-ui}/bin/hledger-ui --watch --register lunchcard -U -P" + ) + ] + } + , runOnTopic "pdf" "${pkgs.calibre}/bin/calibre" + , runOnTopic "music" "${pkgs.spotify}/bin/spotify" + ] + , bindings = + let mkCommand = + \(prefix : Text) -> + \(name : Text) -> + \(command : Text) -> + Config.SubCommand.act + { prefix, name, command = Config.Command.Spawn command } + + let mkSearch = + \(prefix : Text) -> + \(name : Text) -> + \(site : Text) -> + Config.SubCommand.act + { prefix + , name + , command = Config.Command.Search { name, browser, site } + } + + in [ mkCommand + "M-" + "Take a screenshot" + "${pkgs.flameshot}/bin/flameshot gui" + , Config.SubCommand.subMap + { prefix = "M-s" + , name = "Search" + , sub = + [ mkSearch "h" "hoogle" "https://hoogle.haskell.org?hoogle=" + , mkSearch "g" "google" "https://google.com/search?q=" + , mkSearch "d" "duckduckgo" "https://duckduckgo.com/?q=" + ] + } + ] + }