From d8116e5a6aef0f7ee6c29fe84c87e5e87566f913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Fri, 28 May 2021 15:58:33 +0100 Subject: [PATCH] Add emacs --- nixos/boxes/foureighty/modem.sh | 105 ++++++++++++++++++ nixos/home-manager/default.nix | 1 + nixos/home-manager/programs/emacs/default.nix | 8 ++ nixos/home-manager/programs/emacs/emacs.nix | 16 +++ nixos/home-manager/programs/emacs/home.nix | 8 ++ 5 files changed, 138 insertions(+) create mode 100644 nixos/boxes/foureighty/modem.sh create mode 100644 nixos/home-manager/programs/emacs/default.nix create mode 100644 nixos/home-manager/programs/emacs/emacs.nix create mode 100644 nixos/home-manager/programs/emacs/home.nix diff --git a/nixos/boxes/foureighty/modem.sh b/nixos/boxes/foureighty/modem.sh new file mode 100644 index 00000000..849fa0cf --- /dev/null +++ b/nixos/boxes/foureighty/modem.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash + +### +# This script automate the setup of QMI supported wwan devices. +# +# Tested on following environment: +# * Lenovo ThinkPad X220 (4286-CTO) +# * Gentoo/Linux, Linux Kernel 3.9.6 +# * NTT Docomo UIM card (Xi LTE SIM) +# * Sierra Wireless, Inc. Gobi 3000 wireless wan module +# (FRU 60Y3257, vendor and device id is 1199:9013) +# memo: +# I recommend to check if your wwan module works fine +# for your mobile broadband provider with Windows +# especially if you imported the device from other country. +# You may have to initialize your device for your region. +# * Required kernel config (other modules may be also required): +# - qmi_wwan (CONFIG_USB_NET_QMI_WWAN) +# - qcserial (CONFIG_USB_SERIAL_QUALCOMM) +# * Required settings: +# - you may have to create /etc/qmi-network.conf. +# My qmi-network.conf has only a line "APN=mopera.net". +# + +# your wwan device name created by qmi_wwan kernel module +# check it with "ip a" or "ifconfig -a". it may be wwan0? +WWAN_DEV=wwp0s29u1u4 +# your cdc_wdm modem location +CDC_WDM=/dev/cdc-wdm0 +# this script uses following qmi commands +QMICLI=/usr/bin/qmicli +QMI_NETWORK=/usr/bin/qmi-network +# the places of following commands vary depending on your distribution +IFCONFIG=/bin/ifconfig +DHCPCD=/sbin/dhcpcd +SUDO=/usr/bin/sudo + +function helpmsg { + echo "usage: $0 {start|stop|restart|status}" + exit 1 +} + +function qmi_start { + $COMMAND_PREFIX $IFCONFIG $WWAN_DEV up + $COMMAND_PREFIX $QMICLI -d $CDC_WDM --dms-set-operating-mode=online + if [ $? -ne 0 ]; then + echo "your wwan device may be RFKilled?" + exit 1 + fi + $COMMAND_PREFIX $QMI_NETWORK $CDC_WDM start + $COMMAND_PREFIX $DHCPCD $WWAN_DEV +} + +function qmi_stop { + $COMMAND_PREFIX $QMI_NETWORK $CDC_WDM stop + $COMMAND_PREFIX kill `cat /var/run/dhcpcd-${WWAN_DEV}.pid` + $COMMAND_PREFIX $IFCONFIG $WWAN_DEV down +} + +function qmi_strength { + dbm=`$COMMAND_PREFIX $QMICLI -d $CDC_WDM --nas-get-signal-strength | tr "'" " " | grep Network | head -1 | awk '{print $4}'` + echo -n "Signal strength is " + if [ $dbm -ge -73 ]; then + echo -n 'Excellent' + elif [ $dbm -ge -83 ]; then + echo -n 'Good' + elif [ $dbm -ge -93 ]; then + echo -n 'OK' + elif [ $dbm -ge -109 ]; then + echo -n 'Marginal' + else + echo Unknown + fi + echo " (${dbm} dBm)" +} + +function qmi_status { + $COMMAND_PREFIX $QMI_NETWORK $CDC_WDM status + qmi_strength +} + +# check argument number +if [ $# -ne 1 ] +then + helpmsg +fi + +# check permission +if [ `whoami` != 'root' ] +then + echo "warning: root permission required. setting command prefix to 'sudo'." + COMMAND_PREFIX=$SUDO +fi + +# run commands +case $1 in + start) qmi_start ;; + stop) qmi_stop ;; + restart) qmi_stop; qmi_start ;; + status) qmi_status ;; + *) helpmsg ;; +esac + + + diff --git a/nixos/home-manager/default.nix b/nixos/home-manager/default.nix index bd386fcb..38b218b3 100644 --- a/nixos/home-manager/default.nix +++ b/nixos/home-manager/default.nix @@ -25,6 +25,7 @@ ./programs/tmux.nix ./programs/zsh.nix ./programs/vim.nix + ./programs/emacs/home.nix ./programs/kitty.nix ./programs/newsboat.nix ./programs.nix diff --git a/nixos/home-manager/programs/emacs/default.nix b/nixos/home-manager/programs/emacs/default.nix new file mode 100644 index 00000000..2c4065d1 --- /dev/null +++ b/nixos/home-manager/programs/emacs/default.nix @@ -0,0 +1,8 @@ +{ config, pkgs, lib, ... }: +{ + home-manager.users.cyryl = {...}: { + imports = [ + ./home.nix + ]; + }; +} diff --git a/nixos/home-manager/programs/emacs/emacs.nix b/nixos/home-manager/programs/emacs/emacs.nix new file mode 100644 index 00000000..e3c265de --- /dev/null +++ b/nixos/home-manager/programs/emacs/emacs.nix @@ -0,0 +1,16 @@ +{ pkgs ? import {} }: +let + myEmacs = pkgs.emacs-nox; + emacsWithPackages = (pkgs.emacsPackagesGen myEmacs).emacsWithPackages; +in + emacsWithPackages (epkgs: (with epkgs.melpaStablePackages; [ + magit # ; Integrate git + zerodark-theme # ; Nicolas' theme + ]) ++ (with epkgs.melpaPackages; [ + + ]) ++ (with epkgs.elpaPackages; [ + beacon # ; highlight my cursor when scrolling + nameless # ; hide current package name everywhere in elisp code + ]) ++ [ + pkgs.notmuch # From main packages set + ]) diff --git a/nixos/home-manager/programs/emacs/home.nix b/nixos/home-manager/programs/emacs/home.nix new file mode 100644 index 00000000..6edba4c3 --- /dev/null +++ b/nixos/home-manager/programs/emacs/home.nix @@ -0,0 +1,8 @@ +{ config, pkgs, ... }: +{ + programs.emacs = { + enable = true; + package = (import ./emacs.nix { inherit pkgs; }); + }; + +}