From 392e6768f9f60c761b65f8774c1667ab8d00f230 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 3 Jan 2021 01:14:47 +0100 Subject: gkleen@sif: systemd --- accounts/gkleen@sif/default.nix | 5 +- accounts/gkleen@sif/store.kdbx.lftp | 6 ++ accounts/gkleen@sif/systemd.nix | 107 ++++++++++++++++++++++++ accounts/gkleen@sif/xmobar/default.nix | 7 ++ accounts/gkleen@sif/xmobar/nixpkgs.nix | 9 ++ accounts/gkleen@sif/xmobar/package.yaml | 13 +++ accounts/gkleen@sif/xmobar/shell.nix | 28 +++++++ accounts/gkleen@sif/xmobar/stack.nix | 17 ++++ accounts/gkleen@sif/xmobar/stack.yaml | 10 +++ accounts/gkleen@sif/xmobar/stack.yaml.lock | 12 +++ accounts/gkleen@sif/xmobar/stackage.nix | 31 +++++++ accounts/gkleen@sif/xmobar/xmobar-yggdrasil.nix | 13 +++ accounts/gkleen@sif/xmobar/xmobar.hs | 52 ++++++++++++ 13 files changed, 309 insertions(+), 1 deletion(-) create mode 100644 accounts/gkleen@sif/store.kdbx.lftp create mode 100644 accounts/gkleen@sif/systemd.nix create mode 100644 accounts/gkleen@sif/xmobar/default.nix create mode 100644 accounts/gkleen@sif/xmobar/nixpkgs.nix create mode 100644 accounts/gkleen@sif/xmobar/package.yaml create mode 100644 accounts/gkleen@sif/xmobar/shell.nix create mode 100644 accounts/gkleen@sif/xmobar/stack.nix create mode 100644 accounts/gkleen@sif/xmobar/stack.yaml create mode 100644 accounts/gkleen@sif/xmobar/stack.yaml.lock create mode 100644 accounts/gkleen@sif/xmobar/stackage.nix create mode 100644 accounts/gkleen@sif/xmobar/xmobar-yggdrasil.nix create mode 100644 accounts/gkleen@sif/xmobar/xmobar.hs (limited to 'accounts') diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index 9f2df668..163e75f1 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix @@ -1,4 +1,4 @@ -{ flake, userName, pkgs, customUtils, lib, config, ... }: +{ flake, userName, pkgs, customUtils, lib, config, ... }@inputs: let cfg = config.home-manager.users.${userName}; xmonad = import ./xmonad pkgs.haskellPackages; @@ -159,6 +159,7 @@ in { google-play-music-desktop-player qt5ct playerctl evince thunderbird zulip zoom-us steam steam-run wireshark skype virt-manager rclone cached-nix-shell xournal discord xmonad + worktime ]; file = { @@ -177,5 +178,7 @@ in { stateVersion = "20.03"; }; + + systemd.user = import ./systemd.nix inputs; }; } diff --git a/accounts/gkleen@sif/store.kdbx.lftp b/accounts/gkleen@sif/store.kdbx.lftp new file mode 100644 index 00000000..4447aded --- /dev/null +++ b/accounts/gkleen@sif/store.kdbx.lftp @@ -0,0 +1,6 @@ +open ftp://gkleen.keepass@yggdrasil.li/ + +lcd /home/gkleen + +mirror -v --only-newer -f store.kdbx +mirror -v --reverse --only-newer -f store.kdbx \ No newline at end of file diff --git a/accounts/gkleen@sif/systemd.nix b/accounts/gkleen@sif/systemd.nix new file mode 100644 index 00000000..c6ec6f64 --- /dev/null +++ b/accounts/gkleen@sif/systemd.nix @@ -0,0 +1,107 @@ +{ pkgs, config, userName, ... }: +let + xmobar = import ./xmobar pkgs.haskellPackages; + cfg = config.home-manager.users.${userName}; +in { + services = { + "dynamic-forward@" = { + Service = { + WorkingDirectory = "~"; + ExecStart = "${pkgs.autossh}/bin/autossh -M 20000 -- -vN -o ControlMaster=no \"%I\""; + Environment = [ "AUTOSSH_POLL=30" "AUTOSSH_PIDFILE=.ssh/autossh.%i.pid" ]; + PIDFile = "~/.ssh/autossh.%i.pid"; + Restart = "on-failure"; + RestartSec = "30"; + }; + Install = { + WantedBy = ["default.target"]; + }; + }; + sync-keepass = { + Service = { + Type = "oneshot"; + WorkingDirectory = "~"; + ExecStart = "${pkgs.lftp}/bin/lftp -f ${./store.kdbx.lftp}"; + }; + }; + urxvtd = { + Service = { + Type = "simple"; + WorkingDirectory = "~"; + ExecStart = "${cfg.programs.urxvt.package}/bin/urxvtd"; + Restart = "always"; + }; + Unit = { + After = ["graphical-session.target"]; + }; + Install = { + WantedBy = ["graphical-session.target"]; + }; + }; + emacs = { + Unit = { + After = ["graphical-session-pre.target"]; + }; + }; + trayer = { + Service = { + Type = "simple"; + WorkingDirectory = "~"; + ExecStart = "${pkgs.trayer}/bin/trayer --edge top --align right --SetDockType true --SetPartialStrut true --expand true --width 8 --tint 0x000000 --alpha 0 --transparent true --height 32 --monitor primary"; + Restart = "always"; + }; + Install = { + WantedBy = ["graphical-session.target"]; + }; + }; + xmobar = { + Service = { + Type = "simple"; + WorkingDirectory = "~"; + ExecStart = "${xmobar}/bin/xmobar"; + Restart = "always"; + Environment = "PATH=${pkgs.worktime}/bin:${pkgs.openssh}/bin"; + + }; + Install = { + WantedBy = ["graphical-session.target"]; + }; + }; + dunst = { + Service = { + Restart = "always"; + }; + Install = { + WantedBy = ["graphical-session.target"]; + }; + }; + xiccd = { + Service = { + Type = "simple"; + WorkingDirectory = "~"; + ExecStart = "${pkgs.xiccd}/bin/xiccd"; + Restart = "always"; + }; + }; + }; + timers = { + sync-keepass = { + Timer = { + OnActiveSec = "1m"; + OnUnitActiveSec = "1m"; + }; + + Install = { + WantedBy = ["default.target"]; + }; + }; + }; + targets = { + graphical-session = { + Unit = { + BindsTo = ["default.target"]; + After = ["basic.target"]; + }; + }; + }; +} diff --git a/accounts/gkleen@sif/xmobar/default.nix b/accounts/gkleen@sif/xmobar/default.nix new file mode 100644 index 00000000..fcac5e60 --- /dev/null +++ b/accounts/gkleen@sif/xmobar/default.nix @@ -0,0 +1,7 @@ +argumentPackages@{ ... }: + +let + # defaultPackages = (import ./stackage.nix {}); + # haskellPackages = defaultPackages // argumentPackages; + haskellPackages = argumentPackages; +in haskellPackages.callPackage ./xmobar-yggdrasil.nix {} diff --git a/accounts/gkleen@sif/xmobar/nixpkgs.nix b/accounts/gkleen@sif/xmobar/nixpkgs.nix new file mode 100644 index 00000000..783ede00 --- /dev/null +++ b/accounts/gkleen@sif/xmobar/nixpkgs.nix @@ -0,0 +1,9 @@ +{ nixpkgs ? import +}: + +import ((nixpkgs {}).fetchFromGitHub { + owner = "NixOS"; + repo = "nixpkgs"; + rev = "10e61bf5be57736035ec7a804cb0bf3d083bf2cf"; + sha256 = "0fplfm2zx4vk7gs8bdcxnvzkdmpx2w0llqwf8475z9dz9cl132rm"; +}) diff --git a/accounts/gkleen@sif/xmobar/package.yaml b/accounts/gkleen@sif/xmobar/package.yaml new file mode 100644 index 00000000..b638b6ac --- /dev/null +++ b/accounts/gkleen@sif/xmobar/package.yaml @@ -0,0 +1,13 @@ +name: xmobar-yggdrasil + +executables: + xmobar: + dependencies: + - base + - xmobar + + main: xmobar.hs + source-dirs: + - . + + ghc-options: -threaded diff --git a/accounts/gkleen@sif/xmobar/shell.nix b/accounts/gkleen@sif/xmobar/shell.nix new file mode 100644 index 00000000..18188e78 --- /dev/null +++ b/accounts/gkleen@sif/xmobar/shell.nix @@ -0,0 +1,28 @@ +{ nixpkgs ? import ./nixpkgs.nix {} }: + +let + inherit (nixpkgs {}) pkgs; + haskellPackages = import ./stackage.nix { inherit nixpkgs; }; + + drv = haskellPackages.callPackage ./xmobar-yggdrasil.nix {}; + override = oldAttrs: { + nativeBuildInputs = oldAttrs.nativeBuildInputs ++ (with pkgs; []) ++ (with haskellPackages; [ stack cabal-install cabal2nix ]); + shellHook = '' + export PROMPT_INFO="${oldAttrs.name}" + + if [ -n "$ZSH_VERSION" ]; then + autoload -U +X compinit && compinit + autoload -U +X bashcompinit && bashcompinit + fi + eval "$(stack --bash-completion-script stack)" + + ${oldAttrs.shellHook} + ''; + }; + + dummy = pkgs.stdenv.mkDerivation { + name = "interactive-xmobar-environment"; + shellHook = ""; + }; +in pkgs.stdenv.lib.overrideDerivation dummy override + #pkgs.stdenv.lib.overrideDerivation drv.env override diff --git a/accounts/gkleen@sif/xmobar/stack.nix b/accounts/gkleen@sif/xmobar/stack.nix new file mode 100644 index 00000000..17a49e04 --- /dev/null +++ b/accounts/gkleen@sif/xmobar/stack.nix @@ -0,0 +1,17 @@ +{ ghc, nixpkgs ? import ./nixpkgs.nix {} }: + +let + haskellPackages = import ./stackage.nix { inherit nixpkgs; }; + inherit (nixpkgs {}) pkgs; +in pkgs.haskell.lib.buildStackProject { + inherit ghc; + inherit (haskellPackages) stack; + name = "stackenv"; + buildInputs = (with pkgs; + [ xorg.libX11 xorg.libXrandr xorg.libXinerama xorg.libXScrnSaver xorg.libXext xorg.libXft + cairo + glib + ]) ++ (with haskellPackages; + [ + ]); +} diff --git a/accounts/gkleen@sif/xmobar/stack.yaml b/accounts/gkleen@sif/xmobar/stack.yaml new file mode 100644 index 00000000..b8ed1147 --- /dev/null +++ b/accounts/gkleen@sif/xmobar/stack.yaml @@ -0,0 +1,10 @@ +nix: + enable: true + shell-file: stack.nix + +resolver: lts-13.21 + +packages: + - . + +extra-deps: [] diff --git a/accounts/gkleen@sif/xmobar/stack.yaml.lock b/accounts/gkleen@sif/xmobar/stack.yaml.lock new file mode 100644 index 00000000..fcc2f5f3 --- /dev/null +++ b/accounts/gkleen@sif/xmobar/stack.yaml.lock @@ -0,0 +1,12 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: [] +snapshots: +- completed: + size: 498180 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/13/21.yaml + sha256: eff2de19a6d4691ccbf6edc1fba858f1918683047dce0f09adede874bbd2a8f3 + original: lts-13.21 diff --git a/accounts/gkleen@sif/xmobar/stackage.nix b/accounts/gkleen@sif/xmobar/stackage.nix new file mode 100644 index 00000000..c162ca2c --- /dev/null +++ b/accounts/gkleen@sif/xmobar/stackage.nix @@ -0,0 +1,31 @@ +{ nixpkgs ? import ./nixpkgs.nix {} +, snapshot ? "lts-13.21" +}: + +let + stackage = import (fetchTarball { + url = "https://stackage.serokell.io/zb36jsy3r5h4ydz0pnp00g9vk94dvv03-stackage/default.nix.tar.gz"; + sha256 = "0h6f80gds0ds77y51hhiadh2h2k8njqq8n0gayp729ana9m9agma"; + }); + + overlays = + [ stackage."${snapshot}" + (self: super: { + haskell = super.haskell // { + packages = super.haskell.packages // { + "${snapshot}" = super.haskell.packages."${snapshot}".override { + overrides = hself: hsuper: { + zip-archive = self.haskell.lib.overrideCabal hsuper.zip-archive (old: { + testToolDepends = old.testToolDepends ++ (with self; [ unzip which ]); + }); + alex = self.haskell.lib.dontCheck hsuper.alex; + }; + }; + }; + }; + } + ) + ]; + + inherit (nixpkgs { inherit overlays; }) pkgs; +in pkgs.haskell.packages."${snapshot}" diff --git a/accounts/gkleen@sif/xmobar/xmobar-yggdrasil.nix b/accounts/gkleen@sif/xmobar/xmobar-yggdrasil.nix new file mode 100644 index 00000000..1dfc619b --- /dev/null +++ b/accounts/gkleen@sif/xmobar/xmobar-yggdrasil.nix @@ -0,0 +1,13 @@ +{ mkDerivation, base, hpack, stdenv, xmobar }: +mkDerivation { + pname = "xmobar-yggdrasil"; + version = "0.0.0"; + src = ./.; + isLibrary = false; + isExecutable = true; + libraryToolDepends = [ hpack ]; + executableHaskellDepends = [ base xmobar ]; + preConfigure = "hpack"; + license = "unknown"; + hydraPlatforms = stdenv.lib.platforms.none; +} diff --git a/accounts/gkleen@sif/xmobar/xmobar.hs b/accounts/gkleen@sif/xmobar/xmobar.hs new file mode 100644 index 00000000..ea53082d --- /dev/null +++ b/accounts/gkleen@sif/xmobar/xmobar.hs @@ -0,0 +1,52 @@ +import Xmobar + +import Data.List (intercalate) + + +main :: IO () +main = xmobar config + where + config = defaultConfig + { font = "xft:Fira Mono for Powerline:style=Medium:pixelsize=22.5" + , position = OnScreen 0 $ TopP 0 307 + , bgColor = "black" + , fgColor = "grey" + , overrideRedirect = False + , template = + let left = intercalate " | " + [ "%XMonadWorkspaces%" + , "%XMonadLayout%" + , "%XMonadTitle%" + ] + right = intercalate " | " + [ {- "%status%" + , -} "%battery%" + , "%kbd%" + , "%worktime%" + , "%worktime-today%" + , "%time%" + , "%date%" + ] + in left <> "}{" <> right + , commands = + [ Run $ NamedXPropertyLog "_XMONAD_WORKSPACES" "XMonadWorkspaces" + , Run $ NamedXPropertyLog "_XMONAD_LAYOUT" "XMonadLayout" + , Run $ NamedXPropertyLog "_XMONAD_TITLE" "XMonadTitle" + , Run $ Date "%H:%M" "time" 50 + , Run $ Date "%a %b %_d" "date" 50 + , Run $ Com "worktime" [] "worktime" 1500 + , Run $ Com "worktime" ["today"] "worktime-today" 1500 + , Run $ Com "ssh" ["status.odin"] "status" 600 + , Run $ Kbd [("us(dvp)", "dvp")] + , Run $ Battery + [ "--template", " () AC " + , "--suffix", "On" + , "--Low", "10" + , "--High", "80" + , "--low", "darkred" + , "--normal", "darkorange" + , "--high", "darkgreen" + , "-p", "3" + ] 50 + ] + } -- cgit v1.2.3