From 16e54a97b4ba2deec6d699f2e04971bae15e4611 Mon Sep 17 00:00:00 2001 From: greg-compass Date: Wed, 7 Sep 2022 11:28:09 -0500 Subject: [PATCH] Continue to fix merge --- darwin-configuration.nix | 4 +- flake.nix | 4 +- home/xonsh.nix | 3 + hosts/work/default.nix | 6 +- modules/automatic.nix | 4 +- modules/automatic/nix.nix | 3 +- modules/automatic/users.nix | 21 +----- modules/darwin.nix | 18 +++++ modules/default.nix | 2 + modules/linux.nix | 19 ++++++ nix.conf | 1 + profiles/darwin/default.nix | 10 --- profiles/linux/default.nix | 43 ------------ profiles/linux/programs.nix | 30 --------- profiles/linux/syncthing.nix | 46 ------------- profiles/linux/xonsh.nix | 127 ----------------------------------- profiles/shared/default.nix | 7 -- profiles/shared/nix.nix | 21 ------ 18 files changed, 54 insertions(+), 315 deletions(-) create mode 100644 modules/darwin.nix create mode 100644 modules/linux.nix create mode 100644 nix.conf delete mode 100644 profiles/darwin/default.nix delete mode 100644 profiles/linux/default.nix delete mode 100644 profiles/linux/programs.nix delete mode 100644 profiles/linux/syncthing.nix delete mode 100644 profiles/linux/xonsh.nix delete mode 100644 profiles/shared/default.nix delete mode 100644 profiles/shared/nix.nix diff --git a/darwin-configuration.nix b/darwin-configuration.nix index 76dc6b6..8f2bcdd 100644 --- a/darwin-configuration.nix +++ b/darwin-configuration.nix @@ -2,7 +2,7 @@ { imports = [ - profiles/darwin - hosts/work + ./modules + ./hosts/work ]; } diff --git a/flake.nix b/flake.nix index e4da5fb..acfb078 100644 --- a/flake.nix +++ b/flake.nix @@ -19,7 +19,7 @@ nurpkgs.url = "github:nix-community/NUR"; }; - outputs = {nixpkgs, nixunstable, agenix, home-manager, nurpkgs, self}@inputs: + outputs = {nixpkgs, nixunstable, agenix, home-manager, nurpkgs, self, ...}@inputs: let local_overlay = import ./overlays; @@ -45,7 +45,7 @@ darwinMods = hostname: [ inputs.agenix.nixosModule - ./profiles/darwin + ./modules ./hosts/${hostname} ]; diff --git a/home/xonsh.nix b/home/xonsh.nix index aafa96a..61352b1 100644 --- a/home/xonsh.nix +++ b/home/xonsh.nix @@ -118,6 +118,9 @@ import builtins builtins.true = True builtins.false = False builtins.null = None + +if not $__NIX_DARWIN_SET_ENVIRONMENT_DONE: + source-bash /etc/bashrc ''; }; } diff --git a/hosts/work/default.nix b/hosts/work/default.nix index d796592..2234a8e 100644 --- a/hosts/work/default.nix +++ b/hosts/work/default.nix @@ -1,10 +1,6 @@ { pkgs, ... }: { - environment.systemPackages = with pkgs; [ - vim - wget - ]; - services.nix-daemon.enable = true; + greg.darwin = true; } diff --git a/modules/automatic.nix b/modules/automatic.nix index b8f2f38..2ec9bf1 100644 --- a/modules/automatic.nix +++ b/modules/automatic.nix @@ -5,8 +5,6 @@ ./automatic/nix.nix ./automatic/programs.nix ./automatic/syncthing.nix - ./automatic/users.nix + # Users imported only for Linux machines ]; - # I am a fan of network manager, myself - networking.networkmanager.enable = true; } diff --git a/modules/automatic/nix.nix b/modules/automatic/nix.nix index 2c97556..db570b5 100644 --- a/modules/automatic/nix.nix +++ b/modules/automatic/nix.nix @@ -5,6 +5,8 @@ nix = { package = pkgs.nixFlakes; + autoOptimiseStore = true; + # Keep freespace available, at a minimum, and enable Flakes extraOptions = '' experimental-features = nix-command flakes @@ -17,5 +19,4 @@ keep-derivations = true ''; }; nixpkgs.config.allowUnfree = true; - system.stateVersion = "22.05"; } diff --git a/modules/automatic/users.nix b/modules/automatic/users.nix index 86ef2b9..328baf4 100644 --- a/modules/automatic/users.nix +++ b/modules/automatic/users.nix @@ -1,23 +1,8 @@ -{ config, pkgs, agenix, ... }: +# Only imported from the Linux modules + +{ pkgs, ... }: { -<<<<<<<< HEAD:profiles/linux/default.nix - imports = [ - ../shared - ./programs.nix - ./syncthing.nix - ./xonsh.nix - ]; - - - # Use hardlinking instead of copying when possible - nix.autoOptimiseStore = true; - - # I am a fan of network manager, myself - networking.networkmanager.enable = true; - -======== ->>>>>>>> origin/main:modules/automatic/users.nix # Enable the OpenSSH daemon for remote control services.openssh.enable = true; #services.openssh.permitRootLogin = "yes"; diff --git a/modules/darwin.nix b/modules/darwin.nix new file mode 100644 index 0000000..e15893a --- /dev/null +++ b/modules/darwin.nix @@ -0,0 +1,18 @@ +{ config, lib, ... }: + +let + cfg = config.greg.darwin; + +in with lib; { + options = { + greg.darwin = mkEnableOption "This system is Darwin"; + }; + + config = mkIf cfg { + system.stateVersion = 4; + programs = { + zsh.enable = true; + bash.enable = true; + }; + }; +} diff --git a/modules/default.nix b/modules/default.nix index b766d39..26ee429 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -4,9 +4,11 @@ imports = [ ./automatic.nix ./backup.nix + ./darwin.nix ./home.nix ./gnome.nix ./linode.nix + ./linux.nix ./proxy.nix ./rpi4.nix ./tailscale.nix diff --git a/modules/linux.nix b/modules/linux.nix new file mode 100644 index 0000000..850317f --- /dev/null +++ b/modules/linux.nix @@ -0,0 +1,19 @@ +{ config, lib, ... }: + +let + cfg = config.greg.linux; + +in with lib; { + options.greg.linux = mkEnableOption "This system is Linux"; + + config = mkIf cfg { + imports = [ + ./automatic/users.nix + ]; + + system.stateVersion = "22.05"; + + # I am a fan of network manager, myself + networking.networkmanager.enable = true; + }; +} diff --git a/nix.conf b/nix.conf new file mode 100644 index 0000000..c7d7291 --- /dev/null +++ b/nix.conf @@ -0,0 +1 @@ +experimental-features = nix-command flakes diff --git a/profiles/darwin/default.nix b/profiles/darwin/default.nix deleted file mode 100644 index 334cede..0000000 --- a/profiles/darwin/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ ... }: - -{ - imports = [ - ../shared - ]; - system.stateVersion = 4; - programs.zsh.enable = true; - programs.bash.enable = true; -} diff --git a/profiles/linux/default.nix b/profiles/linux/default.nix deleted file mode 100644 index 86ef2b9..0000000 --- a/profiles/linux/default.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ config, pkgs, agenix, ... }: - -{ -<<<<<<<< HEAD:profiles/linux/default.nix - imports = [ - ../shared - ./programs.nix - ./syncthing.nix - ./xonsh.nix - ]; - - - # Use hardlinking instead of copying when possible - nix.autoOptimiseStore = true; - - # I am a fan of network manager, myself - networking.networkmanager.enable = true; - -======== ->>>>>>>> origin/main:modules/automatic/users.nix - # Enable the OpenSSH daemon for remote control - services.openssh.enable = true; - #services.openssh.permitRootLogin = "yes"; - - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.greg = { - isNormalUser = true; - createHome = true; - extraGroups = [ "wheel" "networkmanager" ]; # Enable ‘sudo’ for the user. - shell = pkgs.xonsh; - openssh.authorizedKeys.keys = [ - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQDLQRq55JKqLifX+31kEXyuoB8gfM+5thAlgR7XLPvvdu6g2a5cCWyozQ1I2oGbPRfJtzcJ5ifM7Ii2PuqAj3MdYFLHBEDOhIpBBWme9Ts2YB9HJ4NorBvB4zEfJd0Q7k2MmylyeBOwdwGz3bVqPRDcJbxWFMDHqr33FEs6SXdfyAQ5SvhWGARI84qz8zUUdOp6M4e3aIGO3cx1gA+YzYQ4FbUtL8+m1NFO8VoNFMZBMf5q0iF/SgEu5bmGWUCePia6DvfeBFQ2/y4Y7WmOj980WE+JmFTkIvmGruMYeGI8FuDQ2JIIIcehddy9bQbPF4VlGnTFsHqJYVRUUWc+vH1cPNMn01oB8s27ogf9e1lyhIN+cZOgp/jDt4eXcO4Wr04uwj7CI6m+d8iMQOa5Jv0hmNgqqiwOMVBlKeo0FCxlovzwvn/Lia9WZ74JqM6JwLCD8SZ0oFgiSIHOTHrQhr7iaCmj7X/0ey7VR8FnCrpeAJpG+ELTfWGshF1d9QR2zW7u4EsXTDLiuOmdJ+/KxwMvjMcWdlg2+Qch6SwulTQRxWaED2IWJo+YiAql8eaiVXu/eZJGLoiskGFZnONoLrzIT4pSjakPlrSpn/M/GkP1pDpaMkr24OhJsGpJNEU3F1ZcOMqy2iJzIxlPmU8Xg0I/OrnbJplpaXeRCqnmouJUJhWkaPzawaVyW7dtvprLWcpQtUgT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T4kCHBI041hIt+/VqryGtxnT45IavyUaN3JWYntDbpG3eEW4N9IB2oGWuC/XuTJrsUaNpLPpApUKuozxhsFELBRepU+j+Wn4kgJJl8hy0n+WL63ZUee+/F23C7UNXoOc/wU3KbpxO6ipsTSkTzhZpQF2LOuA3JUs5t9ZaiCJ2P9r8axHiphCRcIYSbcCo3pZupf1eTDSXm+x9/UB2sfzErNEH4SdakoSdAi8jG8WhPVOs3BrIXjVBjvyBLeOH86EzBGR/Ba8X6MWoEW9Oau1C3P/z65VH8RHpvPvp6axlMynyVI1ygt5uheuQ== gregory.hellings@C02G48H8MD6R" - ]; - }; - - i18n.defaultLocale = "en_US.UTF-8"; - - console = { - font = "Lat2-Terminus16"; - keyMap = "us"; - }; -} diff --git a/profiles/linux/programs.nix b/profiles/linux/programs.nix deleted file mode 100644 index f2f273a..0000000 --- a/profiles/linux/programs.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ pkgs, agenix, ... }: - -let - myPackages = pypackages: with pypackages; [ - pkgs.xonsh-direnv - ]; - - myPython = pkgs.python3.withPackages myPackages; -in { - # Base packages that need to be in all my hosts - environment.systemPackages = with pkgs; [ - agenix.defaultPackage."${system}" - bitwarden-cli - diffutils - git - gnupatch - findutils - hms # My own home manager switcher - home-manager - htop - myPython - pwgen - tmux - transcrypt - unzip - vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - wget - yamllint # Used in vim - ]; -} diff --git a/profiles/linux/syncthing.nix b/profiles/linux/syncthing.nix deleted file mode 100644 index 1bd8471..0000000 --- a/profiles/linux/syncthing.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ ... }: - -let - syncs = [ - "nas" - "dns" - "linode" - ]; -in -{ - services.syncthing = { - enable = true; - user = "greg"; - group = "users"; - dataDir = "/home/greg/sync"; - devices = { - nas = { - addresses = [ - "tcp://nas.thehellings.lan:22000" - "tcp://chronicles.greg-hellings.gmail.com.beta.tailscale.net:22000" - ]; - id = "74JUTZG-77EPGO3-FEYCL2P-CHDWP5G-6EXWZVB-XTAH6O5-TUXCVY2-QNRHSQ4"; - }; - dns = { - addresses = [ - "tcp://dns.thehellings.lan:22000" - "tcp://2maccabees.greg-hellings.gmail.com.beta.tailscale.net:22000" - ]; - id = "C4XJCH7-3ZNW6XZ-R5DB2EU-OEGVVT2-WPHQAG7-UDWER36-6NO5KZR-4MN5VAK"; - }; - linode = { - addresses = [ - "tcp://linode.thehellings.com:22000" - ]; - id = "ROZPUG5-G4IAXYA-JNRQXRD-5PFU2BQ-WVJTOGZ-DFMGJ5E-Q4IGXCJ-JHSNDQ6"; - }; - }; - folders = { - "mkrvy-tc6x9" = { - path = "/home/greg/drive"; - enable = true; - devices = syncs; - }; - }; - }; -} diff --git a/profiles/linux/xonsh.nix b/profiles/linux/xonsh.nix deleted file mode 100644 index 9456475..0000000 --- a/profiles/linux/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 -''; - }; -} diff --git a/profiles/shared/default.nix b/profiles/shared/default.nix deleted file mode 100644 index 1e6d63c..0000000 --- a/profiles/shared/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ ... }: - -{ - imports = [ - ./nix.nix - ]; -} diff --git a/profiles/shared/nix.nix b/profiles/shared/nix.nix deleted file mode 100644 index 2c97556..0000000 --- a/profiles/shared/nix.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ pkgs, ... }: - -{ - # Enable flakes - nix = { - package = pkgs.nixFlakes; - - # Keep freespace available, at a minimum, and enable Flakes - extraOptions = '' -experimental-features = nix-command flakes -min-free = ${toString (1024 * 1024 * 1024) } -max-free = ${toString (5 * 1024 * 1024 * 1024) } - -# Used by direnv -keep-outputs = true -keep-derivations = true -''; - }; - nixpkgs.config.allowUnfree = true; - system.stateVersion = "22.05"; -}