Browse Source

Initial import

master
Peter J. Jones 4 months ago
commit
4238edf286
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49
11 changed files with 492 additions and 0 deletions
  1. 26
    0
      LICENSE
  2. 10
    0
      README.md
  3. 7
    0
      default.nix
  4. 81
    0
      nixos/default.nix
  5. 85
    0
      nixos/modules/mail.nix
  6. 36
    0
      nixos/modules/shells.nix
  7. 15
    0
      nixos/modules/wheel.nix
  8. 184
    0
      nixos/modules/workstation.nix
  9. 11
    0
      pkgs/default.nix
  10. 7
    0
      pkgs/pkgs.json
  11. 30
    0
      support/workstation/xdg.sh

+ 26
- 0
LICENSE View File

@@ -0,0 +1,26 @@
1
+Copyright (c) 2019 Peter J. Jones <pjones@devalot.com>
2
+All rights reserved.
3
+
4
+Redistribution and use in source and binary forms, with or without
5
+modification, are permitted provided that the following conditions are
6
+met:
7
+
8
+1. Redistributions of source code must retain the above copyright
9
+   notice, this list of conditions and the following disclaimer.
10
+
11
+2. Redistributions in binary form must reproduce the above copyright
12
+   notice, this list of conditions and the following disclaimer in the
13
+   documentation and/or other materials provided with the
14
+   distribution.
15
+
16
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 10
- 0
README.md View File

@@ -0,0 +1,10 @@
1
+Peter's Account
2
+===============
3
+
4
+Want to create an account for me on a NixOS machine?  Thanks!
5
+
6
+Just add the `default.nix` file to one of your `imports`.
7
+
8
+The only requirement is that you have [home-manager][] included as well.
9
+
10
+[home-manager]: https://github.com/rycee/home-manager

+ 7
- 0
default.nix View File

@@ -0,0 +1,7 @@
1
+{ config, pkgs, lib, ... }:
2
+
3
+{
4
+  imports = [
5
+    ./nixos
6
+  ];
7
+}

+ 81
- 0
nixos/default.nix View File

@@ -0,0 +1,81 @@
1
+# User entry for pjones.
2
+{ config, pkgs, lib, ... }:
3
+
4
+with lib;
5
+
6
+let
7
+  sshPubKeys = [
8
+    "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOT7Ys7LyugF3A5wsJ1EH1CF9jAdihtSWrJskUtDACCR medusa"
9
+    "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG1g7KoenMd6JIWnIuOQOYAaPNk6rF+6vwXBqNic2Juk elphaba"
10
+    "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJKW//sdBipEzLP85H89J1a8ma4J5IRbhEL+3/jEDANk leota"
11
+    "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuiLy4mwlSXLn18H/8tTqCcfq0obMNkEQfU27AgJDdw slugworth"
12
+  ];
13
+in
14
+{
15
+  #### Additional Files:
16
+  imports = [
17
+    ./modules/shells.nix
18
+    ./modules/wheel.nix
19
+    ./modules/workstation.nix
20
+  ];
21
+
22
+  #### Interface:
23
+  options.pjones = {
24
+    putInWheel = mkEnableOption "Allow access to the wheel group";
25
+    isWorkstation = mkEnableOption "The current machine is a workstation, not a server.";
26
+  };
27
+
28
+  #### Implementation:
29
+  config = {
30
+
31
+    # A group just for me:
32
+    users.groups.pjones = { };
33
+
34
+    # And my user account:
35
+    users.users.pjones = {
36
+      isNormalUser = true;
37
+      description = "Peter J. Jones";
38
+      group = "pjones";
39
+      createHome = true;
40
+      home = "/home/pjones";
41
+      shell = pkgs.zsh;
42
+      openssh.authorizedKeys.keys = sshPubKeys;
43
+
44
+      extraGroups = [
45
+        "docker"
46
+        "libvirtd"
47
+        "users"
48
+        "webhooks"
49
+        "webmaster"
50
+      ];
51
+
52
+      # Base set of packages I want on all machines:
53
+      packages = with pkgs; [
54
+        (unison.override {enableX11 = false;})
55
+        bc
56
+        curl
57
+        gitAndTools.gitAnnex
58
+        gitAndTools.git
59
+        gnumake
60
+        gnupg
61
+        gnutls
62
+        inotifyTools
63
+        jq
64
+        lsscsi
65
+        mkpasswd
66
+        openssl
67
+        parted
68
+        pciutils
69
+        pwgen
70
+        rdiff-backup
71
+        rsync
72
+        tmux
73
+        tree
74
+        unzip
75
+        usbutils
76
+        wget
77
+        zip
78
+      ];
79
+    };
80
+  };
81
+}

+ 85
- 0
nixos/modules/mail.nix View File

@@ -0,0 +1,85 @@
1
+{ config, pkgs, lib, ... }:
2
+
3
+with lib;
4
+
5
+let
6
+  cfg = config.pjones;
7
+
8
+  configFile = pkgs.writeText "mbsync-cfg" ''
9
+    IMAPAccount devalot
10
+    Host mail.pmade.com
11
+    User pjones
12
+    PassCmd "${pkgs.pass}/bin/pass show machines/mail.pmade.com/pjones"
13
+    SSLType IMAPS
14
+    SSLVersions TLSv1.2
15
+    CertificateFile /etc/ssl/certs/ca-certificates.crt
16
+
17
+    IMAPStore devalot-remote
18
+    Account devalot
19
+
20
+    MaildirStore devalot-local
21
+    Path ~/mail/devalot/
22
+    Inbox ~/mail/devalot/Inbox
23
+    SubFolders Verbatim
24
+
25
+    Channel devalot
26
+    Master :devalot-remote:
27
+    Slave :devalot-local:
28
+    Expunge both
29
+    Create Both
30
+    Remove Both
31
+    SyncState *
32
+    Patterns *
33
+
34
+    IMAPAccount rfa
35
+    Host outlook.office365.com
36
+    User peter.jones@rfa.sc.gov
37
+    PassCmd "${pkgs.pass}/bin/pass show business/clients/south-carolina/outlook.com"
38
+    SSLType IMAPS
39
+    SSLVersions TLSv1.2
40
+    CertificateFile /etc/ssl/certs/ca-certificates.crt
41
+    PipelineDepth 1
42
+
43
+    IMAPStore rfa-remote
44
+    Account rfa
45
+
46
+    MaildirStore rfa-local
47
+    Path ~/mail/rfa/
48
+    Inbox ~/mail/rfa/Inbox
49
+    SubFolders Verbatim
50
+
51
+    Channel rfa
52
+    Master :rfa-remote:
53
+    Slave :rfa-local:
54
+    Expunge both
55
+    Create Both
56
+    Remove Both
57
+    SyncState *
58
+    Patterns INBOX Archive "Deleted Items" Drafts "Sent Items"
59
+  '';
60
+
61
+  script = pkgs.writeShellScriptBin "mbsync-pjones" ''
62
+    # Make sure some directories exist:
63
+    mkdir -p ~/mail/devalot
64
+    mkdir -p ~/mail/rfa
65
+
66
+    # Do the mail sync:
67
+    mbsync --all
68
+
69
+    # Keep mu from indexing my SPAM folder:
70
+    touch ~/mail/devalot/Junk/.noindex
71
+  '';
72
+in
73
+{
74
+  #### Implementation:
75
+  config = mkIf cfg.isWorkstation {
76
+    users.users.pjones.packages = with pkgs; [
77
+      isync
78
+      mu
79
+    ] ++ [ script ];
80
+
81
+    home-manager.users.pjones = { ... }: {
82
+      home.file.".mbsyncrc".source = "${configFile}";
83
+    };
84
+  };
85
+}

+ 36
- 0
nixos/modules/shells.nix View File

@@ -0,0 +1,36 @@
1
+{ config, pkgs, lib, ... }:
2
+
3
+with lib;
4
+
5
+let
6
+  base = import ../../pkgs { inherit pkgs; };
7
+
8
+  bashrc = base.bashrc;
9
+  zshrc  = base.zshrc;
10
+  tmuxrc = base.tmuxrc;
11
+
12
+in
13
+{
14
+  programs.zsh = {
15
+    enable = true;
16
+    enableCompletion = true;
17
+    syntaxHighlighting.enable = true;
18
+  };
19
+
20
+  home-manager.users.pjones.home.file = {
21
+
22
+    # Bash
23
+    ".bashrc".source = "${bashrc}/share/bashrc";
24
+    ".bash_profile".source = "${bashrc}/share/bash_profile";
25
+    ".inputrc".source = "${bashrc}/share/inputrc";
26
+
27
+    # ZSH:
28
+    ".zshrc".source = "${zshrc}/share/zshrc/zshrc";
29
+    ".zshenv".source = "${zshrc}/share/zshrc/zshenv";
30
+    ".zsh".source = "${zshrc}/share/zshrc/zsh";
31
+
32
+    # tmux: (sort of like a shell :)
33
+    ".tmux.conf".source = "${tmuxrc}/config/tmux.conf";
34
+
35
+  };
36
+}

+ 15
- 0
nixos/modules/wheel.nix View File

@@ -0,0 +1,15 @@
1
+{ config, pkgs, lib, ... }:
2
+
3
+with lib;
4
+
5
+let
6
+  cfg = config.pjones;
7
+
8
+in
9
+{
10
+  config = mkIf cfg.putInWheel {
11
+    users.users.pjones.extraGroups = [
12
+      "wheel"
13
+    ];
14
+  };
15
+}

+ 184
- 0
nixos/modules/workstation.nix View File

@@ -0,0 +1,184 @@
1
+{ config, pkgs, lib, ... }:
2
+
3
+with lib;
4
+
5
+let
6
+  cfg = config.pjones;
7
+  base = import ../../pkgs { inherit pkgs; };
8
+
9
+  emacsrc = base.emacsrc;
10
+  encryption-utils = base.encryption-utils;
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
+  # Set XDG environment variables to my liking:
20
+  xdg-set-up = pkgs.writeScript "xdg-set-up" (readFile ../../support/workstation/xdg.sh);
21
+
22
+  # Reuse the startkde script from NixOS:
23
+  xsessions = config.services.xserver.desktopManager.session.list;
24
+  startkde = (head (filter (d: d.name == "plasma5") xsessions)).start;
25
+in
26
+{
27
+  # Additional files:
28
+  imports = [
29
+    ./mail.nix
30
+  ];
31
+
32
+  #### Implementation:
33
+  config = mkIf cfg.isWorkstation {
34
+
35
+    # Extra groups needed on a workstation:
36
+    users.users.pjones.extraGroups = [
37
+      "cdrom"
38
+      "dialout"
39
+      "disk"
40
+      "networkmanager"
41
+      "scanner"
42
+    ];
43
+
44
+    # Extra packages:
45
+    users.users.pjones.packages = with pkgs; [
46
+      # Desktop
47
+      arc-icon-theme
48
+      arc-theme
49
+      autorandr
50
+      bspwm
51
+      calibre
52
+      glabels
53
+      gwenview
54
+      hicolor_icon_theme
55
+      kdeApplications.krdc
56
+      kdeconnect
57
+      libnotify
58
+      libreoffice
59
+      pamixer
60
+      pavucontrol
61
+      plasma5.user-manager
62
+      playbar2
63
+      qt5.qttools
64
+      rofi
65
+      rofi-pass
66
+      sxhkd
67
+      x11vnc
68
+      xdo
69
+      xdotool
70
+      xorg.xev
71
+      xorg.xhost
72
+      xorg.xrandr
73
+      xorg.xset
74
+      xtitle
75
+      zathura
76
+
77
+      # System and Security
78
+      aspell
79
+      aspellDicts.en
80
+      dict
81
+      pass
82
+
83
+      # Network
84
+      chromium
85
+      firefox
86
+      youtube-dl
87
+
88
+      # Audio/Video
89
+      ffmpeg
90
+      moc
91
+      mpc_cli
92
+      mpg123
93
+      ncmpcpp
94
+      spotify
95
+      vlc
96
+
97
+      # Creative
98
+      darktable
99
+      geda
100
+      gimp
101
+      imagemagick
102
+      inkscape
103
+      librecad
104
+      ngspice
105
+      openscad
106
+      pdftk
107
+      qgis
108
+      qmapshack
109
+      slic3r
110
+      xournal
111
+
112
+      # Development
113
+      haskellPackages.hlint
114
+      libxml2
115
+      libxslt
116
+      mr
117
+      nodePackages.eslint
118
+      nodejs-slim-8_x
119
+      shellcheck
120
+
121
+    ] ++ [
122
+      # My packages
123
+      encryption-utils
124
+      emacsrc
125
+    ];
126
+
127
+    # NixOS services:
128
+    services.autorandr.enable = true;
129
+    services.dbus.enable = true;
130
+
131
+    # Home Manager:
132
+    home-manager.users.pjones = { ... }: {
133
+      # Files in ~pjones:
134
+      home.file.".emacs".source = "${emacsrc}/dot.emacs.el";
135
+      xdg.configFile."autorandr/postswitch".source = "${autorandr-postswitch}";
136
+
137
+      # Services:
138
+      xsession = {
139
+        enable = true;
140
+        windowManager.command = startkde;
141
+
142
+        # Run before the window manager:
143
+        initExtra = ''
144
+          ${xdg-set-up}
145
+          export KDEWM=${pkgs.bspwm}/bin/bspwm
146
+        '';
147
+      };
148
+
149
+      # Hide the mouse.
150
+      services.unclutter.enable = true;
151
+
152
+      # Cache passphrases and keys:
153
+      services.gpg-agent = {
154
+        enable = true;
155
+        enableSshSupport = true;
156
+        defaultCacheTtl = 3600;
157
+        defaultCacheTtlSsh = 14400;
158
+        maxCacheTtl = 7200;
159
+        maxCacheTtlSsh = 21600;
160
+      };
161
+
162
+      # Make things pretty:
163
+      services.compton = {
164
+        enable = true;
165
+
166
+        fade = true;
167
+        fadeExclude = [
168
+          "window_type *= 'menu'"
169
+        ];
170
+
171
+        inactiveOpacity = "0.85";
172
+        opacityRule = [
173
+          "20:class_i *= 'presel_feedback'"
174
+          "100:class_g = 'rofi'" # Why doesn't this work?
175
+        ];
176
+
177
+        extraOptions = ''
178
+          unredir-if-possible = true;
179
+          use-ewmh-active-win = true;
180
+        '';
181
+      };
182
+    };
183
+  };
184
+}

+ 11
- 0
pkgs/default.nix View File

@@ -0,0 +1,11 @@
1
+# Return Peter's Package Collection:
2
+{ pkgs }:
3
+
4
+with pkgs.lib;
5
+
6
+let
7
+  attrs = removeAttrs (importJSON ./pkgs.json) [ "date"];
8
+  repo  = pkgs.fetchgit attrs;
9
+  boot  = import "${repo}/default.nix" { inherit pkgs; };
10
+
11
+in boot.pjones

+ 7
- 0
pkgs/pkgs.json View File

@@ -0,0 +1,7 @@
1
+{
2
+  "url": "git://git.devalot.com/pkgs.git",
3
+  "rev": "fb0984943afaf6f686fb2d5807f451f8d4888f38",
4
+  "date": "2019-02-10T19:41:11-07:00",
5
+  "sha256": "1pxbwp9yjx0775mrg3n3980j0ng434vg6ab81393qhyxpmba7hwn",
6
+  "fetchSubmodules": false
7
+}

+ 30
- 0
support/workstation/xdg.sh View File

@@ -0,0 +1,30 @@
1
+#!/bin/sh
2
+
3
+################################################################################
4
+PATH=/run/current-system/sw/bin:$PATH
5
+
6
+################################################################################
7
+# XDG variables.
8
+export XDG_CONFIG_HOME=$HOME/.config
9
+export XDG_DESKTOP_DIR=$HOME/desktop
10
+export XDG_DOWNLOAD_DIR=$HOME/download
11
+export XDG_DOCUMENTS_DIR=$HOME/documents
12
+export XDG_MUSIC_DIR=$HOME/documents/music
13
+export XDG_PICTURES_DIR=$HOME/documents/pictures
14
+export XDG_PUBLICSHARE_DIR=$HOME/htdocs
15
+export XDG_TEMPLATES_DIR=$HOME/documents/templates
16
+export XDG_VIDEOS_DIR=$HOME/documents/videos
17
+
18
+################################################################################
19
+# Write them out to a file:
20
+cat <<EOF > ~/.config/user-dirs.dirs
21
+XDG_CONFIG_HOME="$XDG_CONFIG_HOME"
22
+XDG_DESKTOP_DIR="$XDG_DESKTOP_DIR"
23
+XDG_DOWNLOAD_DIR="$XDG_DOWNLOAD_DIR"
24
+XDG_DOCUMENTS_DIR="$XDG_DOCUMENTS_DIR"
25
+XDG_MUSIC_DIR="$XDG_MUSIC_DIR"
26
+XDG_PICTURES_DIR="$XDG_PICTURES_DIR"
27
+XDG_PUBLICSHARE_DIR="$XDG_PUBLICSHARE_DIR"
28
+XDG_TEMPLATES_DIR="$XDG_TEMPLATES_DIR"
29
+XDG_VIDEOS_DIR="$XDG_VIDEOS_DIR"
30
+EOF

Loading…
Cancel
Save