From fecf8d6b411f244ed78936a77aad3a9649174b2b Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 29 Apr 2022 08:47:52 -0500 Subject: [PATCH 01/55] Automatic serverAliases --- hosts/2maccabees/dnsmasq.nix | 2 +- modules/proxy.nix | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hosts/2maccabees/dnsmasq.nix b/hosts/2maccabees/dnsmasq.nix index 000d958..4c84e8b 100644 --- a/hosts/2maccabees/dnsmasq.nix +++ b/hosts/2maccabees/dnsmasq.nix @@ -4,7 +4,7 @@ let extraHosts = builtins.concatStringsSep "\n" [ "10.42.0.1 switch" "10.42.1.1 router" - "10.42.1.2 dns smart" + "10.42.1.2 dns dns.thehellings.lan smart smart.thehellings.lan" "100.99.244.92 dns.me.ts" "10.42.1.3 printer" "10.42.1.4 chronicles nas" diff --git a/modules/proxy.nix b/modules/proxy.nix index c13247f..7e0768f 100644 --- a/modules/proxy.nix +++ b/modules/proxy.nix @@ -3,6 +3,8 @@ let cfg = config.greg.proxies; + alias = name: with builtins; head (split "\\." name); + makeHost = name: dest: { forceSSL = dest.ssl; enableACME = dest.ssl; @@ -14,6 +16,7 @@ proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; ''; }; + serverAliases = [ "${alias name}" ]; }; in with lib; { From 11a8eab86731957821a573146e3cdbc4983e47cc Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 27 Apr 2022 11:23:11 -0500 Subject: [PATCH 02/55] Basic Gnome install --- flake.nix | 2 ++ hosts/jude/boot.nix | 9 +++++++ hosts/jude/default.nix | 10 ++++++++ hosts/jude/hardware-configuration.nix | 24 ++++++++++++++++++ modules/default.nix | 1 + modules/gnome.nix | 36 +++++++++++++++++++++++++++ profiles/gnome.nix | 27 -------------------- 7 files changed, 82 insertions(+), 27 deletions(-) create mode 100644 hosts/jude/boot.nix create mode 100644 hosts/jude/default.nix create mode 100644 hosts/jude/hardware-configuration.nix create mode 100644 modules/gnome.nix delete mode 100644 profiles/gnome.nix diff --git a/flake.nix b/flake.nix index 05083f4..b5865b1 100644 --- a/flake.nix +++ b/flake.nix @@ -39,6 +39,8 @@ "linode" = machine "x86_64-linux" "linode"; + "jude" = machine "x86_64-linux" "jude"; + "iso" = machine "x86_64-linux" "iso"; }; diff --git a/hosts/jude/boot.nix b/hosts/jude/boot.nix new file mode 100644 index 0000000..65f8ae9 --- /dev/null +++ b/hosts/jude/boot.nix @@ -0,0 +1,9 @@ +{ ... }: + +{ + # Use the systemd-boot EFI boot loader. + #boot.loader.systemd-boot.enable = true; + boot.loader.grub.device = "/dev/nvme0n1"; + boot.loader.efi.canTouchEfiVariables = true; + networking.interfaces.enp4s0.useDHCP = true; +} diff --git a/hosts/jude/default.nix b/hosts/jude/default.nix new file mode 100644 index 0000000..ad1dbca --- /dev/null +++ b/hosts/jude/default.nix @@ -0,0 +1,10 @@ +{ ... }: + +{ + imports = [ + ./boot.nix + ./hardware-configuration.nix + ]; + networking.hostName = "jude"; + greg.gnome = true; +} diff --git a/hosts/jude/hardware-configuration.nix b/hosts/jude/hardware-configuration.nix new file mode 100644 index 0000000..8dbc6be --- /dev/null +++ b/hosts/jude/hardware-configuration.nix @@ -0,0 +1,24 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/27ae91ed-32e9-411e-8227-0d99e360fbbf"; + fsType = "btrfs"; + }; + + swapDevices = [ ]; + + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/modules/default.nix b/modules/default.nix index cddba76..27807ce 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -3,6 +3,7 @@ { imports = [ ./home.nix + ./gnome.nix ./linode.nix ./proxy.nix ./rpi4.nix diff --git a/modules/gnome.nix b/modules/gnome.nix new file mode 100644 index 0000000..a3b8575 --- /dev/null +++ b/modules/gnome.nix @@ -0,0 +1,36 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.greg.gnome; + +in with lib; { + options = { + greg.gnome = mkEnableOption "Enable my default Gnome3 setup"; + }; + + config = mkIf cfg { + # 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; + }; + + programs.dconf.enable = true; + programs.sway.enable = true; # Gives us Wayland + xdg.portal.wlr.enable = true; # Allows screen sharing in Wayland + + # Enable some Gnome plugins that I like + environment.systemPackages = with pkgs; [ + gnome3.adwaita-icon-theme + gnomeExtensions.appindicator + ]; + + services.udev.packages = with pkgs; [ + gnome3.gnome-settings-daemon + ]; + }; +} diff --git a/profiles/gnome.nix b/profiles/gnome.nix deleted file mode 100644 index d2fc077..0000000 --- a/profiles/gnome.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ config, pkgs, ... }: - -{ - # Sets up a basic Gnome installation - services.xserver = { - enable = true; - displayManager = { - gdm.enable = true; - gnome.enable = true; - }; - layout = "us"; - # Trackpad support - libinput.enable = true; - }; - - programs.dconf.enable = true; - - # Enable some Gnome plugins that I like - environment.systemPackages = with pkgs; [ - gnome3.adwaita-icon-theme - gnomeExtensions.appindicator - ]; - - services.udev.packages = with pkgs; [ - gnome3.gnome-settings-daemon - ]; -} From 1c19e5300d808ab50afd742826842a70366d982c Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 29 Apr 2022 10:58:31 -0500 Subject: [PATCH 03/55] Vast improvements to desktop experience --- flake.lock | 35 +++++++++- flake.nix | 6 ++ home/gui/chat.nix | 5 ++ home/gui/default.nix | 9 +++ home/gui/firefox.nix | 36 +++++++++++ home/gui/terminal.nix | 13 ++++ home/home.nix | 15 +++-- home/modules/default.nix | 7 ++ home/modules/xonsh.nix | 96 ++++++++++++++++++++++++++++ home/vim.nix | 6 +- home/xonsh.nix | 117 ++++++++++++++++++++++++++++++++++ hosts/jude/default.nix | 2 +- modules/default.nix | 1 + modules/gnome.nix | 18 +++++- modules/xprograms.nix | 16 +++++ profiles/base/default.nix | 1 - profiles/base/programs.nix | 1 - profiles/base/xonsh.nix | 127 ------------------------------------- 18 files changed, 370 insertions(+), 141 deletions(-) create mode 100644 home/gui/chat.nix create mode 100644 home/gui/default.nix create mode 100644 home/gui/firefox.nix create mode 100644 home/gui/terminal.nix create mode 100644 home/modules/default.nix create mode 100644 home/modules/xonsh.nix create mode 100644 home/xonsh.nix create mode 100644 modules/xprograms.nix delete mode 100644 profiles/base/xonsh.nix diff --git a/flake.lock b/flake.lock index 73255af..1dab8b7 100644 --- a/flake.lock +++ b/flake.lock @@ -71,11 +71,44 @@ "type": "github" } }, + "nixunstable": { + "locked": { + "lastModified": 1651007983, + "narHash": "sha256-GNay7yDPtLcRcKCNHldug85AhAvBpTtPEJWSSDYBw8U=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e10da1c7f542515b609f8dfbcf788f3d85b14936", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nur": { + "locked": { + "lastModified": 1651053120, + "narHash": "sha256-PKbB7MK6jwG4G3A/2RR0ZA8YSNanwi5R+Bvv/LwzKwo=", + "owner": "nix-community", + "repo": "NUR", + "rev": "2eb8999947487d915d6a1100d672284a1989c905", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "NUR", + "type": "github" + } + }, "root": { "inputs": { "agenix": "agenix", "home-manager": "home-manager", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_2", + "nixunstable": "nixunstable", + "nur": "nur" } } }, diff --git a/flake.nix b/flake.nix index b5865b1..a37468f 100644 --- a/flake.nix +++ b/flake.nix @@ -6,16 +6,19 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11"; + nixunstable.url = "github:nixos/nixpkgs/nixos-unstable"; agenix.url = "github:ryantm/agenix"; home-manager = { url = "github:nix-community/home-manager/release-21.11"; inputs.nixpkgs.follows = "nixpkgs"; }; + nur.url = "github:nix-community/NUR"; }; outputs = inputs: let mods = hostname: [ + { nixpkgs.overlays = [ inputs.nur.overlay ]; } inputs.agenix.nixosModule ./modules ./profiles/base @@ -24,6 +27,9 @@ home-manager.useGlobalPkgs = true; home-manager.users.greg = import ./home/home.nix "greg"; home-manager.users.root = import ./home/home.nix "root"; + home-manager.extraSpecialArgs = { + nixunstable = inputs.nixunstable; + }; } ]; diff --git a/home/gui/chat.nix b/home/gui/chat.nix new file mode 100644 index 0000000..9f67c39 --- /dev/null +++ b/home/gui/chat.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: + +{ + home.packages = [ pkgs.element-desktop ]; +} diff --git a/home/gui/default.nix b/home/gui/default.nix new file mode 100644 index 0000000..5cffb04 --- /dev/null +++ b/home/gui/default.nix @@ -0,0 +1,9 @@ +{ ... }: + +{ + imports = [ + ./chat.nix + ./firefox.nix + ./terminal.nix + ]; +} diff --git a/home/gui/firefox.nix b/home/gui/firefox.nix new file mode 100644 index 0000000..a79cfd5 --- /dev/null +++ b/home/gui/firefox.nix @@ -0,0 +1,36 @@ +{ lib, pkgs, ... }: + +let + ffPkgs = wayland: if wayland + then [ pkgs.firefox-wayland ] + else [ pkgs.firefox ]; + + vars = { + MOZ_ENABLE_WAYLAND = "1"; + XDG_CURRENT_DESKTOP = "sway"; + }; +in with lib; +{ + programs.firefox = { + enable = true; + enableGnomeExtensions = true; + extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + keepassxc-browser + octotree + refined-github + ublock-origin + ]; + profiles = { + default.settings = { + "browser.startup.page" = 3; + "browser.startup.homepage" = "https://thehellings.com"; + "doh-rollout.doorhanger-decision" = "UIDisabled"; + "doh-rollout.doneFirstRun" = true; + }; + }; + }; + + programs.bash.sessionVariables = vars; + + programs.xonsh.sessionVariables = vars; +} diff --git a/home/gui/terminal.nix b/home/gui/terminal.nix new file mode 100644 index 0000000..7d90605 --- /dev/null +++ b/home/gui/terminal.nix @@ -0,0 +1,13 @@ +{ ... }: + +{ + programs.gnome-terminal = { + enable = true; + showMenubar = true; + themeVariant = "dark"; + profile.default = { + default = true; + visibleName = "greg"; + }; + }; +} diff --git a/home/home.nix b/home/home.nix index f197fa4..197350e 100644 --- a/home/home.nix +++ b/home/home.nix @@ -1,12 +1,19 @@ -name: { pkgs, lib, ...}: +name: { pkgs, lib, nixosConfig, ...}: -{ +let + guiImports = if nixosConfig.greg.gnome.enable then + [ ./gui ] else []; + +in { imports = [ + ./modules ./bash.nix ./git.nix - ./vim.nix ./ssh.nix - ]; + ./vim.nix + ./xonsh.nix + ] ++ guiImports; + home.username = name; home.homeDirectory = if name == "root" then "/root" else "/home/${name}"; diff --git a/home/modules/default.nix b/home/modules/default.nix new file mode 100644 index 0000000..3357dd9 --- /dev/null +++ b/home/modules/default.nix @@ -0,0 +1,7 @@ +{ ... }: + +{ + imports = [ + ./xonsh.nix + ]; +} diff --git a/home/modules/xonsh.nix b/home/modules/xonsh.nix new file mode 100644 index 0000000..348612c --- /dev/null +++ b/home/modules/xonsh.nix @@ -0,0 +1,96 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.programs.xonsh; + +in with lib; { + options = { + programs.xonsh = { + enable = mkEnableOption "Enable the xonsh program"; + + sessionVariables = mkOption { + type = types.attrs; + default = {}; + example = { XONSH_TRACE_SUBPROC = true; }; + description = '' + Environment variables that will be set for the Xonsh session. + ''; + }; + + aliases = mkOption { + type = types.attrsOf types.str; + default = {}; + example = literalExpression '' + { + ll = "ls -l"; + la = "ls -a"; + } + ''; + description = '' + An attribute set that maps aliases (the top level attribute names in + this option) to command strings or directly to build outputs. + ''; + }; + + configHeader = mkOption { + type = types.lines; + default = ""; + example = literalExpression '' + import os + import sys + ''; + description = "An arbitrary string to put at the top of the config file"; + }; + + configFooter = mkOption { + type = types.lines; + default = ""; + example = literalExpression '' + def _some_method(args): + do_command() + some_other_thing() + aliases['some_method'] = _some_method + ''; + description = "An arbitrary string to put at the end of the config file"; + }; + }; + }; + + config = + let + shortAliases = concatStringsSep "\n" ( + mapAttrsToList (k: v: "aliases['${k}']='${v}'") cfg.aliases + ); + + listToPythonList = let + listInternals = args: + concatStringsSep "\n" (map (v: "'${v}'") args); + in list: "[${listInternals list}]"; + + sessionVars = concatStringsSep "\n" ( + mapAttrsToList (k: v: + if builtins.typeOf v == "string" then + "\$${k} = '${v}'" + else if builtins.typeOf v == "list" then + "\$${k} = ${listToPythonList}" + else if builtins.typeOf v == "int" then + "\$${k} = ${toString v}" + else "" + ) cfg.sessionVariables + ); + + in mkIf cfg.enable { + + home.packages = [ pkgs.xonsh ]; + + home.file.".xonshrc".text = '' +${cfg.configHeader} + +${sessionVars} + +${shortAliases} + +${cfg.configFooter} +''; + }; +} diff --git a/home/vim.nix b/home/vim.nix index 4ea06f9..eaedde5 100644 --- a/home/vim.nix +++ b/home/vim.nix @@ -22,7 +22,6 @@ in vim-flake8 vim-fugitive vim-indent-guides - #vim-stabs gruvbox syntastic ]; @@ -74,9 +73,9 @@ let g:ctrlp_switch_buffer = 0 let g:ctrlp_cmd = 'CtrlPMixed' let g:ctrlp_user_command = { \'types': { - \1: ['.git', 'git ls-files --cached --exclude-standard --others' ], + \1: ['.git', '${pkgs.git}/bin/git ls-files --cached --exclude-standard --others' ], \}, - \'fallback': 'find . -type f | grep -v -e "\.tox/" -e "\.git/"' + \'fallback': '${pkgs.findutils}/bin/find . -type f | ${pkgs.gnugrep}/bin/grep -v -e "\.tox/" -e "\.git/"' \} " let g:ctrpl_match_func = { 'match': 'pymatcher#PyMatch' } @@ -88,6 +87,7 @@ autocmd! BufWritePost .vimrc source $MYVIMRC " Tell syntastic to use yamllint let g:syntastic_yaml_checkers = ['yamllint'] let g:syntastic_yaml_yamllint_args = [] +let g:syntastic_shell = "${pkgs.bash}/bin/bash" " Shortcuts for resolving git diff conflicts let g:diffget_local_map = 'gl' let g:diffget_upstream_map = 'gu' diff --git a/home/xonsh.nix b/home/xonsh.nix new file mode 100644 index 0000000..660ffc0 --- /dev/null +++ b/home/xonsh.nix @@ -0,0 +1,117 @@ +{ pkgs, config, nixosConfig, lib, ... }: + +let + enable = nixosConfig.greg.gnome.enable; +in { + programs.xonsh = { + enable = true; + + sessionVariables = { + TIMEFORMAT = "%3Uu %3Ss %3lR %P%%"; + CLICOLOR = 1; + LSCOLORS = "ExGxBxDxCxEgEdxbxgxcxd"; + EDITOR = "${pkgs.vim}/bin/vim"; + # Tells vox where to find virtualenvs + VIRTUALENV_HOME = "${config.home.homeDirectory}/venv/"; + # vte_new_tab_cwd causes new Terminal tabs to open in the + # same CWD as the current tab + PROMPT = "{vte_new_tab_cwd}{env_name}{BOLD_GREEN}{user}@{hostname}{BOLD_BLUE} {short_cwd}{branch_color}{curr_branch: {}}{RESET} {BOLD_BLUE}{prompt_end}{RESET} "; + SWORD_PATH = "${config.home.homeDirectory}/.sword/"; + OS_CLOUD = "default"; + MAVEN_OPTS = " -Dmaven.wagon.http.ssl.insecure=true"; + LESS_TERMCAP_mb = "\\033[01;31m"; # begin blinking + LESS_TERMCAP_md = "\\033[01;31m"; # begin bold + LESS_TERMCAP_me = "\\033[0m"; # end mode + LESS_TERMCAP_so = "\\033[01;44;36m"; # begin standout-mode (bottom of screen) + LESS_TERMCAP_se = "\\033[0m"; # end standout-mode + LESS_TERMCAP_us = "\\033[00;36m"; # begin underline + LESS_TERMCAP_ue = "\\033[0m"; # end underline + }; + + aliases = { + ll = "ls -l"; + vup = "vagrant up --provision --provider libvirt"; + vos = "vagrant up --provision --provider openstack"; + vssh = "vagrant ssh"; + vhalt = "vagrant halt"; + vprov = "vagrant provision"; + vdown = "vagrant destroy"; + ac = "vox activate"; + d = "vox deactivate"; + devroles = "cd ~/src/ansible_collections/devroles"; + molcol = "molecule -c ../../tests/molecule.yml"; + pa = "cd ~/src/packaging"; + }; + + configHeader = '' +# set -e == $RAISE_SUBPROC_ERROR = True +# set -x == trace on; $XONSH_TRACE_SUBPROC = True +# $? == _.rtn + +import os +''; + +#$PKG_CONFIG_PATH = '/usr/local/lib/pkgconfig' +#$GOPATH = $HOME + '/.go' +#$JAVA_HOME = '/etc/alternatives/java_sdk' + configFooter = '' +def _yaml2json(args, stdin=None, stdout=None): + import sys, yaml, json + from yaml import CLoader + json.dump(yaml.load(stdin, Loader=CLoader), stdout, indent=4) + +def _py2env(args): + vox new @(args[0]) -p /usr/bin/python2 + +def _py3env(args): + vox new @(args[0]) + +def _rundock(args): + if os.path.exists('/usr/bin/podman'): + e = 'podman' + else: + e = 'docker' + @(e) exec -ti @(args[0]) /bin/bash + +def _pip_extras(args): + import importlib_metadata + print(importlib_metadata.metadata(args[0]).get_all('Provides-Extra')) + +# Container stuff +def _newdock(args): + if os.path.exists('/usr/bin/podman'): + e = 'podman' + else: + e = 'docker' + @(e) run -P --privileged=true -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v @(os.getcwd()):/dmnt -v /etc/pki:/etc/pki:ro -d --name @(args[1]) @(args[0]) /sbin/init + rundock @(args[1]) + +def _unknown_host(args): + sed -i -e @(args[0])d ~/.ssh/known_hosts + +aliases['yaml2json'] = _yaml2json +aliases['py2env'] = _py2env +aliases['py3env'] = _py3env +aliases['rundock'] = _rundock +aliases['newdock'] = _newdock +aliases['unknown_host'] = _unknown_host +aliases['pip_extras'] = _pip_extras +### +# +# Other random nice-to-have things +# +### + +# Does virtualenv support +xontrib load vox +# Faster coreutils +xontrib load coreutils + +# Allows identifying JSON as if it was Python by adding some new builtins to the language +import builtins +builtins.true = True +builtins.false = False +builtins.null = None +''; + }; +} diff --git a/hosts/jude/default.nix b/hosts/jude/default.nix index ad1dbca..8c34c55 100644 --- a/hosts/jude/default.nix +++ b/hosts/jude/default.nix @@ -6,5 +6,5 @@ ./hardware-configuration.nix ]; networking.hostName = "jude"; - greg.gnome = true; + greg.gnome.enable= true; } diff --git a/modules/default.nix b/modules/default.nix index 27807ce..8124384 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -7,5 +7,6 @@ ./linode.nix ./proxy.nix ./rpi4.nix + ./xprograms.nix ]; } diff --git a/modules/gnome.nix b/modules/gnome.nix index a3b8575..45cd953 100644 --- a/modules/gnome.nix +++ b/modules/gnome.nix @@ -5,10 +5,12 @@ let in with lib; { options = { - greg.gnome = mkEnableOption "Enable my default Gnome3 setup"; + greg.gnome.enable = mkEnableOption "Enable my default Gnome3 setup"; }; - config = mkIf cfg { + config = mkIf cfg.enable { + greg.xprograms.enable = true; + # Sets up a basic Gnome installation services.xserver = { enable = true; @@ -21,16 +23,26 @@ in with lib; { programs.dconf.enable = true; programs.sway.enable = true; # Gives us Wayland - xdg.portal.wlr.enable = true; # Allows screen sharing in 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 gnomeExtensions.appindicator + gnomeExtensions.dash-to-dock ]; services.udev.packages = with pkgs; [ gnome3.gnome-settings-daemon ]; + + services.pipewire.enable = true; + + # Enablement for Firefox + services.gnome.chrome-gnome-shell.enable = true; }; } diff --git a/modules/xprograms.nix b/modules/xprograms.nix new file mode 100644 index 0000000..0a31731 --- /dev/null +++ b/modules/xprograms.nix @@ -0,0 +1,16 @@ +{ 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 + ]; + }; +} diff --git a/profiles/base/default.nix b/profiles/base/default.nix index 644d95f..043fb38 100755 --- a/profiles/base/default.nix +++ b/profiles/base/default.nix @@ -5,7 +5,6 @@ ./nix.nix ./programs.nix ./syncthing.nix - ./xonsh.nix ]; diff --git a/profiles/base/programs.nix b/profiles/base/programs.nix index ce02325..a5aa7d5 100644 --- a/profiles/base/programs.nix +++ b/profiles/base/programs.nix @@ -16,7 +16,6 @@ transcrypt vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. wget - xonsh yamllint # Used in vim ]; } diff --git a/profiles/base/xonsh.nix b/profiles/base/xonsh.nix deleted file mode 100644 index 9456475..0000000 --- a/profiles/base/xonsh.nix +++ /dev/null @@ -1,127 +0,0 @@ -{ pkgs, ... }: - -{ - programs.xonsh = { - enable = true; - config = '' -# set -e == $RAISE_SUBPROC_ERROR = True -# set -x == trace on; $XONSH_TRACE_SUBPROC = True -# $? == _.rtn - -import os - -$TIMEFORMAT = '%3Uu %3Ss %3lR %P%%' -$CLICOLOR = 1 -$LSCOLORS = 'ExGxBxDxCxEgEdxbxgxcxd' -$EDITOR = '${pkgs.vim}/bin/vim' -$PKG_CONFIG_PATH = '/usr/local/lib/pkgconfig' -# Tells vox where to find virtualenvs -$VIRTUALENV_HOME = $HOME + '/venv/' -$PROMPT = '{env_name}{BOLD_GREEN}{user}@{hostname}{BOLD_BLUE} {short_cwd}{branch_color}{curr_branch: {}}{RESET} {BOLD_BLUE}{prompt_end}{RESET} ' - - -$SWORD_PATH = $HOME + '/.sword' -$OS_CLOUD = 'default' - - -$GOPATH = '~/.go' -$JAVA_HOME = '/etc/alternatives/java_sdk' -$MAVEN_OPTS = ' -Dmaven.wagon.http.ssl.insecure=true' - - -# Coloured man page support -# using 'less' env vars (format is '\E[;m') -$LESS_TERMCAP_mb = "\033[01;31m" # begin blinking -$LESS_TERMCAP_md = "\033[01;31m" # begin bold -$LESS_TERMCAP_me = "\033[0m" # end mode -$LESS_TERMCAP_so = "\033[01;44;36m" # begin standout-mode (bottom of screen) -$LESS_TERMCAP_se = "\033[0m" # end standout-mode -$LESS_TERMCAP_us = "\033[00;36m" # begin underline -$LESS_TERMCAP_ue = "\033[0m" # end underline - - -#################################### -# -# Alias Time -# -#################################### -aliases['ll'] = 'ls -l' - -aliases['vup'] = 'vagrant up --provision --provider libvirt' -aliases['vos'] = 'vagrant up --provision --provider openstack' -aliases['vssh'] = 'vagrant ssh' -aliases['vhalt'] = 'vagrant halt' -aliases['vprov'] = 'vagrant provision' -aliases['vdown'] = 'vagrant destroy' - -aliases['ac'] = 'vox activate' -aliases['d'] = 'vox deactivate' - -aliases['devroles'] = 'cd ~/src/ansible_collections/devroles' -aliases['molcol'] = 'molecule -c ../../tests/molecule.yml' - -aliases['packaging'] = 'cd ~/src/packaging' - -def _yaml2json(args, stdin=None, stdout=None): - import sys, yaml, json - from yaml import CLoader - json.dump(yaml.load(stdin, Loader=CLoader), stdout, indent=4) - -def _py2env(args): - vox new @(args[0]) -p /usr/bin/python2 - -def _py3env(args): - vox new @(args[0]) - -def _rundock(args): - if os.path.exists('/usr/bin/podman'): - e = 'podman' - else: - e = 'docker' - @(e) exec -ti @(args[0]) /bin/bash - -def _pip_extras(args): - import importlib_metadata - print(importlib_metadata.metadata(args[0]).get_all('Provides-Extra')) - -# Container stuff -def _newdock(args): - if os.path.exists('/usr/bin/podman'): - e = 'podman' - else: - e = 'docker' - @(e) run -P --privileged=true -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v @(os.getcwd()):/dmnt -v /etc/pki:/etc/pki:ro -d --name @(args[1]) @(args[0]) /sbin/init - rundock @(args[1]) - -def _unknown_host(args): - sed -i -e @(args[0])d ~/.ssh/known_hosts - -aliases['yaml2json'] = _yaml2json -aliases['py2env'] = _py2env -aliases['py3env'] = _py3env -aliases['rundock'] = _rundock -aliases['newdock'] = _newdock -aliases['unknown_host'] = _unknown_host -aliases['pip_extras'] = _pip_extras -### -# -# Other random nice-to-have things -# -### - -# Does virtualenv support -xontrib load vox -# Faster coreutils -xontrib load coreutils - -# Allows identifying JSON as if it was Python by adding some new builtins to the language -import builtins -builtins.true = True -builtins.false = False -builtins.null = None - -# Open a new terminal tab (Gnome Terminal) in the same CWD -$PROMPT = '{vte_new_tab_cwd}' + $PROMPT -''; - }; -} From 2d333a91284490979606d460f027814ec71ea85f Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Mon, 2 May 2022 08:53:46 -0500 Subject: [PATCH 04/55] Adding more features to my desktop Add nheko for chat Add podman for development and testing --- home/gui/chat.nix | 2 +- hosts/jude/default.nix | 1 + hosts/jude/podman.nix | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 hosts/jude/podman.nix diff --git a/home/gui/chat.nix b/home/gui/chat.nix index 9f67c39..3441407 100644 --- a/home/gui/chat.nix +++ b/home/gui/chat.nix @@ -1,5 +1,5 @@ { pkgs, ... }: { - home.packages = [ pkgs.element-desktop ]; + home.packages = [ pkgs.element-desktop pkgs.nheko ]; } diff --git a/hosts/jude/default.nix b/hosts/jude/default.nix index 8c34c55..e5e0eaa 100644 --- a/hosts/jude/default.nix +++ b/hosts/jude/default.nix @@ -4,6 +4,7 @@ imports = [ ./boot.nix ./hardware-configuration.nix + ./podman.nix ]; networking.hostName = "jude"; greg.gnome.enable= true; diff --git a/hosts/jude/podman.nix b/hosts/jude/podman.nix new file mode 100644 index 0000000..837ebf4 --- /dev/null +++ b/hosts/jude/podman.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + virtualisation.podman = { + enable = true; + dockerCompat = true; + }; +} From f18d1f357cbf915f9f0cebe1f74a096c9d6928f8 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 4 May 2022 13:52:38 -0500 Subject: [PATCH 05/55] Make development experience work Add direnv to default build Add xonsh-direnv package to overlay and xonsh environment Add virtualisation options --- flake.nix | 4 +++- home/direnv.nix | 13 +++++++++++++ home/home.nix | 1 + home/ssh.nix | 5 +++++ home/vim.nix | 3 +++ home/xonsh.nix | 2 ++ hosts/jude/default.nix | 1 + hosts/jude/virt.nix | 25 +++++++++++++++++++++++++ overlays/default.nix | 12 ++++++++++++ overlays/defeault.nix | 6 ------ overlays/xonsh-direnv.nix | 20 ++++++++++++++++++++ profiles/base/nix.nix | 4 ++++ profiles/base/programs.nix | 10 ++++++++-- 13 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 home/direnv.nix create mode 100644 hosts/jude/virt.nix create mode 100644 overlays/default.nix delete mode 100644 overlays/defeault.nix create mode 100644 overlays/xonsh-direnv.nix diff --git a/flake.nix b/flake.nix index a37468f..77a65e6 100644 --- a/flake.nix +++ b/flake.nix @@ -17,8 +17,10 @@ outputs = inputs: let + local_overlay = import ./overlays; + mods = hostname: [ - { nixpkgs.overlays = [ inputs.nur.overlay ]; } + { nixpkgs.overlays = [ inputs.nur.overlay local_overlay ]; } inputs.agenix.nixosModule ./modules ./profiles/base diff --git a/home/direnv.nix b/home/direnv.nix new file mode 100644 index 0000000..4659ff4 --- /dev/null +++ b/home/direnv.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: + +{ + programs.direnv = { + enable = true; + nix-direnv.enable = true; + nix-direnv.enableFlakes = true; + }; + + home.packages = [ + pkgs.xonsh-direnv + ]; +} diff --git a/home/home.nix b/home/home.nix index 197350e..8ecf54a 100644 --- a/home/home.nix +++ b/home/home.nix @@ -8,6 +8,7 @@ in { imports = [ ./modules ./bash.nix + ./direnv.nix ./git.nix ./ssh.nix ./vim.nix diff --git a/home/ssh.nix b/home/ssh.nix index 879df1f..56d239a 100644 --- a/home/ssh.nix +++ b/home/ssh.nix @@ -35,6 +35,11 @@ "src.fedoraproject.org pkgs.fedoraproject.org" = { user = "greghellings"; }; + + "127.*".extraOptions = { + PubkeyAcceptedAlgorithms = "+ssh-rsa"; + HostkeyAlgorithms = "+ssh-rsa"; + }; }; }; diff --git a/home/vim.nix b/home/vim.nix index eaedde5..afa1672 100644 --- a/home/vim.nix +++ b/home/vim.nix @@ -15,13 +15,16 @@ in programs.vim = { enable = true; plugins = with pkgs.vimPlugins; [ + ansible-vim bufexplorer ctrlp + direnv-vim nerdtree vim-gitgutter vim-flake8 vim-fugitive vim-indent-guides + vim-packer gruvbox syntastic ]; diff --git a/home/xonsh.nix b/home/xonsh.nix index 660ffc0..98692c0 100644 --- a/home/xonsh.nix +++ b/home/xonsh.nix @@ -49,6 +49,8 @@ in { # $? == _.rtn import os + +xontrib load direnv ''; #$PKG_CONFIG_PATH = '/usr/local/lib/pkgconfig' diff --git a/hosts/jude/default.nix b/hosts/jude/default.nix index e5e0eaa..090d99c 100644 --- a/hosts/jude/default.nix +++ b/hosts/jude/default.nix @@ -5,6 +5,7 @@ ./boot.nix ./hardware-configuration.nix ./podman.nix + ./virt.nix ]; networking.hostName = "jude"; greg.gnome.enable= true; diff --git a/hosts/jude/virt.nix b/hosts/jude/virt.nix new file mode 100644 index 0000000..02a6e88 --- /dev/null +++ b/hosts/jude/virt.nix @@ -0,0 +1,25 @@ +{ pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + ansible + libguestfs + packer + virt-manager + vagrant + ]; + + # Give my user access to the libvirtd process + users.users.greg.extraGroups = [ "libvirtd" ]; + + virtualisation.libvirtd = { + enable = true; + onBoot = "ignore"; # Do not auto-restart VMs on boot, unless they are marked autostart + }; + + virtualisation.waydroid = { + enable = true; + }; + + boot.extraModprobeConfig = "options kvm_amd nested=1"; +} diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..5af5d1d --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,12 @@ +self: super: +{ + xonsh-direnv = super.callPackage ./xonsh-direnv.nix { + #lib = self.lib; + buildPythonPackage = self.python3.pkgs.buildPythonPackage; + fetchPypi = self.python.pkgs.fetchPypi; + }; + + xonsh = super.xonsh.overridePythonAttrs (old: rec{ + propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.xonsh-direnv ]; + }); +} diff --git a/overlays/defeault.nix b/overlays/defeault.nix deleted file mode 100644 index f71814b..0000000 --- a/overlays/defeault.nix +++ /dev/null @@ -1,6 +0,0 @@ -self: super: -{ - git = super.git.override { - meta.priority = 4; - }; -} diff --git a/overlays/xonsh-direnv.nix b/overlays/xonsh-direnv.nix new file mode 100644 index 0000000..79afcad --- /dev/null +++ b/overlays/xonsh-direnv.nix @@ -0,0 +1,20 @@ +{ lib, buildPythonPackage, fetchPypi, pkgs}: + +buildPythonPackage rec { + pname = "xonsh-direnv"; + version = "1.5.0"; + + src = fetchPypi { + inherit pname version; + sha256 = "OLjtGD2lX4Yf3aHrxCWmAbSPZnf8OuVrBu0VFbsna1Y="; + }; + + meta = with lib; { + description = "Direnv support for Xonsh"; + homepage = "https://github.com/74th/xonsh-direnv/"; + license = licenses.mit; + maintainers = []; + }; + + doCheck = false; +} diff --git a/profiles/base/nix.nix b/profiles/base/nix.nix index 0b23255..3a964da 100644 --- a/profiles/base/nix.nix +++ b/profiles/base/nix.nix @@ -10,6 +10,10 @@ 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 ''; # Use hardlinking instead of copying when possible diff --git a/profiles/base/programs.nix b/profiles/base/programs.nix index a5aa7d5..b37d479 100644 --- a/profiles/base/programs.nix +++ b/profiles/base/programs.nix @@ -1,6 +1,12 @@ { 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}" @@ -10,7 +16,7 @@ findutils home-manager htop - python3 + myPython pwgen tmux transcrypt From 97dc85a256fe2d8d991ed7ac145eb2ef35999414 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 11 May 2022 23:59:11 -0500 Subject: [PATCH 06/55] Remove unneeded libs --- overlays/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/overlays/default.nix b/overlays/default.nix index 5af5d1d..080869d 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,7 +1,6 @@ self: super: { xonsh-direnv = super.callPackage ./xonsh-direnv.nix { - #lib = self.lib; buildPythonPackage = self.python3.pkgs.buildPythonPackage; fetchPypi = self.python.pkgs.fetchPypi; }; From 9f76a9040319e513615657dc235609f8ccc3000e Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 11 May 2022 23:59:28 -0500 Subject: [PATCH 07/55] Comment out broken vim config --- home/vim.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/home/vim.nix b/home/vim.nix index afa1672..45e1781 100644 --- a/home/vim.nix +++ b/home/vim.nix @@ -74,12 +74,13 @@ set wildignore+=*.swp,*.pyc,*.class,.tox let g:ctrlp_working_path_mode = 'arc' let g:ctrlp_switch_buffer = 0 let g:ctrlp_cmd = 'CtrlPMixed' -let g:ctrlp_user_command = { - \'types': { - \1: ['.git', '${pkgs.git}/bin/git ls-files --cached --exclude-standard --others' ], - \}, - \'fallback': '${pkgs.findutils}/bin/find . -type f | ${pkgs.gnugrep}/bin/grep -v -e "\.tox/" -e "\.git/"' -\} +let g:ctrlp_show_hidden = 1 +"let g:ctrlp_user_command = { +" \'types': { +" \1: ['.git', '${pkgs.git}/bin/git ls-files --cached --exclude-standard --others' ], +" \}, +" \'fallback': '${pkgs.findutils}/bin/find . -type f | ${pkgs.gnugrep}/bin/grep -v -e "\.tox/" -e "\.git/"' +"\} " let g:ctrpl_match_func = { 'match': 'pymatcher#PyMatch' } " Settings for NerdTree From 669f22c3a75b002ac93c68897532beea239891c6 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Thu, 19 May 2022 11:26:08 -0500 Subject: [PATCH 08/55] Remove vlan67 --- hosts/2maccabees/networking.nix | 9 --------- 1 file changed, 9 deletions(-) diff --git a/hosts/2maccabees/networking.nix b/hosts/2maccabees/networking.nix index 3217e34..5825944 100644 --- a/hosts/2maccabees/networking.nix +++ b/hosts/2maccabees/networking.nix @@ -20,11 +20,6 @@ address = "192.168.66.2"; prefixLength = 24; } ]; - - vlan67.ipv4.addresses = [ { - address = "192.168.67.2"; - prefixLength = 24; - } ]; }; vlans = { @@ -32,10 +27,6 @@ id = 66; interface = "eth0"; }; - vlan67 = { - id = 67; - interface = "eth0"; - }; }; }; From b93650b198eff7e6f820b301060403cb3a588179 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 20 May 2022 10:12:40 -0500 Subject: [PATCH 09/55] Update flake locking --- flake.lock | 30 ++++----- flake.nix | 14 ++++- hosts/2maccabees/home-assistant.nix | 97 ++++++++++------------------- 3 files changed, 61 insertions(+), 80 deletions(-) diff --git a/flake.lock b/flake.lock index 1dab8b7..ed6ff21 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1648942457, - "narHash": "sha256-i29Z1t3sVfCNfpp+KAfeExvpqHQSbLO1KWylTtfradU=", + "lastModified": 1652712410, + "narHash": "sha256-hMJ2TqLt0DleEnQFGUHK9sV2aAzJPU8pZeiZoqRozbE=", "owner": "ryantm", "repo": "agenix", - "rev": "0d5e59ed645e4c7b60174bc6f6aac6a203dc0b01", + "rev": "7e5e58b98c3dcbf497543ff6f22591552ebfe65b", "type": "github" }, "original": { @@ -25,11 +25,11 @@ ] }, "locked": { - "lastModified": 1649887911, - "narHash": "sha256-Af0Ppb1RZ7HWuxUvF0/O7h3cy8tqU2eKFyVwyA1ZD+w=", + "lastModified": 1651519540, + "narHash": "sha256-3k6p8VsTwwRPQjE8rrMh+o2AZACZn/eeYJ7ivdQ/Iro=", "owner": "nix-community", "repo": "home-manager", - "rev": "7244c6715cb8f741f3b3e1220a9279e97b2ed8f5", + "rev": "d93d56ab8c1c6aa575854a79b9d2f69d491db7d0", "type": "github" }, "original": { @@ -57,11 +57,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1650244918, - "narHash": "sha256-DsS5nxjTpnoUC4pNXJI1rit7TnDTij8vQDa5PtcDCD0=", + "lastModified": 1652881001, + "narHash": "sha256-k9JmPCojaJnqGz4aRXXT1HZqJKHCXijoMfBAb24abXk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7b38b03d76ab71bdc8dc325e3f6338d984cc35ca", + "rev": "2d474d6a4a43a0348b78db68dc00c491032cf5cf", "type": "github" }, "original": { @@ -73,11 +73,11 @@ }, "nixunstable": { "locked": { - "lastModified": 1651007983, - "narHash": "sha256-GNay7yDPtLcRcKCNHldug85AhAvBpTtPEJWSSDYBw8U=", + "lastModified": 1652794215, + "narHash": "sha256-erVj41IcCPDWdt8CwT60ygD+SY/uhqip3RXwiESOCVk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e10da1c7f542515b609f8dfbcf788f3d85b14936", + "rev": "242efdc5a5aff8222c1152c0e4b9262bd02915b6", "type": "github" }, "original": { @@ -89,11 +89,11 @@ }, "nur": { "locked": { - "lastModified": 1651053120, - "narHash": "sha256-PKbB7MK6jwG4G3A/2RR0ZA8YSNanwi5R+Bvv/LwzKwo=", + "lastModified": 1652997257, + "narHash": "sha256-vF4ji8t3ZgwjhGH0nrlO1n4AhsOfL7H4eGSP10BKj/k=", "owner": "nix-community", "repo": "NUR", - "rev": "2eb8999947487d915d6a1100d672284a1989c905", + "rev": "4ab0b3bc0bcfa401360cac1f77a4355589c465f7", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 77a65e6..3184c3a 100644 --- a/flake.nix +++ b/flake.nix @@ -41,9 +41,21 @@ modules = mods name; }; + unstableMachine = system: name: inputs.nixunstable.lib.nixosSystem { + system = system; + modules = mods name; + specialArgs = { + nixpkgs = inputs.nixunstable; + nixunstable = inputs.nixunstable; + agenix = inputs.agenix; + home-manager = inputs.home-manager; + nur = inputs.nur; + }; + }; + in { nixosConfigurations = { - "2maccabees" = machine "aarch64-linux" "2maccabees"; + "2maccabees" = unstableMachine "aarch64-linux" "2maccabees"; "linode" = machine "x86_64-linux" "linode"; diff --git a/hosts/2maccabees/home-assistant.nix b/hosts/2maccabees/home-assistant.nix index ac77178..e921121 100755 --- a/hosts/2maccabees/home-assistant.nix +++ b/hosts/2maccabees/home-assistant.nix @@ -7,19 +7,44 @@ in { virtualisation.podman.enable = true; + services.home-assistant = { + enable = true; + configDir = "/var/lib/hass"; + package = (pkgs.home-assistant.override { + extraComponents = [ + "accuweather" + "cast" + "eufy" + "lovelace" + "tplink" + "wiz" + "zwave_js" + ]; + }).overrideAttrs (oldAttrs: { + doInstallCheck = false; + }); + + config = { + default_config = {}; + esphome = {}; # Get these things loaded, even if not configured + met = {}; + tts = [ { platform = "google_translate"; } ]; + http = { + use_x_forwarded_for = true; + trusted_proxies = [ "127.0.0.1" "::1" ]; + server_host = "127.0.0.1"; + }; + "automation ui" = "!include automations.yaml"; + "script ui" = "!include scripts.yaml"; + "scene ui" = "!include scenes.yaml"; + }; + }; + # Although NixOS has a package for Home Assistant, it is not kept as up to date as the container and the upstream # is very vocal about only supporting their own container or the HAOS deployments. So we deploy the container here # and avoid any potential messes from that virtualisation.oci-containers = { backend = "podman"; - containers."home-assistant" = { - image = "ghcr.io/home-assistant/home-assistant:stable"; - ports = [ "127.0.0.1:8123:8123" ]; - volumes = [ "/var/lib/hass:/config" ]; - extraOptions = [ - "--device" "/dev/ttyAMA0" - ]; - }; # I have ZWave devices. The easiest way to connect to them is the zwavejs2mqtt service running, so we spin up # its container and map the ZWave device into it @@ -36,13 +61,6 @@ in # Both of the above container need storage for their configuration and devices, but it is not created correctly by # the container. So we add the creation of /var/lib/{zwave,hass} to the systemd Unit files systemd.services = { - "podman-home-assistant" = { - serviceConfig = { - StateDirectory = "hass"; - StateDirectoryMode = pkgs.lib.mkForce "0777"; - }; - }; - "podman-zwave".serviceConfig = { StateDirectory = "zwave"; StateDirectoryMode = pkgs.lib.mkForce "0777"; @@ -50,49 +68,6 @@ in }; - # Podman 3.4, which is in NixOS 21.11 does not support creating multiple network interfaces during launch. Starting in Podman - # 4.0 (NixOS 22.05) that will be possible. For now, adding this sidecar service that executes after every time the Home Assistant - # container is started will do the necessary Podman commands to attach the container to the interface for VLAN 66. Once we - # upgrade to NixOS 22.05 this service can go away and we can explicitly add two "--network" options to the Home Assistant container - systemd.services."home-assistant-network-attach" = { - requires = service_list; - path = [ pkgs.podman pkgs.coreutils ]; - script = "sleep 10 && podman network connect podman66 home-assistant"; - wantedBy = service_list; - serviceConfig = { - Type = "oneshot"; - }; - }; - - # This ensures that Podman has a separate network configured to attach to my IOT VLAN so that Home Assistant is able to communicate - # with my devices as well as with the rest of the LAN. - systemd.services.podman66 = { - wantedBy = service_list; - before = service_list; - path = [ pkgs.podman ]; - script = "podman network create -d macvlan -o parent=vlan66 --subnet 192.168.66.0/24 --ip-range 192.168.66.192/26 --gateway 192.168.66.1 podman66 || true"; - serviceConfig = { - Type = "oneshot"; - }; - }; - - # I do not want to have to remember the port number for Home Assistant's UI, so we use Nginx to proxy communication from - # smart.thehellings.lan to the Home Assistant UI - # After the first activation of this container, before you can access the Home Assistant UI, you need to ensure that the - # Home Assistant's configuration at /var/lib/hass/configuration.yaml includes the following option. Update the IP address - # if you have changed the value of your default podman network. - # ```yaml - # http: - # use_x_forwarded_for: true - # trusted_proxies: - # - "10.88.0.1" - # ``` - # Home assistant will not accept connections from the proxy if these values are not set. If you are adding those values - # manually after initial creation of the containers, then you will need to issue `systemctl restart podman-home-assistant.service` - # for Home Assistant to pick up the new values. After that, proxy connections should work well. If you are sitting behind - # multiple layers of proxies, then add more of them in the list. The list also accepts subnet notation in case you have - # multiple potentially incoming connections. So you could do "10.88.0.1/24", according to the docs. However, that has not - # worked in my testing, as Home Assistant throws an error on start up saying that value is invalid greg.proxies."smart.thehellings.lan".target = "http://127.0.0.1:8123"; # Ensure that both ports are up and running. We keep 8123 directly open because we are on the LAN and sometimes want to connect @@ -107,12 +82,6 @@ in services.syncthing = { enable = true; folders = { - "asdf-fdsa" = { - enable = true; - path = "/var/lib/hass"; - devices = [ "nas" ]; - }; - "zwave-live" = { enable = true; path = "/var/lib/zwave"; From b5236bf14564c0e14ab5298ab1d0ba8e6aedf56f Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 22 May 2022 21:01:37 -0500 Subject: [PATCH 10/55] Add direnv flake alias --- home/xonsh.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/home/xonsh.nix b/home/xonsh.nix index 98692c0..7b7ccc2 100644 --- a/home/xonsh.nix +++ b/home/xonsh.nix @@ -41,6 +41,7 @@ in { devroles = "cd ~/src/ansible_collections/devroles"; molcol = "molecule -c ../../tests/molecule.yml"; pa = "cd ~/src/packaging"; + dirflake = "nix flake new -t github:nix-community/nix-direnv"; }; configHeader = '' From cc98e529f5eaf3957caf661ed1a2fc1976f4d9c1 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Mon, 23 May 2022 23:58:40 -0500 Subject: [PATCH 11/55] Update Firefox and stateVersion Set home-manager stateVersion to 21.11 Move to newer method of integrating Firefox with Gnome Add tree-style-tab plugin for Firefox --- home/gui/firefox.nix | 7 ++++++- home/home.nix | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/home/gui/firefox.nix b/home/gui/firefox.nix index a79cfd5..d5513a0 100644 --- a/home/gui/firefox.nix +++ b/home/gui/firefox.nix @@ -13,11 +13,16 @@ in with lib; { programs.firefox = { enable = true; - enableGnomeExtensions = true; + package = pkgs.firefox-wayland.override { + cfg = { + enableGnomeExtensions = true; + }; + }; extensions = with pkgs.nur.repos.rycee.firefox-addons; [ keepassxc-browser octotree refined-github + tree-style-tab ublock-origin ]; profiles = { diff --git a/home/home.nix b/home/home.nix index 8ecf54a..62cd5b3 100644 --- a/home/home.nix +++ b/home/home.nix @@ -18,4 +18,5 @@ in { home.username = name; home.homeDirectory = if name == "root" then "/root" else "/home/${name}"; + home.stateVersion = "21.11"; } From ac9d5fad068a7b719206cbb20ec1677d83e1b66b Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 25 May 2022 00:15:11 -0500 Subject: [PATCH 12/55] Add onlyoffice to distro --- home/gui/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/home/gui/default.nix b/home/gui/default.nix index 5cffb04..95f8ffc 100644 --- a/home/gui/default.nix +++ b/home/gui/default.nix @@ -1,4 +1,4 @@ -{ ... }: +{ pkgs, ... }: { imports = [ @@ -6,4 +6,8 @@ ./firefox.nix ./terminal.nix ]; + + home.packages = with pkgs; [ + onlyoffice-bin + ]; } From 5e1eaac35cacd2f474f156c8c1c3dc7c1707a427 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 25 May 2022 01:32:08 -0500 Subject: [PATCH 13/55] Tidy up flake args --- flake.nix | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 77a65e6..c114d0a 100644 --- a/flake.nix +++ b/flake.nix @@ -15,28 +15,29 @@ nur.url = "github:nix-community/NUR"; }; - outputs = inputs: + outputs = {nixpkgs, nixunstable, agenix, home-manager, nur, self}@inputs: let local_overlay = import ./overlays; mods = hostname: [ - { nixpkgs.overlays = [ inputs.nur.overlay local_overlay ]; } - inputs.agenix.nixosModule + { nixpkgs.overlays = [ nur.overlay local_overlay ]; } + agenix.nixosModule ./modules ./profiles/base ./hosts/${hostname} - inputs.home-manager.nixosModules.home-manager { + home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; home-manager.users.greg = import ./home/home.nix "greg"; home-manager.users.root = import ./home/home.nix "root"; home-manager.extraSpecialArgs = { - nixunstable = inputs.nixunstable; + inherit nixunstable; }; } ]; - machine = system: name: inputs.nixpkgs.lib.nixosSystem { - system = system; + machine = system: name: nixpkgs.lib.nixosSystem { + inherit system; specialArgs = inputs; modules = mods name; }; From b3179604d9d4bd239a0af01be1e59c8215eb9a88 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 27 May 2022 13:53:02 -0500 Subject: [PATCH 14/55] Add ansible config files --- home/ansible.nix | 28 ++++++++++++++++++++++++++++ home/home.nix | 1 + 2 files changed, 29 insertions(+) create mode 100644 home/ansible.nix diff --git a/home/ansible.nix b/home/ansible.nix new file mode 100644 index 0000000..f4df8b6 --- /dev/null +++ b/home/ansible.nix @@ -0,0 +1,28 @@ +{ ... }: + +{ + home.file.".ansible.cfg".text = '' +[defaults] +forks=10 +host_key_checking=False +# Also available: profile_roles +callback_enabled=timer,profile_tasks +stdout_callback=yaml +nocows=1 +cow_selection=tux +collections_path=~/src + +[ssh_connection] +pipelining=True +ssh_args = -o ControlMaster=auto -o ControlPersist=600s -o IdentitiesOnly=yes -o GSSAPIAuthentication=no -o StrictHostKeyChecking=no +control_path=%(directory)s/%%h-%%r +control_path_dir=/tmp + +[callback_profile_tasks] +sort_order=descending + +[galaxy] +role_skeleton_ignore = ^.git$,^.*/.git_keep$,\..*.swp +role_skeleton = ~/src/ansible_collections/meta_ansible_templates/role +''; +} diff --git a/home/home.nix b/home/home.nix index 62cd5b3..55fc169 100644 --- a/home/home.nix +++ b/home/home.nix @@ -7,6 +7,7 @@ let in { imports = [ ./modules + ./ansible.nix ./bash.nix ./direnv.nix ./git.nix From eb17fb1d3c993368d5fe4b8125f1268c30ce5be1 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Thu, 2 Jun 2022 08:20:45 -0500 Subject: [PATCH 15/55] Upgrade to 22.05 --- flake.lock | 34 +++++++++++++++++----------------- flake.nix | 4 ++-- home/direnv.nix | 1 - 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index 1dab8b7..a11ff8a 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1648942457, - "narHash": "sha256-i29Z1t3sVfCNfpp+KAfeExvpqHQSbLO1KWylTtfradU=", + "lastModified": 1652712410, + "narHash": "sha256-hMJ2TqLt0DleEnQFGUHK9sV2aAzJPU8pZeiZoqRozbE=", "owner": "ryantm", "repo": "agenix", - "rev": "0d5e59ed645e4c7b60174bc6f6aac6a203dc0b01", + "rev": "7e5e58b98c3dcbf497543ff6f22591552ebfe65b", "type": "github" }, "original": { @@ -25,16 +25,16 @@ ] }, "locked": { - "lastModified": 1649887911, - "narHash": "sha256-Af0Ppb1RZ7HWuxUvF0/O7h3cy8tqU2eKFyVwyA1ZD+w=", + "lastModified": 1654113405, + "narHash": "sha256-VpK+0QaWG2JRgB00lw77N9TjkE3ec0iMYIX1TzGpxa4=", "owner": "nix-community", "repo": "home-manager", - "rev": "7244c6715cb8f741f3b3e1220a9279e97b2ed8f5", + "rev": "ac2287df5a2d6f0a44bbcbd11701dbbf6ec43675", "type": "github" }, "original": { "owner": "nix-community", - "ref": "release-21.11", + "ref": "release-22.05", "repo": "home-manager", "type": "github" } @@ -57,27 +57,27 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1650244918, - "narHash": "sha256-DsS5nxjTpnoUC4pNXJI1rit7TnDTij8vQDa5PtcDCD0=", + "lastModified": 1654005557, + "narHash": "sha256-J6elwUzPoco+r5qWPHhvS2EHVWomUtNcxzkfdAQOwEU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7b38b03d76ab71bdc8dc325e3f6338d984cc35ca", + "rev": "08950a6e29cf7bddee466592eb790a417550f7f9", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-21.11", + "ref": "nixos-22.05", "repo": "nixpkgs", "type": "github" } }, "nixunstable": { "locked": { - "lastModified": 1651007983, - "narHash": "sha256-GNay7yDPtLcRcKCNHldug85AhAvBpTtPEJWSSDYBw8U=", + "lastModified": 1653931853, + "narHash": "sha256-O3wncIouj9x7gBPntzHeK/Hkmm9M1SGlYq7JI7saTAE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e10da1c7f542515b609f8dfbcf788f3d85b14936", + "rev": "f1c167688a6f81f4a51ab542e5f476c8c595e457", "type": "github" }, "original": { @@ -89,11 +89,11 @@ }, "nur": { "locked": { - "lastModified": 1651053120, - "narHash": "sha256-PKbB7MK6jwG4G3A/2RR0ZA8YSNanwi5R+Bvv/LwzKwo=", + "lastModified": 1654123271, + "narHash": "sha256-xM85/VFYu8I8jZiZ7U0CmZO/98sHO7+f7PIMxQVZXCM=", "owner": "nix-community", "repo": "NUR", - "rev": "2eb8999947487d915d6a1100d672284a1989c905", + "rev": "4c83235ccca7cfcf34fee9f49023f21c0e9db128", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index c114d0a..b90f021 100644 --- a/flake.nix +++ b/flake.nix @@ -5,11 +5,11 @@ description = "Greg's machines!"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05"; nixunstable.url = "github:nixos/nixpkgs/nixos-unstable"; agenix.url = "github:ryantm/agenix"; home-manager = { - url = "github:nix-community/home-manager/release-21.11"; + url = "github:nix-community/home-manager/release-22.05"; inputs.nixpkgs.follows = "nixpkgs"; }; nur.url = "github:nix-community/NUR"; diff --git a/home/direnv.nix b/home/direnv.nix index 4659ff4..b6d26ad 100644 --- a/home/direnv.nix +++ b/home/direnv.nix @@ -4,7 +4,6 @@ programs.direnv = { enable = true; nix-direnv.enable = true; - nix-direnv.enableFlakes = true; }; home.packages = [ From 36f5000e3c88be2f67c0c650d4f961a822296ee2 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Thu, 2 Jun 2022 09:34:20 -0500 Subject: [PATCH 16/55] Add unzip as general tool --- profiles/base/programs.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/profiles/base/programs.nix b/profiles/base/programs.nix index b37d479..3c188fb 100644 --- a/profiles/base/programs.nix +++ b/profiles/base/programs.nix @@ -20,6 +20,7 @@ in { 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 From 6c87da8ce5ce752854bda2fe2aa5501ef10c52d0 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Thu, 2 Jun 2022 09:34:37 -0500 Subject: [PATCH 17/55] Add virutalbox --- hosts/jude/virt.nix | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hosts/jude/virt.nix b/hosts/jude/virt.nix index 02a6e88..accf728 100644 --- a/hosts/jude/virt.nix +++ b/hosts/jude/virt.nix @@ -12,14 +12,20 @@ # Give my user access to the libvirtd process users.users.greg.extraGroups = [ "libvirtd" ]; - virtualisation.libvirtd = { - enable = true; - onBoot = "ignore"; # Do not auto-restart VMs on boot, unless they are marked autostart + virtualisation = { + libvirtd = { + enable = true; + onBoot = "ignore"; # Do not auto-restart VMs on boot, unless they are marked autostart + }; + + waydroid = { + enable = true; + }; + + virtualbox.host.enable = true; }; - virtualisation.waydroid = { - enable = true; - }; + users.extraGroups.vboxusers.members = [ "greg" ]; boot.extraModprobeConfig = "options kvm_amd nested=1"; } From 899cfba9ebab7ff15c66521ca0a2ddbfdacf7e5c Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 3 Jun 2022 15:41:45 -0500 Subject: [PATCH 18/55] Add printers --- hosts/jude/default.nix | 1 + hosts/jude/printing.nix | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 hosts/jude/printing.nix diff --git a/hosts/jude/default.nix b/hosts/jude/default.nix index 090d99c..342e027 100644 --- a/hosts/jude/default.nix +++ b/hosts/jude/default.nix @@ -5,6 +5,7 @@ ./boot.nix ./hardware-configuration.nix ./podman.nix + ./printing.nix ./virt.nix ]; networking.hostName = "jude"; diff --git a/hosts/jude/printing.nix b/hosts/jude/printing.nix new file mode 100644 index 0000000..07d237f --- /dev/null +++ b/hosts/jude/printing.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: + +{ + # ipp://printer.thehellings.lan:631/ - generic postscript printer + services.printing = { + enable = true; + drivers = with pkgs; [ + gutenprint + gutenprintBin + ]; + }; +} From a5ad72423a09e306742cdeb052322847331cef48 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 10 Jun 2022 05:48:18 +0000 Subject: [PATCH 19/55] Linode config update 22.05 --- hosts/linode/postgres.nix | 4 ++-- hosts/linode/synapse.nix | 40 +++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/hosts/linode/postgres.nix b/hosts/linode/postgres.nix index 9191feb..e75e1b4 100644 --- a/hosts/linode/postgres.nix +++ b/hosts/linode/postgres.nix @@ -31,10 +31,10 @@ root root postgres services.logrotate = { enable = true; - paths = { + settings = { postgres = { enable = true; - path = "${config.services.postgresqlBackup.location}/*.gz"; + files = "${config.services.postgresqlBackup.location}/*.gz"; }; }; }; diff --git a/hosts/linode/synapse.nix b/hosts/linode/synapse.nix index 2d296e5..42ea89f 100644 --- a/hosts/linode/synapse.nix +++ b/hosts/linode/synapse.nix @@ -74,26 +74,30 @@ return 200 '${builtins.toJSON client}'; services.matrix-synapse = { enable = true; - database_name = "synapse"; - database_user = "matrix-synapse"; # Identify ourselves as the root of our own domain - server_name = "thehellings.com"; - #registration_shared_secret = "B9EoPr2WV9hzwc7uL2Sx1JmvCeKDEOGCpB0uginQcQtEH4wzRtkSIdo7lltrjSQa"; - # Bind a single listener to localhost only, disable SSL/TLS, and put - # it behind an nginx proxy - listeners = [ { - port = 8448; - bind_address = "127.0.0.1"; - type = "http"; # Offload SSL/TLS to Nginx - tls = false; - resources = [ { - names = [ "client" "federation" ]; - compress = false; # Offload compressiong to Nginx + settings = { + database.args = { + user = "matrix-synapse"; + name = "synapse"; + }; + server_name = "thehellings.com"; + #registration_shared_secret = "B9EoPr2WV9hzwc7uL2Sx1JmvCeKDEOGCpB0uginQcQtEH4wzRtkSIdo7lltrjSQa"; + # Bind a single listener to localhost only, disable SSL/TLS, and put + # it behind an nginx proxy + listeners = [ { + port = 8448; + bind_addresses = ["127.0.0.1"]; + type = "http"; # Offload SSL/TLS to Nginx + tls = false; + resources = [ { + names = [ "client" "federation" ]; + compress = false; # Offload compressiong to Nginx + } ]; } ]; - } ]; - app_service_config_files = [ - "/etc/${fbRegistrationFile}" - ]; + app_service_config_files = [ + "/etc/${fbRegistrationFile}" + ]; + }; }; # Open networking ports for the server From 139ac1277f1496c5cc387140f2750f61d92813da Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 10 Jun 2022 01:09:38 -0500 Subject: [PATCH 20/55] Add tailscale to Jude --- hosts/jude/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/hosts/jude/default.nix b/hosts/jude/default.nix index 342e027..188af78 100644 --- a/hosts/jude/default.nix +++ b/hosts/jude/default.nix @@ -9,5 +9,6 @@ ./virt.nix ]; networking.hostName = "jude"; + services.tailscale.enable = true; greg.gnome.enable= true; } From 0f16792ed5eb586fa36125600d2e21b60a3dd29f Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 10 Jun 2022 01:09:52 -0500 Subject: [PATCH 21/55] Add bitwarden clients --- home/gui/default.nix | 1 + profiles/base/programs.nix | 1 + 2 files changed, 2 insertions(+) diff --git a/home/gui/default.nix b/home/gui/default.nix index 95f8ffc..4ee5a48 100644 --- a/home/gui/default.nix +++ b/home/gui/default.nix @@ -8,6 +8,7 @@ ]; home.packages = with pkgs; [ + bitwarden onlyoffice-bin ]; } diff --git a/profiles/base/programs.nix b/profiles/base/programs.nix index 3c188fb..06afebb 100644 --- a/profiles/base/programs.nix +++ b/profiles/base/programs.nix @@ -10,6 +10,7 @@ in { # Base packages that need to be in all my hosts environment.systemPackages = with pkgs; [ agenix.defaultPackage."${system}" + bitwarden-cli diffutils git gnupatch From e8b4f3b3b018a6cc12dceed7cf098f30939ef82e Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 12 Jun 2022 03:50:24 +0000 Subject: [PATCH 22/55] Simplify syncthing and fix Synapse --- hosts/linode/nextcloud.nix | 4 ---- hosts/linode/postgres.nix | 4 ---- hosts/linode/synapse.nix | 2 +- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/hosts/linode/nextcloud.nix b/hosts/linode/nextcloud.nix index b4c7265..068ec5a 100644 --- a/hosts/linode/nextcloud.nix +++ b/hosts/linode/nextcloud.nix @@ -30,8 +30,4 @@ enable = true; devices = [ "nas" ]; }; - - services.cron.systemCronJobs = [ - "59 2 * * * root chmod -R a+r ${config.services.syncthing.folders.nextcloud-backup.path} && find ${config.services.syncthing.folders.nextcloud-backup.path} -type d -exec chmod a+x '{}' \\;" - ]; } diff --git a/hosts/linode/postgres.nix b/hosts/linode/postgres.nix index e75e1b4..c8f9780 100644 --- a/hosts/linode/postgres.nix +++ b/hosts/linode/postgres.nix @@ -44,8 +44,4 @@ root root postgres enable = true; devices = [ "nas" ]; }; - - services.cron.systemCronJobs = [ - "59 2 * * * root chmod -R a+r ${config.services.postgresqlBackup.location} && find ${config.services.postgresqlBackup.location} -type d -exec chmod a+x '{}' \\;" - ]; } diff --git a/hosts/linode/synapse.nix b/hosts/linode/synapse.nix index 42ea89f..02bb222 100644 --- a/hosts/linode/synapse.nix +++ b/hosts/linode/synapse.nix @@ -78,7 +78,7 @@ return 200 '${builtins.toJSON client}'; settings = { database.args = { user = "matrix-synapse"; - name = "synapse"; + database = "synapse"; }; server_name = "thehellings.com"; #registration_shared_secret = "B9EoPr2WV9hzwc7uL2Sx1JmvCeKDEOGCpB0uginQcQtEH4wzRtkSIdo7lltrjSQa"; From 164e30cd87e203836749e588d9af56c95de5731f Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 12 Jun 2022 04:58:34 +0000 Subject: [PATCH 23/55] Update ACME configurations --- hosts/linode/nginx.nix | 3 ++- modules/proxy.nix | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hosts/linode/nginx.nix b/hosts/linode/nginx.nix index 9f17309..dc7c4de 100644 --- a/hosts/linode/nginx.nix +++ b/hosts/linode/nginx.nix @@ -5,7 +5,7 @@ in { security.acme = { acceptTerms = true; - email = "greg.hellings@gmail.com"; + defaults.email = "greg.hellings@gmail.com"; }; services.nginx = { @@ -30,5 +30,6 @@ in greg.proxies."thehellings.com" = { target = "http://${homepage}/"; ssl = true; + genAliases = false; }; } diff --git a/modules/proxy.nix b/modules/proxy.nix index 7e0768f..e108242 100644 --- a/modules/proxy.nix +++ b/modules/proxy.nix @@ -16,7 +16,7 @@ proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; ''; }; - serverAliases = [ "${alias name}" ]; + serverAliases = lib.mkIf dest.genAliases [ "${alias name}" ]; }; in with lib; { @@ -40,6 +40,12 @@ in with lib; { { 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.''; From d34a180efe4687cc141d9ea339cebbb2b42c9056 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 12 Jun 2022 04:59:12 +0000 Subject: [PATCH 24/55] Add tailscale support to linode --- hosts/linode/default.nix | 1 + modules/default.nix | 1 + modules/tailscale.nix | 14 ++++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 modules/tailscale.nix diff --git a/hosts/linode/default.nix b/hosts/linode/default.nix index 2ab58f5..ae0a13c 100644 --- a/hosts/linode/default.nix +++ b/hosts/linode/default.nix @@ -10,6 +10,7 @@ ]; greg.home = false; greg.linode.enable = true; + greg.tailscale.enable = true; networking.hostName = "linode"; networking.domain = "thehellings.com"; } diff --git a/modules/default.nix b/modules/default.nix index 8124384..2a2d0c4 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -7,6 +7,7 @@ ./linode.nix ./proxy.nix ./rpi4.nix + ./tailscale.nix ./xprograms.nix ]; } diff --git a/modules/tailscale.nix b/modules/tailscale.nix new file mode 100644 index 0000000..54e34b1 --- /dev/null +++ b/modules/tailscale.nix @@ -0,0 +1,14 @@ +{ 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"; + }; +} From 6bfbf544c5868978f6a79da75e2e7699a57d7fdb Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 12 Jun 2022 05:31:45 +0000 Subject: [PATCH 25/55] Add tailscale helpers --- home/xonsh.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home/xonsh.nix b/home/xonsh.nix index 7b7ccc2..b4a3187 100644 --- a/home/xonsh.nix +++ b/home/xonsh.nix @@ -42,6 +42,8 @@ in { molcol = "molecule -c ../../tests/molecule.yml"; pa = "cd ~/src/packaging"; dirflake = "nix flake new -t github:nix-community/nix-direnv"; + tsup = "tailscale up"; + tspub = "tailscale up --exit-node=linode"; }; configHeader = '' From 076f9cb7edfdc1294401419dafce9a58041bb3fd Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 12 Jun 2022 00:50:26 -0500 Subject: [PATCH 26/55] Setup tailscale more better --- home/xonsh.nix | 4 ++-- hosts/jude/default.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/home/xonsh.nix b/home/xonsh.nix index b4a3187..20564a9 100644 --- a/home/xonsh.nix +++ b/home/xonsh.nix @@ -42,8 +42,8 @@ in { molcol = "molecule -c ../../tests/molecule.yml"; pa = "cd ~/src/packaging"; dirflake = "nix flake new -t github:nix-community/nix-direnv"; - tsup = "tailscale up"; - tspub = "tailscale up --exit-node=linode"; + tsup = "sudo tailscale up"; + tspub = "sudo tailscale up --exit-node=linode"; }; configHeader = '' diff --git a/hosts/jude/default.nix b/hosts/jude/default.nix index 188af78..d85e8a1 100644 --- a/hosts/jude/default.nix +++ b/hosts/jude/default.nix @@ -9,6 +9,6 @@ ./virt.nix ]; networking.hostName = "jude"; - services.tailscale.enable = true; + greg.tailscale.enable = true; greg.gnome.enable= true; } From 56065e2f15b07c554e2fbdac02c0b53b24f4f214 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 12 Jun 2022 00:56:46 -0500 Subject: [PATCH 27/55] Add more aliases --- home/xonsh.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home/xonsh.nix b/home/xonsh.nix index 20564a9..77e2e51 100644 --- a/home/xonsh.nix +++ b/home/xonsh.nix @@ -44,6 +44,8 @@ in { dirflake = "nix flake new -t github:nix-community/nix-direnv"; tsup = "sudo tailscale up"; tspub = "sudo tailscale up --exit-node=linode"; + tsclear = "sudo tailscale up --exit-node=''"; + rebuild = "sudo nixos-rebuild switch"; }; configHeader = '' From 86c73cfe56079d154451a2a28bc148901be9b6d6 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Mon, 13 Jun 2022 16:14:20 +0000 Subject: [PATCH 28/55] Convert syncthing to root --- profiles/base/syncthing.nix | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/profiles/base/syncthing.nix b/profiles/base/syncthing.nix index 5058476..dc46abc 100644 --- a/profiles/base/syncthing.nix +++ b/profiles/base/syncthing.nix @@ -10,9 +10,9 @@ in { services.syncthing = { enable = true; - user = "greg"; - group = "users"; - dataDir = "/home/greg/sync"; + user = "root"; + group = "root"; + dataDir = "/root/sync"; devices = { nas = { addresses = [ @@ -32,14 +32,7 @@ in addresses = [ "tcp://linode.thehellings.com:22000" ]; - id = "3PHWAI5-ILAWGGD-S5FC5QM-M2WQ2FX-PZ3IXQF-QVRKANG-WXAACJC-2MZN3Q5"; - }; - }; - folders = { - "mkrvy-tc6x9" = { - enable = true; - path = "/home/greg/drive"; - devices = syncs; + id = "ROZPUG5-G4IAXYA-JNRQXRD-5PFU2BQ-WVJTOGZ-DFMGJ5E-Q4IGXCJ-JHSNDQ6"; }; }; }; From 495e471d6138db0ecb85296d69c97c5fbc2dc90f Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Mon, 13 Jun 2022 16:14:41 +0000 Subject: [PATCH 29/55] Add another tailscale helper --- home/xonsh.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/home/xonsh.nix b/home/xonsh.nix index 77e2e51..336d280 100644 --- a/home/xonsh.nix +++ b/home/xonsh.nix @@ -44,6 +44,7 @@ in { dirflake = "nix flake new -t github:nix-community/nix-direnv"; tsup = "sudo tailscale up"; tspub = "sudo tailscale up --exit-node=linode"; + tshome = "sudo tailscale up --exit-node=2maccabees"; tsclear = "sudo tailscale up --exit-node=''"; rebuild = "sudo nixos-rebuild switch"; }; From 360562c2f3aa8f84a4159f47de84d6a9dfd330e9 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Mon, 13 Jun 2022 16:15:02 +0000 Subject: [PATCH 30/55] More targeted postgres backups --- hosts/linode/postgres.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hosts/linode/postgres.nix b/hosts/linode/postgres.nix index c8f9780..319c962 100644 --- a/hosts/linode/postgres.nix +++ b/hosts/linode/postgres.nix @@ -27,7 +27,13 @@ root root postgres ''; }; - services.postgresqlBackup.enable = true; + services.postgresqlBackup = { + enable = true; + databases = [ + "nextcloud" + "matrix-synapse" + ]; + }; services.logrotate = { enable = true; From a9d53720027e071337d3265ad1518fc2581a16c6 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Mon, 13 Jun 2022 16:16:07 +0000 Subject: [PATCH 31/55] Add more DNS entries --- hosts/2maccabees/dnsmasq.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hosts/2maccabees/dnsmasq.nix b/hosts/2maccabees/dnsmasq.nix index 4c84e8b..f6a37b5 100644 --- a/hosts/2maccabees/dnsmasq.nix +++ b/hosts/2maccabees/dnsmasq.nix @@ -5,11 +5,13 @@ let "10.42.0.1 switch" "10.42.1.1 router" "10.42.1.2 dns dns.thehellings.lan smart smart.thehellings.lan" - "100.99.244.92 dns.me.ts" "10.42.1.3 printer" "10.42.1.4 chronicles nas" - "100.119.228.115 nas.me.ts" "10.42.1.12 tv" + "100.99.244.92 2maccabees.me.ts dns.me.ts" + "100.119.228.115 chronicles.me.ts nas.me.ts" + "100.90.74.19 jude.me.ts" + "100.115.57.8 linode.me.ts" ]; extraConfig = builtins.concatStringsSep "\n" [ From 818c797903dc8b8ff1f490f973521c2016230ec0 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 22 Jun 2022 11:00:41 -0500 Subject: [PATCH 32/55] Update xonsh-direnv --- overlays/xonsh-direnv.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/overlays/xonsh-direnv.nix b/overlays/xonsh-direnv.nix index 79afcad..07d57a5 100644 --- a/overlays/xonsh-direnv.nix +++ b/overlays/xonsh-direnv.nix @@ -2,11 +2,11 @@ buildPythonPackage rec { pname = "xonsh-direnv"; - version = "1.5.0"; + version = "1.6.1"; src = fetchPypi { inherit pname version; - sha256 = "OLjtGD2lX4Yf3aHrxCWmAbSPZnf8OuVrBu0VFbsna1Y="; + sha256 = "Nt8Da1EtMVWZ9mbBDjys7HDutLYifwoQ1HVmI5CN2Ww="; }; meta = with lib; { From 944ad44a58e02c070b706e14cd1feadd6ba9bb91 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 22 Jun 2022 11:00:58 -0500 Subject: [PATCH 33/55] Use Bitwarden FF plugin --- home/gui/firefox.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/gui/firefox.nix b/home/gui/firefox.nix index d5513a0..d1b97c7 100644 --- a/home/gui/firefox.nix +++ b/home/gui/firefox.nix @@ -19,7 +19,7 @@ in with lib; }; }; extensions = with pkgs.nur.repos.rycee.firefox-addons; [ - keepassxc-browser + bitwarden octotree refined-github tree-style-tab From 1c67ef4fa0945b76bdcd98b5105255aeb404e3af Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Mon, 1 Aug 2022 21:46:23 -0500 Subject: [PATCH 34/55] Custom ISO based on Calamares --- hosts/iso/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts/iso/default.nix b/hosts/iso/default.nix index 23333be..18535c8 100644 --- a/hosts/iso/default.nix +++ b/hosts/iso/default.nix @@ -2,7 +2,7 @@ { imports = [ - "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-base.nix" + "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares-gnome.nix" ]; networking.networkmanager.enable = lib.mkForce false; From 8c69ccd3b2ad86dc2fd47bd9e1d952cd52c97a20 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Mon, 1 Aug 2022 21:47:13 -0500 Subject: [PATCH 35/55] Ignore result build --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c70dc2d..0d96e93 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ host +result From 78704b5c882084ffe58b4aed2e94c814de1e161e Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Tue, 2 Aug 2022 01:50:50 -0500 Subject: [PATCH 36/55] Convert home-manager to flakes Instead of calling the home manager directly in the user's list, we add a command for the user to invoke "hms" and have their environment setup in the way that Greg likes. --- flake.lock | 10 +++++----- flake.nix | 14 +++++++++----- home/default.nix | 35 +++++++++++++++++++++++++++++++++++ home/home.nix | 11 ++++++----- home/xonsh.nix | 6 ++---- hosts/jude/boot.nix | 6 ++++++ overlays/default.nix | 4 ++++ overlays/hms.nix | 20 ++++++++++++++++++++ profiles/base/default.nix | 7 +++++++ profiles/base/programs.nix | 1 + 10 files changed, 95 insertions(+), 19 deletions(-) create mode 100644 home/default.nix create mode 100644 overlays/hms.nix diff --git a/flake.lock b/flake.lock index a11ff8a..ed6b921 100644 --- a/flake.lock +++ b/flake.lock @@ -87,13 +87,13 @@ "type": "github" } }, - "nur": { + "nurpkgs": { "locked": { - "lastModified": 1654123271, - "narHash": "sha256-xM85/VFYu8I8jZiZ7U0CmZO/98sHO7+f7PIMxQVZXCM=", + "lastModified": 1659413279, + "narHash": "sha256-7tCR//2NnB1Xw2AqK0RTYJH9YcAEKHmhiSAYsBbQp8s=", "owner": "nix-community", "repo": "NUR", - "rev": "4c83235ccca7cfcf34fee9f49023f21c0e9db128", + "rev": "9bedf12848954098f5298215b3a06b5eb2983058", "type": "github" }, "original": { @@ -108,7 +108,7 @@ "home-manager": "home-manager", "nixpkgs": "nixpkgs_2", "nixunstable": "nixunstable", - "nur": "nur" + "nurpkgs": "nurpkgs" } } }, diff --git a/flake.nix b/flake.nix index b90f021..1180306 100644 --- a/flake.nix +++ b/flake.nix @@ -12,15 +12,15 @@ url = "github:nix-community/home-manager/release-22.05"; inputs.nixpkgs.follows = "nixpkgs"; }; - nur.url = "github:nix-community/NUR"; + nurpkgs.url = "github:nix-community/NUR"; }; - outputs = {nixpkgs, nixunstable, agenix, home-manager, nur, self}@inputs: + outputs = {nixpkgs, nixunstable, agenix, home-manager, nurpkgs, self}@inputs: let local_overlay = import ./overlays; mods = hostname: [ - { nixpkgs.overlays = [ nur.overlay local_overlay ]; } + { nixpkgs.overlays = [ nurpkgs.overlay local_overlay ]; } agenix.nixosModule ./modules ./profiles/base @@ -28,8 +28,6 @@ home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - home-manager.users.greg = import ./home/home.nix "greg"; - home-manager.users.root = import ./home/home.nix "root"; home-manager.extraSpecialArgs = { inherit nixunstable; }; @@ -54,5 +52,11 @@ }; defaultPackage."x86_64-linux" = inputs.self.nixosConfigurations.iso.config.system.build.isoImage; + + homeConfigurations = ( + import ./home { + inherit nixpkgs nixunstable agenix home-manager nurpkgs; + } + ); }; } diff --git a/home/default.nix b/home/default.nix new file mode 100644 index 0000000..ec0ed68 --- /dev/null +++ b/home/default.nix @@ -0,0 +1,35 @@ +{ nixpkgs, nurpkgs, home-manager, username ? builtins.getEnv "USER", ... }: + +let + homeDirectory = if username == "root" then "/root" else "/home/${username}"; + configDir = "${homeDirectory}/.config"; + + pkgs = import nixpkgs { + config.allowUnfree = true; + config.xdg.configHome = configDir; + overlays = [ + nurpkgs.overlay + (import ../overlays) + ]; + }; + + nur = import nurpkgs { + inherit pkgs; + nur = pkgs; + }; + + mkhome = system: gui: + home-manager.lib.homeManagerConfiguration rec { + inherit pkgs system username homeDirectory; + stateVersion = "22.05"; + configuration = import ./home.nix username { + inherit nur pkgs gui; + inherit (pkgs) config lib stdenv; + }; + }; +in { + "aarch64-gui" = mkhome "aarch64-linux" true; + "aarch64-nogui" = mkhome "aarch64-linux" false; + "x86_64-gui" = mkhome "x86_64-linux" true; + "x86_64-nogui" = mkhome "x86_64-linux" false; +} diff --git a/home/home.nix b/home/home.nix index 55fc169..50b7f6f 100644 --- a/home/home.nix +++ b/home/home.nix @@ -1,7 +1,7 @@ -name: { pkgs, lib, nixosConfig, ...}: +name: { pkgs, lib, gui, ...}: let - guiImports = if nixosConfig.greg.gnome.enable then + guiImports = if gui then [ ./gui ] else []; in { @@ -17,7 +17,8 @@ in { ] ++ guiImports; - home.username = name; - home.homeDirectory = if name == "root" then "/root" else "/home/${name}"; - home.stateVersion = "21.11"; + home.stateVersion = "22.05"; + home.packages = [ + pkgs.hms + ]; } diff --git a/home/xonsh.nix b/home/xonsh.nix index 336d280..aafa96a 100644 --- a/home/xonsh.nix +++ b/home/xonsh.nix @@ -1,8 +1,6 @@ -{ pkgs, config, nixosConfig, lib, ... }: +{ pkgs, config, lib, ... }: -let - enable = nixosConfig.greg.gnome.enable; -in { +{ programs.xonsh = { enable = true; diff --git a/hosts/jude/boot.nix b/hosts/jude/boot.nix index 65f8ae9..f01208d 100644 --- a/hosts/jude/boot.nix +++ b/hosts/jude/boot.nix @@ -4,6 +4,12 @@ # Use the systemd-boot EFI boot loader. #boot.loader.systemd-boot.enable = true; boot.loader.grub.device = "/dev/nvme0n1"; + boot.loader.grub.useOSProber = true; + boot.loader.grub.extraEntries = '' + menuentry "Windows" { + chainloader (hd0,2)+1 + } + ''; boot.loader.efi.canTouchEfiVariables = true; networking.interfaces.enp4s0.useDHCP = true; } diff --git a/overlays/default.nix b/overlays/default.nix index 080869d..e228946 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -8,4 +8,8 @@ self: super: xonsh = super.xonsh.overridePythonAttrs (old: rec{ propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.xonsh-direnv ]; }); + + hms = super.callPackage ./hms.nix { + pkgs = self.pkgs; + }; } diff --git a/overlays/hms.nix b/overlays/hms.nix new file mode 100644 index 0000000..b3cefb1 --- /dev/null +++ b/overlays/hms.nix @@ -0,0 +1,20 @@ +{ pkgs, ... }: + +pkgs.writeShellScriptBin "hms" '' +set -eo pipefail +# Build different targets with GUI or not +if [ -z "$DISPLAY" ]; then + target="nogui" +else + target="gui" +fi + +# Build and switch +echo "Building $(uname -m)-$target" +dest=$(mktemp -d) +pushd "$dest" > /dev/null +nix build --impure /etc/nixos#homeConfigurations.$(uname -m)-$target.activationPackage +./result/activate +popd > /dev/null +rm -r "$dest" +'' diff --git a/profiles/base/default.nix b/profiles/base/default.nix index 043fb38..5e6b5b9 100755 --- a/profiles/base/default.nix +++ b/profiles/base/default.nix @@ -27,6 +27,13 @@ ]; }; + users.users.test = { + isNormalUser = true; + createHome = true; + extraGroups = [ ]; + shell = pkgs.xonsh; + }; + i18n.defaultLocale = "en_US.UTF-8"; console = { diff --git a/profiles/base/programs.nix b/profiles/base/programs.nix index 06afebb..f2f273a 100644 --- a/profiles/base/programs.nix +++ b/profiles/base/programs.nix @@ -15,6 +15,7 @@ in { git gnupatch findutils + hms # My own home manager switcher home-manager htop myPython From f502476e2980fed53bf1c92d52706995cdb8c5bb Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Tue, 2 Aug 2022 01:57:50 -0500 Subject: [PATCH 37/55] Add output overlay --- flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flake.nix b/flake.nix index 1180306..e8c2391 100644 --- a/flake.nix +++ b/flake.nix @@ -58,5 +58,7 @@ inherit nixpkgs nixunstable agenix home-manager nurpkgs; } ); + + overlay = local_overlay; }; } From 6e96c8f5e44e0276682f24cef9f5bbb1c38a1652 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Tue, 2 Aug 2022 12:47:32 -0500 Subject: [PATCH 38/55] Update flake lock --- flake.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index ed6b921..73ba5fd 100644 --- a/flake.lock +++ b/flake.lock @@ -25,11 +25,11 @@ ] }, "locked": { - "lastModified": 1654113405, - "narHash": "sha256-VpK+0QaWG2JRgB00lw77N9TjkE3ec0iMYIX1TzGpxa4=", + "lastModified": 1656169755, + "narHash": "sha256-Nlnm4jeQWEGjYrE6hxi/7HYHjBSZ/E0RtjCYifnNsWk=", "owner": "nix-community", "repo": "home-manager", - "rev": "ac2287df5a2d6f0a44bbcbd11701dbbf6ec43675", + "rev": "4a3d01fb53f52ac83194081272795aa4612c2381", "type": "github" }, "original": { @@ -57,11 +57,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1654005557, - "narHash": "sha256-J6elwUzPoco+r5qWPHhvS2EHVWomUtNcxzkfdAQOwEU=", + "lastModified": 1659342832, + "narHash": "sha256-ePnxG4hacRd6oZMk+YeCSYMNUnHCe+qPLI0/+VaTu48=", "owner": "nixos", "repo": "nixpkgs", - "rev": "08950a6e29cf7bddee466592eb790a417550f7f9", + "rev": "e43cf1748462c81202a32b26294e9f8eefcc3462", "type": "github" }, "original": { @@ -73,11 +73,11 @@ }, "nixunstable": { "locked": { - "lastModified": 1653931853, - "narHash": "sha256-O3wncIouj9x7gBPntzHeK/Hkmm9M1SGlYq7JI7saTAE=", + "lastModified": 1659219666, + "narHash": "sha256-pzYr5fokQPHv7CmUXioOhhzDy/XyWOIXP4LZvv/T7Mk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f1c167688a6f81f4a51ab542e5f476c8c595e457", + "rev": "7b9be38c7250b22d829ab6effdee90d5e40c6e5c", "type": "github" }, "original": { @@ -89,11 +89,11 @@ }, "nurpkgs": { "locked": { - "lastModified": 1659413279, - "narHash": "sha256-7tCR//2NnB1Xw2AqK0RTYJH9YcAEKHmhiSAYsBbQp8s=", + "lastModified": 1659423577, + "narHash": "sha256-i2wSHqFqu4xpBJU/o9SRpQblAHknnEtyeN6Kuq/c1JA=", "owner": "nix-community", "repo": "NUR", - "rev": "9bedf12848954098f5298215b3a06b5eb2983058", + "rev": "0bdb7691364dc93c8f04016c0ed395b675bdc50c", "type": "github" }, "original": { From 5f01e0f24d1bbf7f85d5e70600257d85bcc5c465 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Tue, 2 Aug 2022 16:02:56 -0500 Subject: [PATCH 39/55] Add more DNS paths --- hosts/2maccabees/dnsmasq.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hosts/2maccabees/dnsmasq.nix b/hosts/2maccabees/dnsmasq.nix index 4c84e8b..edf845b 100644 --- a/hosts/2maccabees/dnsmasq.nix +++ b/hosts/2maccabees/dnsmasq.nix @@ -4,12 +4,13 @@ let extraHosts = builtins.concatStringsSep "\n" [ "10.42.0.1 switch" "10.42.1.1 router" - "10.42.1.2 dns dns.thehellings.lan smart smart.thehellings.lan" - "100.99.244.92 dns.me.ts" + "10.42.1.2 2maccabees 2maccabees.thehellings.lan dns dns.thehellings.lan smart smart.thehellings.lan" + "100.99.244.92 dns.me.ts 2maccabees.me.ts smart.me.ts" "10.42.1.3 printer" "10.42.1.4 chronicles nas" "100.119.228.115 nas.me.ts" "10.42.1.12 tv" + "100.90.74.19 jude.me.ts" ]; extraConfig = builtins.concatStringsSep "\n" [ From 0dfd8ef63f8e46906400b4209eddf2314b120d37 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Tue, 2 Aug 2022 16:06:39 -0500 Subject: [PATCH 40/55] Add modules to outputs --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index e8c2391..ee135e9 100644 --- a/flake.nix +++ b/flake.nix @@ -60,5 +60,6 @@ ); overlay = local_overlay; + modules = import ./modules; }; } From c0b639ad1570492aa10f05b96ebb36f8a4dcaa7e Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Tue, 2 Aug 2022 16:28:04 -0500 Subject: [PATCH 41/55] Add ICDM target --- hosts/2maccabees/dnsmasq.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hosts/2maccabees/dnsmasq.nix b/hosts/2maccabees/dnsmasq.nix index edf845b..1c18c66 100644 --- a/hosts/2maccabees/dnsmasq.nix +++ b/hosts/2maccabees/dnsmasq.nix @@ -11,6 +11,8 @@ let "100.119.228.115 nas.me.ts" "10.42.1.12 tv" "100.90.74.19 jude.me.ts" + + "10.42.101.1 icdm.lan wiki.icdm.lan *.icdm.lan" ]; extraConfig = builtins.concatStringsSep "\n" [ From cecc289c6bd0ab49a37d958b5dfaa67e5dcf35ef Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Aug 2022 00:17:46 -0500 Subject: [PATCH 42/55] Add laptop configuration --- configuration.nix | 120 +++++++++++++++++++++++++ flake.nix | 2 + hardware-configuration.nix | 39 ++++++++ hosts/lappy/default.nix | 15 ++++ hosts/lappy/hardware-configuration.nix | 39 ++++++++ 5 files changed, 215 insertions(+) create mode 100644 configuration.nix create mode 100644 hardware-configuration.nix create mode 100644 hosts/lappy/default.nix create mode 100644 hosts/lappy/hardware-configuration.nix diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..98ba06e --- /dev/null +++ b/configuration.nix @@ -0,0 +1,120 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ./profiles/nix.nix + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.efi.efiSysMountPoint = "/boot/efi"; + + networking.hostName = "lappy"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Enable networking + networking.networkmanager.enable = true; + + # Set your time zone. + time.timeZone = "America/Chicago"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.utf8"; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + + # Configure keymap in X11 + services.xserver = { + layout = "us"; + xkbVariant = ""; + }; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.greg = { + isNormalUser = true; + description = "Greg Hellings"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; [ + firefox + # thunderbird + ]; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + git + vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + wget + ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + # services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "22.05"; # Did you read the comment? + +} diff --git a/flake.nix b/flake.nix index ee135e9..0c49f14 100644 --- a/flake.nix +++ b/flake.nix @@ -48,6 +48,8 @@ "jude" = machine "x86_64-linux" "jude"; + "lappy" = machine "x86_64-linux" "lappy"; + "iso" = machine "x86_64-linux" "iso"; }; diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..19de254 --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,39 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "sd_mod" "sr_mod" "rtsx_usb_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/63bcc80e-0501-4aef-bb58-30bb83881055"; + fsType = "ext4"; + }; + + fileSystems."/boot/efi" = + { device = "/dev/disk/by-uuid/C617-B2B1"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/bc4f24a3-5969-4bcb-95f4-f80109e36ebb"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp7s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp6s0.useDHCP = lib.mkDefault true; + + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/lappy/default.nix b/hosts/lappy/default.nix new file mode 100644 index 0000000..fb9dd7e --- /dev/null +++ b/hosts/lappy/default.nix @@ -0,0 +1,15 @@ +{ ... }: + +{ + imports = [ + ./hardware-configuration.nix + ]; + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.efi.efiSysMountPoint = "/boot/efi"; + # Graphics, please + greg.gnome.enable = true; + # Set host name + networking.hostName = "lappy"; +} diff --git a/hosts/lappy/hardware-configuration.nix b/hosts/lappy/hardware-configuration.nix new file mode 100644 index 0000000..19de254 --- /dev/null +++ b/hosts/lappy/hardware-configuration.nix @@ -0,0 +1,39 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "sd_mod" "sr_mod" "rtsx_usb_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/63bcc80e-0501-4aef-bb58-30bb83881055"; + fsType = "ext4"; + }; + + fileSystems."/boot/efi" = + { device = "/dev/disk/by-uuid/C617-B2B1"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/bc4f24a3-5969-4bcb-95f4-f80109e36ebb"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp7s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp6s0.useDHCP = lib.mkDefault true; + + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} From 763e2fd2017cde1ab92594e19c40268d664ced4a Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Aug 2022 00:40:01 -0500 Subject: [PATCH 43/55] Streamline modules and profiles --- flake.nix | 1 - modules/automatic.nix | 12 +++++++++++ {profiles/base => modules/automatic}/nix.nix | 1 + .../base => modules/automatic}/programs.nix | 0 .../base => modules/automatic}/syncthing.nix | 0 .../automatic/users.nix | 21 ------------------- modules/default.nix | 1 + 7 files changed, 14 insertions(+), 22 deletions(-) create mode 100644 modules/automatic.nix rename {profiles/base => modules/automatic}/nix.nix (93%) rename {profiles/base => modules/automatic}/programs.nix (100%) rename {profiles/base => modules/automatic}/syncthing.nix (100%) rename profiles/base/default.nix => modules/automatic/users.nix (86%) mode change 100755 => 100644 diff --git a/flake.nix b/flake.nix index 0c49f14..600512c 100644 --- a/flake.nix +++ b/flake.nix @@ -23,7 +23,6 @@ { nixpkgs.overlays = [ nurpkgs.overlay local_overlay ]; } agenix.nixosModule ./modules - ./profiles/base ./hosts/${hostname} home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; diff --git a/modules/automatic.nix b/modules/automatic.nix new file mode 100644 index 0000000..b8f2f38 --- /dev/null +++ b/modules/automatic.nix @@ -0,0 +1,12 @@ +{ ... }: + +{ + imports = [ + ./automatic/nix.nix + ./automatic/programs.nix + ./automatic/syncthing.nix + ./automatic/users.nix + ]; + # I am a fan of network manager, myself + networking.networkmanager.enable = true; +} diff --git a/profiles/base/nix.nix b/modules/automatic/nix.nix similarity index 93% rename from profiles/base/nix.nix rename to modules/automatic/nix.nix index 3a964da..3d71a48 100644 --- a/profiles/base/nix.nix +++ b/modules/automatic/nix.nix @@ -20,4 +20,5 @@ keep-derivations = true autoOptimiseStore = true; }; nixpkgs.config.allowUnfree = true; + system.stateVersion = "22.05"; } diff --git a/profiles/base/programs.nix b/modules/automatic/programs.nix similarity index 100% rename from profiles/base/programs.nix rename to modules/automatic/programs.nix diff --git a/profiles/base/syncthing.nix b/modules/automatic/syncthing.nix similarity index 100% rename from profiles/base/syncthing.nix rename to modules/automatic/syncthing.nix diff --git a/profiles/base/default.nix b/modules/automatic/users.nix old mode 100755 new mode 100644 similarity index 86% rename from profiles/base/default.nix rename to modules/automatic/users.nix index 5e6b5b9..e9f47a6 --- a/profiles/base/default.nix +++ b/modules/automatic/users.nix @@ -1,16 +1,6 @@ { config, pkgs, agenix, ... }: { - imports = [ - ./nix.nix - ./programs.nix - ./syncthing.nix - ]; - - - # I am a fan of network manager, myself - networking.networkmanager.enable = true; - # Enable the OpenSSH daemon for remote control services.openssh.enable = true; #services.openssh.permitRootLogin = "yes"; @@ -27,21 +17,10 @@ ]; }; - users.users.test = { - isNormalUser = true; - createHome = true; - extraGroups = [ ]; - shell = pkgs.xonsh; - }; - i18n.defaultLocale = "en_US.UTF-8"; console = { font = "Lat2-Terminus16"; keyMap = "us"; }; - - # The set of default values, which allow syou to keep system defaults set - # to a predictable value as you upgrade the system - system.stateVersion = "21.11"; } diff --git a/modules/default.nix b/modules/default.nix index 2a2d0c4..f39ef20 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -2,6 +2,7 @@ { imports = [ + ./automatic.nix ./home.nix ./gnome.nix ./linode.nix From 36e370fb73d2f6eccd340c72e9f3866ff304fee3 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 13 Aug 2022 00:42:30 -0500 Subject: [PATCH 44/55] Default configuration.nix file --- configuration.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.nix b/configuration.nix index 98ba06e..f860526 100644 --- a/configuration.nix +++ b/configuration.nix @@ -8,7 +8,7 @@ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ./profiles/nix.nix + ./modules/automatic/nix.nix ]; # Bootloader. From 46630f69bc610c1274351148d779cce2864200ac Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 19 Aug 2022 10:17:23 -0500 Subject: [PATCH 45/55] Synology plus Gnome oneline --- home/gui/default.nix | 1 + modules/gnome.nix | 38 ++++++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/home/gui/default.nix b/home/gui/default.nix index 4ee5a48..7e39d17 100644 --- a/home/gui/default.nix +++ b/home/gui/default.nix @@ -10,5 +10,6 @@ home.packages = with pkgs; [ bitwarden onlyoffice-bin + synology-drive-client ]; } diff --git a/modules/gnome.nix b/modules/gnome.nix index 45cd953..dbea52a 100644 --- a/modules/gnome.nix +++ b/modules/gnome.nix @@ -12,13 +12,28 @@ in with lib; { 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; + 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; @@ -35,14 +50,5 @@ in with lib; { gnomeExtensions.appindicator gnomeExtensions.dash-to-dock ]; - - services.udev.packages = with pkgs; [ - gnome3.gnome-settings-daemon - ]; - - services.pipewire.enable = true; - - # Enablement for Firefox - services.gnome.chrome-gnome-shell.enable = true; }; } From 2681a2f58e153fe2976e8cb54ef853063a0d4cbc Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 19 Aug 2022 10:55:21 -0500 Subject: [PATCH 46/55] VLC and associated bits --- home/gui/default.nix | 1 + home/home.nix | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/home/gui/default.nix b/home/gui/default.nix index 7e39d17..0cf4a31 100644 --- a/home/gui/default.nix +++ b/home/gui/default.nix @@ -11,5 +11,6 @@ bitwarden onlyoffice-bin synology-drive-client + vlc ]; } diff --git a/home/home.nix b/home/home.nix index 50b7f6f..b9e007d 100644 --- a/home/home.nix +++ b/home/home.nix @@ -18,7 +18,11 @@ in { home.stateVersion = "22.05"; - home.packages = [ - pkgs.hms + home.packages = with pkgs; [ + cdrtools + ffmpeg + hms + libtheora + x265 ]; } From cf6ccf2bf714e16beee53ea8ac7fee3a0ca398cb Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 21 Aug 2022 21:57:29 -0500 Subject: [PATCH 47/55] Add handbrake and other tools --- home/gui/default.nix | 1 + modules/gnome.nix | 3 +++ 2 files changed, 4 insertions(+) diff --git a/home/gui/default.nix b/home/gui/default.nix index 0cf4a31..54ae780 100644 --- a/home/gui/default.nix +++ b/home/gui/default.nix @@ -9,6 +9,7 @@ home.packages = with pkgs; [ bitwarden + handbrake onlyoffice-bin synology-drive-client vlc diff --git a/modules/gnome.nix b/modules/gnome.nix index dbea52a..b168e8e 100644 --- a/modules/gnome.nix +++ b/modules/gnome.nix @@ -47,7 +47,10 @@ in with lib; { # 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 ]; }; From cd70ac57c62f14dbe1c9abeee542e8158206c81a Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 24 Aug 2022 03:08:15 +0000 Subject: [PATCH 48/55] Do backups directly --- .gitattributes | 1 + hosts/linode/default.nix | 1 + hosts/linode/nextcloud.nix | 8 +-- hosts/linode/postgres.nix | 14 +++-- hosts/linode/ssh/id_ed25519 | 9 +++ hosts/linode/ssh/id_ed25519.pub | 3 + modules/backup.nix | 107 ++++++++++++++++++++++++++++++++ modules/default.nix | 1 + profiles/base/syncthing.nix | 13 +++- 9 files changed, 145 insertions(+), 12 deletions(-) create mode 100644 hosts/linode/ssh/id_ed25519 create mode 100644 hosts/linode/ssh/id_ed25519.pub create mode 100644 modules/backup.nix diff --git a/.gitattributes b/.gitattributes index 6d34fee..6f6b429 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ #pattern filter=crypt diff=crypt **/*.crypt filter=crypt diff=crypt home/ssh/id_rsa* filter=crypt diff=crypt +hosts/linode/ssh/id_* filter=crypt diff=crypt diff --git a/hosts/linode/default.nix b/hosts/linode/default.nix index ae0a13c..a947538 100644 --- a/hosts/linode/default.nix +++ b/hosts/linode/default.nix @@ -11,6 +11,7 @@ greg.home = false; greg.linode.enable = true; greg.tailscale.enable = true; + greg.backup.key = ./ssh/id_ed25519; networking.hostName = "linode"; networking.domain = "thehellings.com"; } diff --git a/hosts/linode/nextcloud.nix b/hosts/linode/nextcloud.nix index 068ec5a..9a87315 100644 --- a/hosts/linode/nextcloud.nix +++ b/hosts/linode/nextcloud.nix @@ -25,9 +25,9 @@ enableACME = true; }; - services.syncthing.folders."nextcloud-backup" = { - path = "${config.services.nextcloud.datadir}"; - enable = true; - devices = [ "nas" ]; + greg.backup.jobs.nextcloud = { + src = "/var/lib/nextcloud"; + dest = "nextcloud-backup"; + user = "nextcloud"; }; } diff --git a/hosts/linode/postgres.nix b/hosts/linode/postgres.nix index 319c962..df3a507 100644 --- a/hosts/linode/postgres.nix +++ b/hosts/linode/postgres.nix @@ -38,16 +38,20 @@ root root postgres services.logrotate = { enable = true; settings = { - postgres = { + postgresBackup = { enable = true; files = "${config.services.postgresqlBackup.location}/*.gz"; }; + postgresLog = { + enable = true; + files = "/var/lib/postgresql/*/log/*.log"; + }; }; }; - services.syncthing.folders."postgres-backups" = { - path = "${config.services.postgresqlBackup.location}"; - enable = true; - devices = [ "nas" ]; + greg.backup.jobs.postgresql = { + src = "/var/backup/postgresql"; + dest = "linode-postgres"; + user = "postgres"; }; } diff --git a/hosts/linode/ssh/id_ed25519 b/hosts/linode/ssh/id_ed25519 new file mode 100644 index 0000000..5cf4acf --- /dev/null +++ b/hosts/linode/ssh/id_ed25519 @@ -0,0 +1,9 @@ +U2FsdGVkX1+5xhF/T+xJUHDp5c4sT1d0SHp/bwqJ0WXOsiCv7pGNuDBVV1rhItct +tRnfR7OKwrfK7DXFCTNJkcYhnNwma8ZBurmFCwMpAC6sXGhEIoxHNkWezjlGnZja +k1cVx8R17Eg4/3jzKPyaCGv1kZ9Nhxg8aHtXP5ow2e6C0dzkQaq3j9QEVjRUm+tf +JY4Aetg+ySXvKVfdj0JnSkAu4k8IznxzEqzkdF7gcTdiYJo54VQXzupAjwe6BBrh ++ncgfBWaFOfq9Jiawh8HFFm48cOwsKh3+18itI9t8snhyANFj3pFiTsoCZBdYIxR +UwbfcRjDsyplCpwQNZaioe3bh/UMOZsFrUm4Ch8kR6nbJjfonl4nmnrSLHCY9lrn +QWscukwrLcwsAh4B0q0bhUPa3qCj9KQyml/iSKbOboIigbPu9IhFCP23POnFl0Rc +ehf+WQ+xtu49YPbvGjn6lhklHMDlJAM3HGp+/7c0b0VQ98ZzRBjqmIsrDmVKR9ba +1lVm6C+ootFhXrTrejFh4zmMSynL3P179d9O0936uY4= diff --git a/hosts/linode/ssh/id_ed25519.pub b/hosts/linode/ssh/id_ed25519.pub new file mode 100644 index 0000000..26d8d1d --- /dev/null +++ b/hosts/linode/ssh/id_ed25519.pub @@ -0,0 +1,3 @@ +U2FsdGVkX1/RfYko8CbloOVbd2J9+eCw/UuUw8YJ0Rm/G/yUZNeLU2yngUky/vsk +XxXZBVO+ScNGwgzvb4iDqx01szQtrT8cIpkhaetyUY11CLEgPr8fbcHX/XOfGctV +bUnljF9ubnNcmRzAzXjsfQ== diff --git a/modules/backup.nix b/modules/backup.nix new file mode 100644 index 0000000..ebc4a79 --- /dev/null +++ b/modules/backup.nix @@ -0,0 +1,107 @@ +{ 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 0 1 * * ${job.user} ${script}/bin/${binName}"; + }; + +in with lib; { + options = { + greg.backup = { + key = mkOption { + type = types.path; + description = "SSH key to use"; + default = null; + }; + + 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; + }; +} diff --git a/modules/default.nix b/modules/default.nix index 2a2d0c4..a20e178 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -2,6 +2,7 @@ { imports = [ + ./backup.nix ./home.nix ./gnome.nix ./linode.nix diff --git a/profiles/base/syncthing.nix b/profiles/base/syncthing.nix index dc46abc..1bd8471 100644 --- a/profiles/base/syncthing.nix +++ b/profiles/base/syncthing.nix @@ -10,9 +10,9 @@ in { services.syncthing = { enable = true; - user = "root"; - group = "root"; - dataDir = "/root/sync"; + user = "greg"; + group = "users"; + dataDir = "/home/greg/sync"; devices = { nas = { addresses = [ @@ -35,5 +35,12 @@ in id = "ROZPUG5-G4IAXYA-JNRQXRD-5PFU2BQ-WVJTOGZ-DFMGJ5E-Q4IGXCJ-JHSNDQ6"; }; }; + folders = { + "mkrvy-tc6x9" = { + path = "/home/greg/drive"; + enable = true; + devices = syncs; + }; + }; }; } From 63985600a8941310bc5a723b91587e3d6a327ee3 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 24 Aug 2022 04:39:55 +0000 Subject: [PATCH 49/55] Correct DB name to backup --- hosts/linode/postgres.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts/linode/postgres.nix b/hosts/linode/postgres.nix index df3a507..fd2da32 100644 --- a/hosts/linode/postgres.nix +++ b/hosts/linode/postgres.nix @@ -31,7 +31,7 @@ root root postgres enable = true; databases = [ "nextcloud" - "matrix-synapse" + "synapse" ]; }; From 8034f6ab7dfde4077fec08d91b0e12e23ba65940 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Tue, 23 Aug 2022 23:45:12 -0500 Subject: [PATCH 50/55] Add gnucash --- home/gui/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/home/gui/default.nix b/home/gui/default.nix index 54ae780..8ce60ed 100644 --- a/home/gui/default.nix +++ b/home/gui/default.nix @@ -9,6 +9,7 @@ home.packages = with pkgs; [ bitwarden + gnucash handbrake onlyoffice-bin synology-drive-client From 141ac515d9397a16db70ecaa7c2d2d4a937d725c Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 31 Aug 2022 00:27:07 -0500 Subject: [PATCH 51/55] Formatting fix --- home/gui/chat.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/home/gui/chat.nix b/home/gui/chat.nix index 3441407..ffc9f8b 100644 --- a/home/gui/chat.nix +++ b/home/gui/chat.nix @@ -1,5 +1,8 @@ { pkgs, ... }: { - home.packages = [ pkgs.element-desktop pkgs.nheko ]; + home.packages = with pkgs; [ + element-desktop + nheko + ]; } From 4a91f6c6a4be330c8b53704c1a5e40107ec986ca Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 31 Aug 2022 00:27:30 -0500 Subject: [PATCH 52/55] Install Steam --- hosts/jude/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/hosts/jude/default.nix b/hosts/jude/default.nix index d85e8a1..3d80293 100644 --- a/hosts/jude/default.nix +++ b/hosts/jude/default.nix @@ -8,6 +8,7 @@ ./printing.nix ./virt.nix ]; + programs.steam.enable = true; networking.hostName = "jude"; greg.tailscale.enable = true; greg.gnome.enable= true; From 658c478278e816cd84ab68675de8ff28a67d0f55 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 31 Aug 2022 05:58:34 +0000 Subject: [PATCH 53/55] Backup is back up --- modules/backup.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backup.nix b/modules/backup.nix index ebc4a79..789b059 100644 --- a/modules/backup.nix +++ b/modules/backup.nix @@ -30,7 +30,7 @@ ${job.post} ''; in { inherit script; - cron = "0 0 1 * * ${job.user} ${script}/bin/${binName}"; + cron = "0 1 * * * ${job.user} ${script}/bin/${binName}"; }; in with lib; { From 4fabbda1ab9c36b897ed75c04f894dffa386ece3 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Mon, 5 Sep 2022 22:21:57 -0500 Subject: [PATCH 54/55] Expose ZWave JS --- hosts/2maccabees/home-assistant.nix | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/hosts/2maccabees/home-assistant.nix b/hosts/2maccabees/home-assistant.nix index e921121..6db8bf3 100755 --- a/hosts/2maccabees/home-assistant.nix +++ b/hosts/2maccabees/home-assistant.nix @@ -74,19 +74,6 @@ in # directly for troubleshooting Nginx configuration networking.firewall = { enable = true; - allowedTCPPorts = [ 80 8123 ]; - }; - - # No data is secure unless it is backed up! So we back up the data on this node to our NAS using Syncthing, from there we will - # handle things like off site - services.syncthing = { - enable = true; - folders = { - "zwave-live" = { - enable = true; - path = "/var/lib/zwave"; - devices = [ "nas" ]; - }; - }; + allowedTCPPorts = [ 80 8091 8123 ]; }; } From 2ee03640e9fd010cd69a90bbac346e445513d5bc Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Tue, 6 Sep 2022 03:36:59 +0000 Subject: [PATCH 55/55] Move backup key --- .gitattributes | 2 +- hosts/linode/default.nix | 1 - hosts/linode/ssh/id_ed25519 | 9 --------- hosts/linode/ssh/id_ed25519.pub | 3 --- modules/backup.nix | 2 +- modules/ssh/id_ed25519 | 9 +++++++++ modules/ssh/id_ed25519.pub | 3 +++ 7 files changed, 14 insertions(+), 15 deletions(-) delete mode 100644 hosts/linode/ssh/id_ed25519 delete mode 100644 hosts/linode/ssh/id_ed25519.pub create mode 100644 modules/ssh/id_ed25519 create mode 100644 modules/ssh/id_ed25519.pub diff --git a/.gitattributes b/.gitattributes index 6f6b429..3ab6513 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ #pattern filter=crypt diff=crypt **/*.crypt filter=crypt diff=crypt home/ssh/id_rsa* filter=crypt diff=crypt -hosts/linode/ssh/id_* filter=crypt diff=crypt +modules/ssh/id_* filter=crypt diff=crypt diff --git a/hosts/linode/default.nix b/hosts/linode/default.nix index a947538..ae0a13c 100644 --- a/hosts/linode/default.nix +++ b/hosts/linode/default.nix @@ -11,7 +11,6 @@ greg.home = false; greg.linode.enable = true; greg.tailscale.enable = true; - greg.backup.key = ./ssh/id_ed25519; networking.hostName = "linode"; networking.domain = "thehellings.com"; } diff --git a/hosts/linode/ssh/id_ed25519 b/hosts/linode/ssh/id_ed25519 deleted file mode 100644 index 5cf4acf..0000000 --- a/hosts/linode/ssh/id_ed25519 +++ /dev/null @@ -1,9 +0,0 @@ -U2FsdGVkX1+5xhF/T+xJUHDp5c4sT1d0SHp/bwqJ0WXOsiCv7pGNuDBVV1rhItct -tRnfR7OKwrfK7DXFCTNJkcYhnNwma8ZBurmFCwMpAC6sXGhEIoxHNkWezjlGnZja -k1cVx8R17Eg4/3jzKPyaCGv1kZ9Nhxg8aHtXP5ow2e6C0dzkQaq3j9QEVjRUm+tf -JY4Aetg+ySXvKVfdj0JnSkAu4k8IznxzEqzkdF7gcTdiYJo54VQXzupAjwe6BBrh -+ncgfBWaFOfq9Jiawh8HFFm48cOwsKh3+18itI9t8snhyANFj3pFiTsoCZBdYIxR -UwbfcRjDsyplCpwQNZaioe3bh/UMOZsFrUm4Ch8kR6nbJjfonl4nmnrSLHCY9lrn -QWscukwrLcwsAh4B0q0bhUPa3qCj9KQyml/iSKbOboIigbPu9IhFCP23POnFl0Rc -ehf+WQ+xtu49YPbvGjn6lhklHMDlJAM3HGp+/7c0b0VQ98ZzRBjqmIsrDmVKR9ba -1lVm6C+ootFhXrTrejFh4zmMSynL3P179d9O0936uY4= diff --git a/hosts/linode/ssh/id_ed25519.pub b/hosts/linode/ssh/id_ed25519.pub deleted file mode 100644 index 26d8d1d..0000000 --- a/hosts/linode/ssh/id_ed25519.pub +++ /dev/null @@ -1,3 +0,0 @@ -U2FsdGVkX1/RfYko8CbloOVbd2J9+eCw/UuUw8YJ0Rm/G/yUZNeLU2yngUky/vsk -XxXZBVO+ScNGwgzvb4iDqx01szQtrT8cIpkhaetyUY11CLEgPr8fbcHX/XOfGctV -bUnljF9ubnNcmRzAzXjsfQ== diff --git a/modules/backup.nix b/modules/backup.nix index 789b059..f3df0e1 100644 --- a/modules/backup.nix +++ b/modules/backup.nix @@ -39,7 +39,7 @@ in with lib; { key = mkOption { type = types.path; description = "SSH key to use"; - default = null; + default = ./ssh/id_ed25519; }; jobs = mkOption { diff --git a/modules/ssh/id_ed25519 b/modules/ssh/id_ed25519 new file mode 100644 index 0000000..cd9f979 --- /dev/null +++ b/modules/ssh/id_ed25519 @@ -0,0 +1,9 @@ +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= diff --git a/modules/ssh/id_ed25519.pub b/modules/ssh/id_ed25519.pub new file mode 100644 index 0000000..491f4e5 --- /dev/null +++ b/modules/ssh/id_ed25519.pub @@ -0,0 +1,3 @@ +U2FsdGVkX199UgWOiZI4QFCTOsVVEQatJHJFBVDmavrKzuGL+2RX1Fsi1uEafGpz +Fa6UGCWVrUvaT69yxpt3PBtSjkFiZtR9g1A0LzWT3XaUB41/0DJIzAsbK62Ya9UT +A+xICWdf2WVk6n0xeNIvPQ==