Works on Darwin

This commit is contained in:
greg-compass
2022-09-07 20:01:51 -05:00
parent 16e54a97b4
commit 4a86e70de4
33 changed files with 123 additions and 110 deletions
-10
View File
@@ -1,10 +0,0 @@
{ ... }:
{
imports = [
./automatic/nix.nix
./automatic/programs.nix
./automatic/syncthing.nix
# Users imported only for Linux machines
];
}
-22
View File
@@ -1,22 +0,0 @@
{ pkgs, ... }:
{
# Enable flakes
nix = {
package = pkgs.nixFlakes;
autoOptimiseStore = true;
# Keep freespace available, at a minimum, and enable Flakes
extraOptions = ''
experimental-features = nix-command flakes
min-free = ${toString (1024 * 1024 * 1024) }
max-free = ${toString (5 * 1024 * 1024 * 1024) }
# Used by direnv
keep-outputs = true
keep-derivations = true
'';
};
nixpkgs.config.allowUnfree = true;
}
-30
View File
@@ -1,30 +0,0 @@
{ pkgs, agenix, ... }:
let
myPackages = pypackages: with pypackages; [
pkgs.xonsh-direnv
];
myPython = pkgs.python3.withPackages myPackages;
in {
# Base packages that need to be in all my hosts
environment.systemPackages = with pkgs; [
agenix.defaultPackage."${system}"
bitwarden-cli
diffutils
git
gnupatch
findutils
hms # My own home manager switcher
home-manager
htop
myPython
pwgen
tmux
transcrypt
unzip
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
wget
yamllint # Used in vim
];
}
-46
View File
@@ -1,46 +0,0 @@
{ ... }:
let
syncs = [
"nas"
"dns"
"linode"
];
in
{
services.syncthing = {
enable = true;
user = "greg";
group = "users";
dataDir = "/home/greg/sync";
devices = {
nas = {
addresses = [
"tcp://nas.thehellings.lan:22000"
"tcp://chronicles.greg-hellings.gmail.com.beta.tailscale.net:22000"
];
id = "74JUTZG-77EPGO3-FEYCL2P-CHDWP5G-6EXWZVB-XTAH6O5-TUXCVY2-QNRHSQ4";
};
dns = {
addresses = [
"tcp://dns.thehellings.lan:22000"
"tcp://2maccabees.greg-hellings.gmail.com.beta.tailscale.net:22000"
];
id = "C4XJCH7-3ZNW6XZ-R5DB2EU-OEGVVT2-WPHQAG7-UDWER36-6NO5KZR-4MN5VAK";
};
linode = {
addresses = [
"tcp://linode.thehellings.com:22000"
];
id = "ROZPUG5-G4IAXYA-JNRQXRD-5PFU2BQ-WVJTOGZ-DFMGJ5E-Q4IGXCJ-JHSNDQ6";
};
};
folders = {
"mkrvy-tc6x9" = {
path = "/home/greg/drive";
enable = true;
devices = syncs;
};
};
};
}
-28
View File
@@ -1,28 +0,0 @@
# Only imported from the Linux modules
{ pkgs, ... }:
{
# Enable the OpenSSH daemon for remote control
services.openssh.enable = true;
#services.openssh.permitRootLogin = "yes";
# Define a user account. Don't forget to set a password with passwd.
users.users.greg = {
isNormalUser = true;
createHome = true;
extraGroups = [ "wheel" "networkmanager" ]; # Enable sudo for the user.
shell = pkgs.xonsh;
openssh.authorizedKeys.keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQDLQRq55JKqLifX+31kEXyuoB8gfM+5thAlgR7XLPvvdu6g2a5cCWyozQ1I2oGbPRfJtzcJ5ifM7Ii2PuqAj3MdYFLHBEDOhIpBBWme9Ts2YB9HJ4NorBvB4zEfJd0Q7k2MmylyeBOwdwGz3bVqPRDcJbxWFMDHqr33FEs6SXdfyAQ5SvhWGARI84qz8zUUdOp6M4e3aIGO3cx1gA+YzYQ4FbUtL8+m1NFO8VoNFMZBMf5q0iF/SgEu5bmGWUCePia6DvfeBFQ2/y4Y7WmOj980WE+JmFTkIvmGruMYeGI8FuDQ2JIIIcehddy9bQbPF4VlGnTFsHqJYVRUUWc+vH1cPNMn01oB8s27ogf9e1lyhIN+cZOgp/jDt4eXcO4Wr04uwj7CI6m+d8iMQOa5Jv0hmNgqqiwOMVBlKeo0FCxlovzwvn/Lia9WZ74JqM6JwLCD8SZ0oFgiSIHOTHrQhr7iaCmj7X/0ey7VR8FnCrpeAJpG+ELTfWGshF1d9QR2zW7u4EsXTDLiuOmdJ+/KxwMvjMcWdlg2+Qch6SwulTQRxWaED2IWJo+YiAql8eaiVXu/eZJGLoiskG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g97CoPKkoWoGk+P13BCWWXR9GCa2PbJ9uprzPa6Ib4+i9RJPdeSkUiLlFi6rBTHaZUT9WUIEaqNSq3bbu1bIqMXkifPeDw7m+TMfOBT8MUBciJaPlPTgXuz3T4kCHBI041hIt+/VqryGtxnT45IavyUaN3JWYntDbpG3eEW4N9IB2oGWuC/XuTJrsUaNpLPpApUKuozxhsFELBRepU+j+Wn4kgJJl8hy0n+WL63ZUee+/F23C7UNXoOc/wU3KbpxO6ipsTSkTzhZpQF2LOuA3JUs5t9ZaiCJ2P9r8axHiphCRcIYSbcCo3pZupf1eTDSXm+x9/UB2sfzErNEH4SdakoSdAi8jG8WhPVOs3BrIXjVBjvyBLeOH86EzBGR/Ba8X6MWoEW9Oau1C3P/z65VH8RHpvPvp6axlMynyVI1ygt5uheuQ== gregory.hellings@C02G48H8MD6R"
];
};
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
}
-107
View File
@@ -1,107 +0,0 @@
{ lib, config, pkgs, ... }:
let
cfg = config.greg.backup;
backup_key = "backup_keys/id_ed25519";
makeJob = name: job: {
paths = job.src;
encryption.mode = "none";
environment.BORG_RSH = "ssh -i /etc/${backup_key} -o 'StrictHostKeyChecking=no' -o 'UserKnownHostsFile=/dev/null'";
repo = "ssh://backup@nas.me.ts//volume1/NetBackup/${job.dest}";
compression = "auto,zstd";
startAt = "daily";
user = job.user;
group = job.group;
preHook = job.pre;
postHook = job.post;
};
cronJob = name: job:
let
binName = "backup-${name}";
script = pkgs.writeShellScriptBin binName ''
exec 1> >(systemd-cat -t $(basename $0)) 2>&1
set -ex
${job.pre}
${pkgs.rsync}/bin/rsync -avz --delete -e "${pkgs.openssh}/bin/ssh -i /etc/${backup_key} -o 'StrictHostKeyChecking=no' -o 'UserKnownHostsFile=/dev/null'" ${job.src}/* backup@nas.me.ts:/volume1/NetBackup/${job.dest}/
${job.post}
'';
in {
inherit script;
cron = "0 1 * * * ${job.user} ${script}/bin/${binName}";
};
in with lib; {
options = {
greg.backup = {
key = mkOption {
type = types.path;
description = "SSH key to use";
default = ./ssh/id_ed25519;
};
jobs = mkOption {
default = {};
type = with types; attrsOf (submodule (
{ name, config, options, ... }:
{
options = {
src = mkOption {
type = types.str;
description = "Local path (string form) to backup from";
};
dest = mkOption {
type = types.str;
};
user = mkOption {
type = types.str;
default = "root";
description = "User to run backup as";
};
pre = mkOption {
type = types.str;
default = "";
description = "Commands to run before backup";
};
post = mkOption {
type = types.str;
default = "";
description = "Commands to run after backup";
};
};
}
));
};
};
};
config = let
jobs = attrValues ( mapAttrs cronJob cfg.jobs );
in mkIf ( ( attrValues cfg.jobs ) != [] )
{
#services.borgbackup = {
# jobs = mapAttrs makeJob cfg.jobs;
#};
services.cron = {
enable = true;
systemCronJobs = map (e: e.cron) jobs;
};
environment.etc = mkIf ( cfg.key != null ) {
"${backup_key}" = {
user = "nobody";
mode = "0777";
source = cfg.key;
};
};
environment.systemPackages = map (e: e.script) jobs;
};
}
-18
View File
@@ -1,18 +0,0 @@
{ config, lib, ... }:
let
cfg = config.greg.darwin;
in with lib; {
options = {
greg.darwin = mkEnableOption "This system is Darwin";
};
config = mkIf cfg {
system.stateVersion = 4;
programs = {
zsh.enable = true;
bash.enable = true;
};
};
}
-17
View File
@@ -1,17 +0,0 @@
{ ... }:
{
imports = [
./automatic.nix
./backup.nix
./darwin.nix
./home.nix
./gnome.nix
./linode.nix
./linux.nix
./proxy.nix
./rpi4.nix
./tailscale.nix
./xprograms.nix
];
}
-57
View File
@@ -1,57 +0,0 @@
{ config, pkgs, lib, ... }:
let
cfg = config.greg.gnome;
in with lib; {
options = {
greg.gnome.enable = mkEnableOption "Enable my default Gnome3 setup";
};
config = mkIf cfg.enable {
greg.xprograms.enable = true;
# Sets up a basic Gnome installation
services = {
xserver = {
enable = true;
displayManager.gdm.enable = true;
desktopManager.gnome.enable = true;
layout = "us";
# Trackpad support
libinput.enable = true;
};
udev.packages = with pkgs; [
gnome3.gnome-settings-daemon
];
pipewire.enable = true;
# Enablement for Firefox
gnome = {
chrome-gnome-shell.enable = true;
sushi.enable = true;
gnome-online-accounts.enable = true;
};
};
programs.dconf.enable = true;
programs.sway.enable = true; # Gives us Wayland
xdg.portal = {
enable = true;
gtkUsePortal = true;
wlr.enable = true; # Enables screen sharing in Wayland
};
# Enable some Gnome plugins that I like
environment.systemPackages = with pkgs; [
gnome3.adwaita-icon-theme
gnome3.gnome-tweaks
gnome3.dconf-editor
gnomeExtensions.appindicator
gnomeExtensions.clipboard-indicator
gnomeExtensions.dash-to-dock
];
};
}
-18
View File
@@ -1,18 +0,0 @@
{ config, lib, ... }:
let
cfg = config.greg.home;
in with lib;
{
options.greg.home = mkOption {
type = types.bool;
default = true;
description = "Sets the device up to be part of my home network";
};
config = mkIf cfg {
time.timeZone = "America/Chicago";
networking.domain = "thehellings.lan";
};
}
-44
View File
@@ -1,44 +0,0 @@
{ config, lib, pkgs, ... }:
let
cfg = config.greg.linode;
in with lib;
{
options.greg.linode = {
enable = mkEnableOption "Set sensible defaults for a Linode host";
bootTimeout = mkOption {
type = types.int;
default = 15;
description = "Set bootloader timeout in seconds.";
};
};
config = mkIf cfg.enable {
# Enables connection over Linode consoles
boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.loader.grub = {
device = "nodev";
extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1;
terminal_input serial;
terminal_output serial;
'';
};
# Tells grub to ignore partion-free device warnings, since we are on Linode
boot.loader.timeout = 15;
networking.usePredictableInterfaceNames = false; # Use old style eth0 names
networking.useDHCP = false;
networking.interfaces.eth0.useDHCP = true;
# Suggested diagnostic tools
environment.systemPackages = with pkgs; [
inetutils
mtr
sysstat
];
};
}
-19
View File
@@ -1,19 +0,0 @@
{ config, lib, ... }:
let
cfg = config.greg.linux;
in with lib; {
options.greg.linux = mkEnableOption "This system is Linux";
config = mkIf cfg {
imports = [
./automatic/users.nix
];
system.stateVersion = "22.05";
# I am a fan of network manager, myself
networking.networkmanager.enable = true;
};
}
-81
View File
@@ -1,81 +0,0 @@
{ config, lib, pkgs, ... }:
let
cfg = config.greg.proxies;
alias = name: with builtins; head (split "\\." name);
makeHost = name: dest: {
forceSSL = dest.ssl;
enableACME = dest.ssl;
locations."${dest.path}" = {
proxyPass = dest.target;
extraConfig = ''
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
'';
};
serverAliases = lib.mkIf dest.genAliases [ "${alias name}" ];
};
in with lib; {
options = {
greg.proxies = mkOption {
default = {};
example = literalExpression ''
{ host-name = {
target = proxyLocation;
ssl = true;
};
'';
description = ''
Quick and simple Nginx proxy configurations.
Use this to configure a very simple proxy that does not
need any extra customization options other than SSL
enablement.
'';
type = with types; attrsOf (submodule (
{ name, config, options, ... }:
{
options = {
genAliases = mkOption {
type = types.bool;
description = "Whether to auto-generate short alias name";
default = true;
};
target = mkOption {
type = types.str;
description = ''The destination that is being proxied.'';
example = "http://localhost:8080";
};
ssl = mkOption {
type = types.bool;
description = "Whether to enable SSL in front of the proxy";
default = false;
};
path = mkOption {
type = types.str;
description = "The path prefix for this proxy";
default = "/";
};
};
}));
};
};
config.services.nginx = mkIf ( ( attrValues cfg ) != [] ) {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts = mapAttrs makeHost cfg;
};
}
-43
View File
@@ -1,43 +0,0 @@
{ config, lib, pkgs, ... }:
let
cfg = config.greg.rpi4;
in with lib; {
options = {
greg.rpi4 = {
enable = mkEnableOption "Enable support for Raspberry Pi 4s";
};
};
config = mkIf cfg.enable {
boot = {
# This prevents us from having to compile our own kernel
kernelPackages = pkgs.linuxPackages_rpi4;
kernelParams = [
"8250.nr_uarts=1"
"console=ttyAMA0,115200"
"console=tty1"
"cma=128M"
];
loader = {
raspberryPi = {
enable = true;
version = 4;
};
# Use the extlinux boot loader. (NixOS wants to enable GRUB by default)
grub.enable = false;
# Enables the generation of /boot/extlinux/extlinux.conf
#generic-extlinux-compatible.enable = true;
};
};
environment.systemPackages = with pkgs; [
raspberrypifw
usbutils
];
};
}
-9
View File
@@ -1,9 +0,0 @@
U2FsdGVkX1+8TBMzBYN9YHgBu1txsCXL0bCxLaGsDMoAaMdkBEdFI1owuEIpM5/E
wJICFzAcEmdFMpX0ZZn4c/jIA7K3Q+p1uxaj+7zcdmzRs08ZxU64yG7LTM47cffJ
W2L1OOFvJPICOs5WmwC/R+4FG6LBIa09W58Xn3OkUEFTe2L2iK73J0ecXuWYjEhN
2y9UvtXr1dHJdXSVY0i7DoPb22JUGuWRRWnT1ThW83xDMs6d83PLD26/BIS/HJiJ
24d0HXuO3nXkkdPX6ocRJmAM0PeMtW+uPG4/HjS6xWaJThBljfvC0I1NRWK7SYR8
+Ret+OXlYhQmSN0M8cGixQKxlrn4iUpawpRnTsug3aSe0Nx30eTw/aRt6WkyeWLS
g/aEnOiaIFSyg780nq5AENQW9/XgvWAb/i9k4AKwKBdyeaAveA/37xoM/6rWToXu
Cql9d4sAF9mEZjSIjXulMQakZHep59MiNclK1WJQQHjQh1DabXS6CEjVD+jJOG9R
cpTkdJ1/Q711jJR7hZK7SNNoo8EH3Vpl5czpJjp+zJE=
-3
View File
@@ -1,3 +0,0 @@
U2FsdGVkX199UgWOiZI4QFCTOsVVEQatJHJFBVDmavrKzuGL+2RX1Fsi1uEafGpz
Fa6UGCWVrUvaT69yxpt3PBtSjkFiZtR9g1A0LzWT3XaUB41/0DJIzAsbK62Ya9UT
A+xICWdf2WVk6n0xeNIvPQ==
-14
View File
@@ -1,14 +0,0 @@
{ lib, config, ... }:
let
cfg = config.greg.tailscale;
in {
options = {
greg.tailscale.enable = lib.mkEnableOption "Enable Tailscale";
};
config = lib.mkIf cfg.enable {
services.tailscale.enable = true;
networking.firewall.checkReversePath = "loose";
};
}
-16
View File
@@ -1,16 +0,0 @@
{ config, lib, pkgs, ... }:
let
cfg = config.greg.xprograms;
in with lib; {
options = {
greg.xprograms.enable = mkEnableOption "Install my favorite XPrograms";
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
keepassxc
];
};
}