Browse Source

Add services such as MPD and Gromit, plus more stuff

master
Peter J. Jones 2 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
16 16
   imports = [
17 17
     ./modules/shells.nix
18 18
     ./modules/wheel.nix
19
-    ./modules/workstation.nix
19
+    ./modules/workstation
20 20
   ];
21 21
 
22 22
   #### Interface:
@@ -56,9 +56,9 @@ in
56 56
         curl
57 57
         gitAndTools.gitAnnex
58 58
         gitAndTools.git
59
-        gnumake
60 59
         gnupg
61 60
         gnutls
61
+        htop
62 62
         inotifyTools
63 63
         jq
64 64
         lsscsi

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

@@ -4,20 +4,13 @@ with lib;
4 4
 
5 5
 let
6 6
   cfg = config.pjones;
7
-  base = import ../../pkgs { inherit pkgs; };
7
+  base = import ../../../pkgs { inherit pkgs; };
8 8
 
9 9
   emacsrc = base.emacsrc;
10 10
   encryption-utils = base.encryption-utils;
11 11
 
12
-  # Restart plasmashell after switching display configuration (the
13
-  # plasma panel goes a bit wonky):
14
-  autorandr-postswitch = pkgs.writeScript "autorandr-postswitch" ''
15
-    #!${pkgs.stdenv.shell}
16
-    kquitapp5 plasmashell; kstart5 plasmashell > /dev/null 2>&1 &
17
-  '';
18
-
19 12
   # Set XDG environment variables to my liking:
20
-  xdg-set-up = pkgs.writeScript "xdg-set-up" (readFile ../../support/workstation/xdg.sh);
13
+  xdg-set-up = pkgs.writeScript "xdg-set-up" (readFile ../../../support/workstation/xdg.sh);
21 14
 
22 15
   # Reuse the startkde script from NixOS:
23 16
   xsessions = config.services.xserver.desktopManager.session.list;
@@ -26,12 +19,24 @@ in
26 19
 {
27 20
   # Additional files:
28 21
   imports = [
22
+    ./gromit-mpx.nix
23
+    ./ipfs.nix
24
+    ./keyboard.nix
29 25
     ./mail.nix
26
+    ./mpd.nix
27
+    ./syncthing.nix
28
+    ./yubikey.nix
30 29
   ];
31 30
 
32 31
   #### Implementation:
33 32
   config = mkIf cfg.isWorkstation {
34 33
 
34
+    # Make sure X is enabled:
35
+    services.xserver.enable = mkDefault true;
36
+    services.xserver.layout = mkDefault "us";
37
+    services.xserver.displayManager.sddm.enable = mkDefault true;
38
+    services.xserver.desktopManager.plasma5.enable = mkDefault true;
39
+
35 40
     # Extra groups needed on a workstation:
36 41
     users.users.pjones.extraGroups = [
37 42
       "cdrom"
@@ -41,30 +46,31 @@ in
41 46
       "scanner"
42 47
     ];
43 48
 
49
+    # Some things only work if installed in the system environment:
50
+    environment.systemPackages = with pkgs; [
51
+      arc-icon-theme
52
+      arc-theme
53
+      gwenview
54
+      hicolor_icon_theme
55
+      kdeconnect
56
+      playbar2
57
+      qt5.qttools
58
+    ] ++ filter isDerivation (attrValues pkgs.kdeApplications);
59
+
44 60
     # Extra packages:
45 61
     users.users.pjones.packages = with pkgs; [
46 62
       # Desktop
47
-      arc-icon-theme
48
-      arc-theme
49
-      autorandr
50 63
       bspwm
51 64
       calibre
52 65
       glabels
53
-      gwenview
54
-      hicolor_icon_theme
55
-      kdeApplications.krdc
56
-      kdeconnect
57 66
       libnotify
58 67
       libreoffice
59 68
       pamixer
60 69
       pavucontrol
61
-      plasma5.user-manager
62
-      playbar2
63
-      qt5.qttools
64 70
       rofi
65
-      rofi-pass
66 71
       sxhkd
67 72
       x11vnc
73
+      xclip
68 74
       xdo
69 75
       xdotool
70 76
       xorg.xev
@@ -100,11 +106,11 @@ in
100 106
       gimp
101 107
       imagemagick
102 108
       inkscape
109
+      kicad
103 110
       librecad
104 111
       ngspice
105 112
       openscad
106 113
       pdftk
107
-      qgis
108 114
       qmapshack
109 115
       slic3r
110 116
       xournal
@@ -124,15 +130,10 @@ in
124 130
       emacsrc
125 131
     ];
126 132
 
127
-    # NixOS services:
128
-    services.autorandr.enable = true;
129
-    services.dbus.enable = true;
130
-
131 133
     # Home Manager:
132 134
     home-manager.users.pjones = { ... }: {
133 135
       # Files in ~pjones:
134 136
       home.file.".emacs".source = "${emacsrc}/dot.emacs.el";
135
-      xdg.configFile."autorandr/postswitch".source = "${autorandr-postswitch}";
136 137
 
137 138
       # Services:
138 139
       xsession = {
@@ -171,7 +172,8 @@ in
171 172
         inactiveOpacity = "0.85";
172 173
         opacityRule = [
173 174
           "20:class_i *= 'presel_feedback'"
174
-          "100:class_g = 'rofi'" # Why doesn't this work?
175
+          "99:class_i *= 'sddm'"
176
+          "99:class_i  = 'rofi'"
175 177
         ];
176 178
 
177 179
         extraOptions = ''

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

@@ -0,0 +1,42 @@
1
+{ config, pkgs, lib, ... }:
2
+
3
+with lib;
4
+
5
+let
6
+  cfg = config.pjones;
7
+
8
+  # Easy pen definition:
9
+  mkTool = attrs: { device="default"; size=3; } // attrs;
10
+
11
+in
12
+{
13
+  config = mkIf cfg.isWorkstation {
14
+    home-manager.users.pjones = { ... }: {
15
+      services.gromit-mpx = {
16
+        enable = true;
17
+
18
+        tools = [
19
+          (mkTool { color="#ff00ff"; })
20
+          (mkTool { color="#00c0ff"; modifiers = [ "SHIFT" ]; })
21
+          (mkTool { color="#00ff00"; modifiers = [ "CONTROL" ]; })
22
+          (mkTool { color="#eded02"; modifiers = [ "ALT" ]; })
23
+          (mkTool { color="#ed0202"; modifiers = [ "SHIFT" "CONTROL" ]; })
24
+          (mkTool { color="#3131be"; modifiers = [ "SHIFT" "ALT" ]; })
25
+          (mkTool { type="eraser"; size=75; modifiers = [ "ALT" "CONTROL" ]; })
26
+
27
+          { device = "Wacom Bamboo One M Pen";
28
+            modifiers = [ "1" "2" ];
29
+            type = "eraser";
30
+            size = 75;
31
+          }
32
+
33
+          { device = "Wacom Bamboo One M Pen";
34
+            modifiers = [ "1" "3" ];
35
+            size = 10;
36
+            color = "#00c0ff";
37
+          }
38
+        ];
39
+      };
40
+    };
41
+  };
42
+}

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

@@ -0,0 +1,23 @@
1
+# Configure IPFS:
2
+{ config, pkgs, lib, ... }:
3
+
4
+with lib;
5
+
6
+let
7
+  cfg = config.pjones;
8
+
9
+in
10
+{
11
+  config = mkIf cfg.isWorkstation {
12
+    networking.firewall = {
13
+      allowedTCPPorts = [
14
+        4001 # IPFS Swarm.
15
+      ];
16
+    };
17
+
18
+    services.ipfs = {
19
+      enable = true;
20
+      autoMount = true;
21
+    };
22
+  };
23
+}

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

@@ -0,0 +1,31 @@
1
+# Support for custom keyboards:
2
+{ config, pkgs, lib, ... }:
3
+
4
+with lib;
5
+
6
+let
7
+  cfg = config.pjones;
8
+
9
+  package = pkgs.stdenvNoCC.mkDerivation {
10
+    name = "keyboard-script";
11
+    phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
12
+    src = ./.;
13
+
14
+    installPhase = ''
15
+      mkdir -p $out/bin
16
+      install -m 0555 ${../../../support/workstation/keyboard.sh} $out/bin/keyboard.sh
17
+    '';
18
+  };
19
+
20
+  script = pkgs.writeScript "keyboard-setup" ''
21
+    sudo -u pjones ${package}/bin/keyboard.sh
22
+  '';
23
+
24
+in
25
+{
26
+  config = mkIf cfg.isWorkstation {
27
+    services.udev.extraRules = ''
28
+      ATTRS{idVendor}=="0xfeed", ATTRS{idProduct}=="0x3060", RUN+="${script}"
29
+    '';
30
+  };
31
+}

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


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

@@ -0,0 +1,21 @@
1
+{ config, pkgs, lib, ... }:
2
+
3
+with lib;
4
+
5
+let
6
+  cfg = config.pjones;
7
+
8
+in
9
+{
10
+  config = mkIf cfg.isWorkstation {
11
+    home-manager.users.pjones = { config, ... }: {
12
+      services.mpd = {
13
+        enable = true;
14
+        musicDirectory = "${config.home.homeDirectory}/documents/music";
15
+        playlistDirectory = "${config.home.homeDirectory}/documents/playlists";
16
+      };
17
+
18
+      services.mpdris2.enable = true;
19
+    };
20
+  };
21
+}

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

@@ -0,0 +1,29 @@
1
+# Start syncthing and open the firewall.
2
+{ config, pkgs, lib, ... }:
3
+
4
+with lib;
5
+
6
+let
7
+  cfg = config.pjones;
8
+
9
+in
10
+{
11
+  config = mkIf cfg.isWorkstation {
12
+    networking.firewall = {
13
+      allowedTCPPorts = [
14
+        22000 # Syncthing
15
+      ];
16
+
17
+      allowedUDPPorts = [
18
+        21027 # Syncthing
19
+      ];
20
+    };
21
+
22
+    home-manager.users.pjones = { config, ... }: {
23
+      services.syncthing = {
24
+        enable = true;
25
+        tray = true;
26
+      };
27
+    };
28
+  };
29
+}

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

@@ -0,0 +1,25 @@
1
+{ config, pkgs, lib, ... }:
2
+
3
+with lib;
4
+
5
+let
6
+  cfg = config.pjones;
7
+
8
+in
9
+{
10
+  config = mkIf cfg.isWorkstation {
11
+    # Helpful packages:
12
+    users.users.pjones.packages = with pkgs; [
13
+      yubikey-personalization
14
+      yubikey-personalization-gui
15
+    ];
16
+
17
+    # This allows GnuPG to see/read the Yubikey.
18
+    services.pcscd.enable = true;
19
+
20
+    # This might be obsolete now that pcscd is running.
21
+    services.udev.extraRules = ''
22
+      ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0111", MODE="0660", GROUP="wheel", SYMLINK+="yubikey"
23
+    '';
24
+  };
25
+}

+ 3
- 3
pkgs/pkgs.json View File

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

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

@@ -0,0 +1,37 @@
1
+#!/bin/sh
2
+
3
+################################################################################
4
+# Disable the built~in keyboard when using an external keyboard.
5
+set -e
6
+set -u
7
+
8
+################################################################################
9
+export DISPLAY=${DISPLAY:=:0.0}
10
+export XAUTHORITY=$HOME/.Xauthority
11
+
12
+################################################################################
13
+list_builtin_keyboard() {
14
+  xinput --list --name-only | \
15
+    grep -Ei '^AT .*keyboard' | \
16
+      head -n 1
17
+}
18
+
19
+################################################################################
20
+external_keyboard_found() {
21
+  xinput --list --name-only | \
22
+    grep -Eq 'Crkbd'
23
+}
24
+
25
+################################################################################
26
+name=$(list_builtin_keyboard)
27
+
28
+if [ -z "$name" ]; then
29
+  >&2 echo "ERROR: can't find built-in keyboard!"
30
+  exit 1
31
+fi
32
+
33
+if external_keyboard_found; then
34
+  xinput --disable "$name"
35
+else
36
+  xinput --enable "$name"
37
+fi

Loading…
Cancel
Save