Browse Source

Initial import

master
Peter J. Jones 6 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 @@
Copyright (c) 2019 Peter J. Jones <pjones@devalot.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the
distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 10
- 0
README.md View File

@@ -0,0 +1,10 @@
Peter's Account
===============

Want to create an account for me on a NixOS machine? Thanks!

Just add the `default.nix` file to one of your `imports`.

The only requirement is that you have [home-manager][] included as well.

[home-manager]: https://github.com/rycee/home-manager

+ 7
- 0
default.nix View File

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

{
imports = [
./nixos
];
}

+ 81
- 0
nixos/default.nix View File

@@ -0,0 +1,81 @@
# User entry for pjones.
{ config, pkgs, lib, ... }:

with lib;

let
sshPubKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOT7Ys7LyugF3A5wsJ1EH1CF9jAdihtSWrJskUtDACCR medusa"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG1g7KoenMd6JIWnIuOQOYAaPNk6rF+6vwXBqNic2Juk elphaba"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJKW//sdBipEzLP85H89J1a8ma4J5IRbhEL+3/jEDANk leota"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuiLy4mwlSXLn18H/8tTqCcfq0obMNkEQfU27AgJDdw slugworth"
];
in
{
#### Additional Files:
imports = [
./modules/shells.nix
./modules/wheel.nix
./modules/workstation.nix
];

#### Interface:
options.pjones = {
putInWheel = mkEnableOption "Allow access to the wheel group";
isWorkstation = mkEnableOption "The current machine is a workstation, not a server.";
};

#### Implementation:
config = {

# A group just for me:
users.groups.pjones = { };

# And my user account:
users.users.pjones = {
isNormalUser = true;
description = "Peter J. Jones";
group = "pjones";
createHome = true;
home = "/home/pjones";
shell = pkgs.zsh;
openssh.authorizedKeys.keys = sshPubKeys;

extraGroups = [
"docker"
"libvirtd"
"users"
"webhooks"
"webmaster"
];

# Base set of packages I want on all machines:
packages = with pkgs; [
(unison.override {enableX11 = false;})
bc
curl
gitAndTools.gitAnnex
gitAndTools.git
gnumake
gnupg
gnutls
inotifyTools
jq
lsscsi
mkpasswd
openssl
parted
pciutils
pwgen
rdiff-backup
rsync
tmux
tree
unzip
usbutils
wget
zip
];
};
};
}

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

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

with lib;

let
cfg = config.pjones;

configFile = pkgs.writeText "mbsync-cfg" ''
IMAPAccount devalot
Host mail.pmade.com
User pjones
PassCmd "${pkgs.pass}/bin/pass show machines/mail.pmade.com/pjones"
SSLType IMAPS
SSLVersions TLSv1.2
CertificateFile /etc/ssl/certs/ca-certificates.crt

IMAPStore devalot-remote
Account devalot

MaildirStore devalot-local
Path ~/mail/devalot/
Inbox ~/mail/devalot/Inbox
SubFolders Verbatim

Channel devalot
Master :devalot-remote:
Slave :devalot-local:
Expunge both
Create Both
Remove Both
SyncState *
Patterns *

IMAPAccount rfa
Host outlook.office365.com
User peter.jones@rfa.sc.gov
PassCmd "${pkgs.pass}/bin/pass show business/clients/south-carolina/outlook.com"
SSLType IMAPS
SSLVersions TLSv1.2
CertificateFile /etc/ssl/certs/ca-certificates.crt
PipelineDepth 1

IMAPStore rfa-remote
Account rfa

MaildirStore rfa-local
Path ~/mail/rfa/
Inbox ~/mail/rfa/Inbox
SubFolders Verbatim

Channel rfa
Master :rfa-remote:
Slave :rfa-local:
Expunge both
Create Both
Remove Both
SyncState *
Patterns INBOX Archive "Deleted Items" Drafts "Sent Items"
'';

script = pkgs.writeShellScriptBin "mbsync-pjones" ''
# Make sure some directories exist:
mkdir -p ~/mail/devalot
mkdir -p ~/mail/rfa

# Do the mail sync:
mbsync --all

# Keep mu from indexing my SPAM folder:
touch ~/mail/devalot/Junk/.noindex
'';
in
{
#### Implementation:
config = mkIf cfg.isWorkstation {
users.users.pjones.packages = with pkgs; [
isync
mu
] ++ [ script ];

home-manager.users.pjones = { ... }: {
home.file.".mbsyncrc".source = "${configFile}";
};
};
}

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

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

with lib;

let
base = import ../../pkgs { inherit pkgs; };

bashrc = base.bashrc;
zshrc = base.zshrc;
tmuxrc = base.tmuxrc;

in
{
programs.zsh = {
enable = true;
enableCompletion = true;
syntaxHighlighting.enable = true;
};

home-manager.users.pjones.home.file = {

# Bash
".bashrc".source = "${bashrc}/share/bashrc";
".bash_profile".source = "${bashrc}/share/bash_profile";
".inputrc".source = "${bashrc}/share/inputrc";

# ZSH:
".zshrc".source = "${zshrc}/share/zshrc/zshrc";
".zshenv".source = "${zshrc}/share/zshrc/zshenv";
".zsh".source = "${zshrc}/share/zshrc/zsh";

# tmux: (sort of like a shell :)
".tmux.conf".source = "${tmuxrc}/config/tmux.conf";

};
}

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

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

with lib;

let
cfg = config.pjones;

in
{
config = mkIf cfg.putInWheel {
users.users.pjones.extraGroups = [
"wheel"
];
};
}

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

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

with lib;

let
cfg = config.pjones;
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);

# Reuse the startkde script from NixOS:
xsessions = config.services.xserver.desktopManager.session.list;
startkde = (head (filter (d: d.name == "plasma5") xsessions)).start;
in
{
# Additional files:
imports = [
./mail.nix
];

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

# Extra groups needed on a workstation:
users.users.pjones.extraGroups = [
"cdrom"
"dialout"
"disk"
"networkmanager"
"scanner"
];

# 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
xdo
xdotool
xorg.xev
xorg.xhost
xorg.xrandr
xorg.xset
xtitle
zathura

# System and Security
aspell
aspellDicts.en
dict
pass

# Network
chromium
firefox
youtube-dl

# Audio/Video
ffmpeg
moc
mpc_cli
mpg123
ncmpcpp
spotify
vlc

# Creative
darktable
geda
gimp
imagemagick
inkscape
librecad
ngspice
openscad
pdftk
qgis
qmapshack
slic3r
xournal

# Development
haskellPackages.hlint
libxml2
libxslt
mr
nodePackages.eslint
nodejs-slim-8_x
shellcheck

] ++ [
# My packages
encryption-utils
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 = {
enable = true;
windowManager.command = startkde;

# Run before the window manager:
initExtra = ''
${xdg-set-up}
export KDEWM=${pkgs.bspwm}/bin/bspwm
'';
};

# Hide the mouse.
services.unclutter.enable = true;

# Cache passphrases and keys:
services.gpg-agent = {
enable = true;
enableSshSupport = true;
defaultCacheTtl = 3600;
defaultCacheTtlSsh = 14400;
maxCacheTtl = 7200;
maxCacheTtlSsh = 21600;
};

# Make things pretty:
services.compton = {
enable = true;

fade = true;
fadeExclude = [
"window_type *= 'menu'"
];

inactiveOpacity = "0.85";
opacityRule = [
"20:class_i *= 'presel_feedback'"
"100:class_g = 'rofi'" # Why doesn't this work?
];

extraOptions = ''
unredir-if-possible = true;
use-ewmh-active-win = true;
'';
};
};
};
}

+ 11
- 0
pkgs/default.nix View File

@@ -0,0 +1,11 @@
# Return Peter's Package Collection:
{ pkgs }:

with pkgs.lib;

let
attrs = removeAttrs (importJSON ./pkgs.json) [ "date"];
repo = pkgs.fetchgit attrs;
boot = import "${repo}/default.nix" { inherit pkgs; };

in boot.pjones

+ 7
- 0
pkgs/pkgs.json View File

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

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

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

################################################################################
PATH=/run/current-system/sw/bin:$PATH

################################################################################
# XDG variables.
export XDG_CONFIG_HOME=$HOME/.config
export XDG_DESKTOP_DIR=$HOME/desktop
export XDG_DOWNLOAD_DIR=$HOME/download
export XDG_DOCUMENTS_DIR=$HOME/documents
export XDG_MUSIC_DIR=$HOME/documents/music
export XDG_PICTURES_DIR=$HOME/documents/pictures
export XDG_PUBLICSHARE_DIR=$HOME/htdocs
export XDG_TEMPLATES_DIR=$HOME/documents/templates
export XDG_VIDEOS_DIR=$HOME/documents/videos

################################################################################
# Write them out to a file:
cat <<EOF > ~/.config/user-dirs.dirs
XDG_CONFIG_HOME="$XDG_CONFIG_HOME"
XDG_DESKTOP_DIR="$XDG_DESKTOP_DIR"
XDG_DOWNLOAD_DIR="$XDG_DOWNLOAD_DIR"
XDG_DOCUMENTS_DIR="$XDG_DOCUMENTS_DIR"
XDG_MUSIC_DIR="$XDG_MUSIC_DIR"
XDG_PICTURES_DIR="$XDG_PICTURES_DIR"
XDG_PUBLICSHARE_DIR="$XDG_PUBLICSHARE_DIR"
XDG_TEMPLATES_DIR="$XDG_TEMPLATES_DIR"
XDG_VIDEOS_DIR="$XDG_VIDEOS_DIR"
EOF

Loading…
Cancel
Save