Browse Source

Add services such as MPD and Gromit, plus more stuff

master
Peter J. Jones 4 months ago
parent
commit
92c1d07f9e
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49

+ 2
- 2
nixos/default.nix View File

@@ -16,7 +16,7 @@ in
imports = [
./modules/shells.nix
./modules/wheel.nix
./modules/workstation.nix
./modules/workstation
];

#### Interface:
@@ -56,9 +56,9 @@ in
curl
gitAndTools.gitAnnex
gitAndTools.git
gnumake
gnupg
gnutls
htop
inotifyTools
jq
lsscsi

nixos/modules/workstation.nix → nixos/modules/workstation/default.nix View File

@@ -4,20 +4,13 @@ with lib;

let
cfg = config.pjones;
base = import ../../pkgs { inherit pkgs; };
base = import ../../../pkgs { inherit pkgs; };

emacsrc = base.emacsrc;
encryption-utils = base.encryption-utils;

# Restart plasmashell after switching display configuration (the
# plasma panel goes a bit wonky):
autorandr-postswitch = pkgs.writeScript "autorandr-postswitch" ''
#!${pkgs.stdenv.shell}
kquitapp5 plasmashell; kstart5 plasmashell > /dev/null 2>&1 &
'';

# Set XDG environment variables to my liking:
xdg-set-up = pkgs.writeScript "xdg-set-up" (readFile ../../support/workstation/xdg.sh);
xdg-set-up = pkgs.writeScript "xdg-set-up" (readFile ../../../support/workstation/xdg.sh);

# Reuse the startkde script from NixOS:
xsessions = config.services.xserver.desktopManager.session.list;
@@ -26,12 +19,24 @@ in
{
# Additional files:
imports = [
./gromit-mpx.nix
./ipfs.nix
./keyboard.nix
./mail.nix
./mpd.nix
./syncthing.nix
./yubikey.nix
];

#### Implementation:
config = mkIf cfg.isWorkstation {

# Make sure X is enabled:
services.xserver.enable = mkDefault true;
services.xserver.layout = mkDefault "us";
services.xserver.displayManager.sddm.enable = mkDefault true;
services.xserver.desktopManager.plasma5.enable = mkDefault true;

# Extra groups needed on a workstation:
users.users.pjones.extraGroups = [
"cdrom"
@@ -41,30 +46,31 @@ in
"scanner"
];

# Some things only work if installed in the system environment:
environment.systemPackages = with pkgs; [
arc-icon-theme
arc-theme
gwenview
hicolor_icon_theme
kdeconnect
playbar2
qt5.qttools
] ++ filter isDerivation (attrValues pkgs.kdeApplications);

# Extra packages:
users.users.pjones.packages = with pkgs; [
# Desktop
arc-icon-theme
arc-theme
autorandr
bspwm
calibre
glabels
gwenview
hicolor_icon_theme
kdeApplications.krdc
kdeconnect
libnotify
libreoffice
pamixer
pavucontrol
plasma5.user-manager
playbar2
qt5.qttools
rofi
rofi-pass
sxhkd
x11vnc
xclip
xdo
xdotool
xorg.xev
@@ -100,11 +106,11 @@ in
gimp
imagemagick
inkscape
kicad
librecad
ngspice
openscad
pdftk
qgis
qmapshack
slic3r
xournal
@@ -124,15 +130,10 @@ in
emacsrc
];

# NixOS services:
services.autorandr.enable = true;
services.dbus.enable = true;

# Home Manager:
home-manager.users.pjones = { ... }: {
# Files in ~pjones:
home.file.".emacs".source = "${emacsrc}/dot.emacs.el";
xdg.configFile."autorandr/postswitch".source = "${autorandr-postswitch}";

# Services:
xsession = {
@@ -171,7 +172,8 @@ in
inactiveOpacity = "0.85";
opacityRule = [
"20:class_i *= 'presel_feedback'"
"100:class_g = 'rofi'" # Why doesn't this work?
"99:class_i *= 'sddm'"
"99:class_i = 'rofi'"
];

extraOptions = ''

+ 42
- 0
nixos/modules/workstation/gromit-mpx.nix View File

@@ -0,0 +1,42 @@
{ config, pkgs, lib, ... }:

with lib;

let
cfg = config.pjones;

# Easy pen definition:
mkTool = attrs: { device="default"; size=3; } // attrs;

in
{
config = mkIf cfg.isWorkstation {
home-manager.users.pjones = { ... }: {
services.gromit-mpx = {
enable = true;

tools = [
(mkTool { color="#ff00ff"; })
(mkTool { color="#00c0ff"; modifiers = [ "SHIFT" ]; })
(mkTool { color="#00ff00"; modifiers = [ "CONTROL" ]; })
(mkTool { color="#eded02"; modifiers = [ "ALT" ]; })
(mkTool { color="#ed0202"; modifiers = [ "SHIFT" "CONTROL" ]; })
(mkTool { color="#3131be"; modifiers = [ "SHIFT" "ALT" ]; })
(mkTool { type="eraser"; size=75; modifiers = [ "ALT" "CONTROL" ]; })

{ device = "Wacom Bamboo One M Pen";
modifiers = [ "1" "2" ];
type = "eraser";
size = 75;
}

{ device = "Wacom Bamboo One M Pen";
modifiers = [ "1" "3" ];
size = 10;
color = "#00c0ff";
}
];
};
};
};
}

+ 23
- 0
nixos/modules/workstation/ipfs.nix View File

@@ -0,0 +1,23 @@
# Configure IPFS:
{ config, pkgs, lib, ... }:

with lib;

let
cfg = config.pjones;

in
{
config = mkIf cfg.isWorkstation {
networking.firewall = {
allowedTCPPorts = [
4001 # IPFS Swarm.
];
};

services.ipfs = {
enable = true;
autoMount = true;
};
};
}

+ 31
- 0
nixos/modules/workstation/keyboard.nix View File

@@ -0,0 +1,31 @@
# Support for custom keyboards:
{ config, pkgs, lib, ... }:

with lib;

let
cfg = config.pjones;

package = pkgs.stdenvNoCC.mkDerivation {
name = "keyboard-script";
phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
src = ./.;

installPhase = ''
mkdir -p $out/bin
install -m 0555 ${../../../support/workstation/keyboard.sh} $out/bin/keyboard.sh
'';
};

script = pkgs.writeScript "keyboard-setup" ''
sudo -u pjones ${package}/bin/keyboard.sh
'';

in
{
config = mkIf cfg.isWorkstation {
services.udev.extraRules = ''
ATTRS{idVendor}=="0xfeed", ATTRS{idProduct}=="0x3060", RUN+="${script}"
'';
};
}

nixos/modules/mail.nix → nixos/modules/workstation/mail.nix View File


+ 21
- 0
nixos/modules/workstation/mpd.nix View File

@@ -0,0 +1,21 @@
{ config, pkgs, lib, ... }:

with lib;

let
cfg = config.pjones;

in
{
config = mkIf cfg.isWorkstation {
home-manager.users.pjones = { config, ... }: {
services.mpd = {
enable = true;
musicDirectory = "${config.home.homeDirectory}/documents/music";
playlistDirectory = "${config.home.homeDirectory}/documents/playlists";
};

services.mpdris2.enable = true;
};
};
}

+ 29
- 0
nixos/modules/workstation/syncthing.nix View File

@@ -0,0 +1,29 @@
# Start syncthing and open the firewall.
{ config, pkgs, lib, ... }:

with lib;

let
cfg = config.pjones;

in
{
config = mkIf cfg.isWorkstation {
networking.firewall = {
allowedTCPPorts = [
22000 # Syncthing
];

allowedUDPPorts = [
21027 # Syncthing
];
};

home-manager.users.pjones = { config, ... }: {
services.syncthing = {
enable = true;
tray = true;
};
};
};
}

+ 25
- 0
nixos/modules/workstation/yubikey.nix View File

@@ -0,0 +1,25 @@
{ config, pkgs, lib, ... }:

with lib;

let
cfg = config.pjones;

in
{
config = mkIf cfg.isWorkstation {
# Helpful packages:
users.users.pjones.packages = with pkgs; [
yubikey-personalization
yubikey-personalization-gui
];

# This allows GnuPG to see/read the Yubikey.
services.pcscd.enable = true;

# This might be obsolete now that pcscd is running.
services.udev.extraRules = ''
ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0111", MODE="0660", GROUP="wheel", SYMLINK+="yubikey"
'';
};
}

+ 3
- 3
pkgs/pkgs.json View File

@@ -1,7 +1,7 @@
{
"url": "git://git.devalot.com/pkgs.git",
"rev": "a6f57dd719a8350e9d021fbceb6fbd13d76f12fb",
"date": "2019-02-10T20:10:32-07:00",
"sha256": "03ibl3m88plrgc0q03ql676ivpdfj2si02v4yrq36xiym2r9pavh",
"rev": "924aa224fa4fd82f52cd5949c76e86eedd30fde9",
"date": "2019-02-21T17:08:25-07:00",
"sha256": "16c4rqfm8fij3z1fyzs6k96ad1w99p00sh5j3yg5njv70v1dgvb5",
"fetchSubmodules": false
}

+ 37
- 0
support/workstation/keyboard.sh View File

@@ -0,0 +1,37 @@
#!/bin/sh

################################################################################
# Disable the built~in keyboard when using an external keyboard.
set -e
set -u

################################################################################
export DISPLAY=${DISPLAY:=:0.0}
export XAUTHORITY=$HOME/.Xauthority

################################################################################
list_builtin_keyboard() {
xinput --list --name-only | \
grep -Ei '^AT .*keyboard' | \
head -n 1
}

################################################################################
external_keyboard_found() {
xinput --list --name-only | \
grep -Eq 'Crkbd'
}

################################################################################
name=$(list_builtin_keyboard)

if [ -z "$name" ]; then
>&2 echo "ERROR: can't find built-in keyboard!"
exit 1
fi

if external_keyboard_found; then
xinput --disable "$name"
else
xinput --enable "$name"
fi

Loading…
Cancel
Save