From b3c3b00450d15db92ec5a98aaa2082825b84e4df Mon Sep 17 00:00:00 2001 From: greg-compass Date: Tue, 6 Sep 2022 11:41:09 -0500 Subject: [PATCH 01/14] Work is now working --- darwin-configuration.nix | 8 ++++++++ flake.lock | 22 ++++++++++++++++++++++ flake.nix | 21 ++++++++++++++++++++- hosts/work/default.nix | 10 ++++++++++ profiles/darwin/default.nix | 10 ++++++++++ profiles/{base => linux}/default.nix | 5 ++++- profiles/{base => linux}/programs.nix | 0 profiles/{base => linux}/syncthing.nix | 0 profiles/{base => linux}/xonsh.nix | 0 profiles/shared/default.nix | 7 +++++++ profiles/{base => shared}/nix.nix | 3 --- result | 1 + 12 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 darwin-configuration.nix create mode 100644 hosts/work/default.nix create mode 100644 profiles/darwin/default.nix rename profiles/{base => linux}/default.nix (96%) rename profiles/{base => linux}/programs.nix (100%) rename profiles/{base => linux}/syncthing.nix (100%) rename profiles/{base => linux}/xonsh.nix (100%) create mode 100644 profiles/shared/default.nix rename profiles/{base => shared}/nix.nix (80%) create mode 120000 result diff --git a/darwin-configuration.nix b/darwin-configuration.nix new file mode 100644 index 0000000..76dc6b6 --- /dev/null +++ b/darwin-configuration.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + profiles/darwin + hosts/work + ]; +} diff --git a/flake.lock b/flake.lock index 73255af..c5464f9 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,27 @@ "type": "github" } }, + "darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1650976225, + "narHash": "sha256-PGM65SQHS63Dd5MmLJo3GJsZP9lJVZmpWxluQoG1Dt8=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "bb3baef6e115ae47bc2ab4973bd3a486488485b0", + "type": "github" + }, + "original": { + "owner": "lnl7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -74,6 +95,7 @@ "root": { "inputs": { "agenix": "agenix", + "darwin": "darwin", "home-manager": "home-manager", "nixpkgs": "nixpkgs_2" } diff --git a/flake.nix b/flake.nix index 05083f4..8bd302a 100644 --- a/flake.nix +++ b/flake.nix @@ -11,6 +11,10 @@ url = "github:nix-community/home-manager/release-21.11"; inputs.nixpkgs.follows = "nixpkgs"; }; + darwin = { + url = "github:lnl7/nix-darwin/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = inputs: @@ -18,7 +22,7 @@ mods = hostname: [ inputs.agenix.nixosModule ./modules - ./profiles/base + ./profiles/linux ./hosts/${hostname} inputs.home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; @@ -33,6 +37,12 @@ modules = mods name; }; + darwinMods = hostname: [ + inputs.agenix.nixosModule + ./profiles/darwin + ./hosts/${hostname} + ]; + in { nixosConfigurations = { "2maccabees" = machine "aarch64-linux" "2maccabees"; @@ -42,6 +52,15 @@ "iso" = machine "x86_64-linux" "iso"; }; + darwinConfigurations = { + "C02G48H8MD6R" = inputs.darwin.lib.darwinSystem { + system = "x86_64-darwin"; + specialArgs = inputs; + modules = darwinMods "work"; + }; + }; + defaultPackage."x86_64-linux" = inputs.self.nixosConfigurations.iso.config.system.build.isoImage; + defaultPackage."x86_64-darwin" = inputs.self.darwinConfigurations.C02G48H8MD6R.system; }; } diff --git a/hosts/work/default.nix b/hosts/work/default.nix new file mode 100644 index 0000000..d796592 --- /dev/null +++ b/hosts/work/default.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + vim + wget + ]; + + services.nix-daemon.enable = true; +} diff --git a/profiles/darwin/default.nix b/profiles/darwin/default.nix new file mode 100644 index 0000000..334cede --- /dev/null +++ b/profiles/darwin/default.nix @@ -0,0 +1,10 @@ +{ ... }: + +{ + imports = [ + ../shared + ]; + system.stateVersion = 4; + programs.zsh.enable = true; + programs.bash.enable = true; +} diff --git a/profiles/base/default.nix b/profiles/linux/default.nix similarity index 96% rename from profiles/base/default.nix rename to profiles/linux/default.nix index 644d95f..a8feb7b 100755 --- a/profiles/base/default.nix +++ b/profiles/linux/default.nix @@ -2,13 +2,16 @@ { imports = [ - ./nix.nix + ../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; diff --git a/profiles/base/programs.nix b/profiles/linux/programs.nix similarity index 100% rename from profiles/base/programs.nix rename to profiles/linux/programs.nix diff --git a/profiles/base/syncthing.nix b/profiles/linux/syncthing.nix similarity index 100% rename from profiles/base/syncthing.nix rename to profiles/linux/syncthing.nix diff --git a/profiles/base/xonsh.nix b/profiles/linux/xonsh.nix similarity index 100% rename from profiles/base/xonsh.nix rename to profiles/linux/xonsh.nix diff --git a/profiles/shared/default.nix b/profiles/shared/default.nix new file mode 100644 index 0000000..1e6d63c --- /dev/null +++ b/profiles/shared/default.nix @@ -0,0 +1,7 @@ +{ ... }: + +{ + imports = [ + ./nix.nix + ]; +} diff --git a/profiles/base/nix.nix b/profiles/shared/nix.nix similarity index 80% rename from profiles/base/nix.nix rename to profiles/shared/nix.nix index 0b23255..1c9dc17 100644 --- a/profiles/base/nix.nix +++ b/profiles/shared/nix.nix @@ -11,9 +11,6 @@ experimental-features = nix-command flakes min-free = ${toString (1024 * 1024 * 1024) } max-free = ${toString (5 * 1024 * 1024 * 1024) } ''; - - # Use hardlinking instead of copying when possible - autoOptimiseStore = true; }; nixpkgs.config.allowUnfree = true; } diff --git a/result b/result new file mode 120000 index 0000000..8a12386 --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/crvk81fyaw1jhqlylxnjcd2y90xpgalr-darwin-system-21.11.20220418.7b38b03+darwin4.bb3baef \ No newline at end of file From 16e54a97b4ba2deec6d699f2e04971bae15e4611 Mon Sep 17 00:00:00 2001 From: greg-compass Date: Wed, 7 Sep 2022 11:28:09 -0500 Subject: [PATCH 02/14] 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/OrnbJplpaXeRCqnmouJUJhWkaPzawaVyW7dtvprLWcpQtUgTRet18WLyOrLKlq1jwvNRMTPKUJ2IFJMpk2pNEP6bdiUxyMa4vrRIEU2p1zsYSUJpCRLtccZ/i/+yAqwnTA2L5TdAORi9nD2uCdM/Ljz52V3A14QapS6oqcoWx2soWKgnsbVXoG8DxmUTpll77Ze9t7Y5216SMInWuOu0vstP8ZcgFmWsiBgIYIuLA58abWHMxgD251phYidua6R3Gtkf8J/kYqTR1P6eJF1bt5efEg7FD2aL1QQZsYJo3CRNz7yVe1XqMdPbfe2mFXQVF9TDX5x6r9Ir3d0KiEmTlBdByz8nSyPJ8IQxC58NT4LNVQs3p2XH2Zcf6B4JOBSmV4NNBnLseFobsxniWjkWwZigED/D2iu3OXuuhmskCbw0hKy2rBcKffaSNMioVqYIiYNfKlMlSvAacQKqc/1HCpqgX8PwAcSgNSLy4K7/gIrTHmjY+g+CH7onzatWzkLo+0vsZRa/D/qwhhK2CU2FeU07mhnWxWuzqpJuqVaAwDTaEforK7nQUtAOFAZZP6qGhIoqsynYt4THb+QORb3QYfaP0PVgQwXfVU5Q8eUQFZ8A+siPtOASFjDumsIbseB5VzkF+UhvdseJwkX2+4pVFu8eHFDyvArYsHeGK6fBcQGJFQc2jSs6doIP9HD9IO2R ghelling@unknown38BAF87CD102" - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDv26EhyBZS9E5bcuZDHHkh/oeyINHXlsD3OEL1UjZekIsiHoMv2QHYq99cYO/CsTVGcZj4ZTOKxrQQ069Cm1II76nXJP9mb3+jip5QAE/zYSWfxi3SgQum95qmkQsx9mxeKFi4NfUU9qN9vpmJkn0hrvYWg8vU98bcYmkx4RtGW6EgZJed3347EtHshTqq3UfAbj3ErSQdCbEqgNOjokzGWmcx16HyyO5HoQj2FP7PGQmArzMz0V76BRsnpg97CoPKkoWoGk+P13BCWWXR9GCa2PbJ9uprzPa6Ib4+i9RJPdeSkUiLlFi6rBTHaZUT9WUIEaqNSq3bbu1bIqMXkifPeDw7m+TMfOBT8MUBciJaPlPTgXuz3T4kCHBI041hIt+/VqryGtxnT45IavyUaN3JWYntDbpG3eEW4N9IB2oGWuC/XuTJrsUaNpLPpApUKuozxhsFELBRepU+j+Wn4kgJJl8hy0n+WL63ZUee+/F23C7UNXoOc/wU3KbpxO6ipsTSkTzhZpQF2LOuA3JUs5t9ZaiCJ2P9r8axHiphCRcIYSbcCo3pZupf1eTDSXm+x9/UB2sfzErNEH4SdakoSdAi8jG8WhPVOs3BrIXjVBjvyBLeOH86EzBGR/Ba8X6MWoEW9Oau1C3P/z65VH8RHpvPvp6axlMynyVI1ygt5uheuQ== gregory.hellings@C02G48H8MD6R" - ]; - }; - - i18n.defaultLocale = "en_US.UTF-8"; - - console = { - font = "Lat2-Terminus16"; - keyMap = "us"; - }; -} 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"; -} From 4a86e70de43441d4dfcd253ece01666111235a54 Mon Sep 17 00:00:00 2001 From: greg-compass Date: Wed, 7 Sep 2022 20:01:51 -0500 Subject: [PATCH 03/14] Works on Darwin --- flake.lock | 32 +++++++++---------- flake.nix | 9 ++++-- home/gui/chat.nix | 9 +++--- home/gui/default.nix | 18 +++++++---- home/gui/firefox.nix | 15 ++++----- home/gui/terminal.nix | 4 +-- hosts/work/default.nix | 2 -- modules-all/automatic/default.nix | 8 +++++ {modules => modules-all}/automatic/nix.nix | 2 -- .../automatic/programs.nix | 0 modules-all/default.nix | 8 +++++ {modules => modules-all}/xprograms.nix | 0 modules-darwin/default.nix | 10 ++++++ modules-linux/automatic/default.nix | 8 +++++ .../automatic/syncthing.nix | 0 .../automatic/users.nix | 0 {modules => modules-linux}/backup.nix | 0 modules-linux/default.nix | 22 +++++++++++++ {modules => modules-linux}/gnome.nix | 0 {modules => modules-linux}/home.nix | 0 {modules => modules-linux}/linode.nix | 0 modules-linux/linux.nix | 11 +++++++ {modules => modules-linux}/proxy.nix | 0 {modules => modules-linux}/rpi4.nix | 0 {modules => modules-linux}/tailscale.nix | 0 modules/automatic.nix | 10 ------ modules/darwin.nix | 18 ----------- modules/default.nix | 17 ---------- modules/linux.nix | 19 ----------- overlays/hms.nix | 9 +++++- result | 2 +- {modules/ssh => ssh}/id_ed25519 | 0 {modules/ssh => ssh}/id_ed25519.pub | 0 33 files changed, 123 insertions(+), 110 deletions(-) create mode 100644 modules-all/automatic/default.nix rename {modules => modules-all}/automatic/nix.nix (93%) rename {modules => modules-all}/automatic/programs.nix (100%) create mode 100644 modules-all/default.nix rename {modules => modules-all}/xprograms.nix (100%) create mode 100644 modules-darwin/default.nix create mode 100644 modules-linux/automatic/default.nix rename {modules => modules-linux}/automatic/syncthing.nix (100%) rename {modules => modules-linux}/automatic/users.nix (100%) rename {modules => modules-linux}/backup.nix (100%) create mode 100644 modules-linux/default.nix rename {modules => modules-linux}/gnome.nix (100%) rename {modules => modules-linux}/home.nix (100%) rename {modules => modules-linux}/linode.nix (100%) create mode 100644 modules-linux/linux.nix rename {modules => modules-linux}/proxy.nix (100%) rename {modules => modules-linux}/rpi4.nix (100%) rename {modules => modules-linux}/tailscale.nix (100%) delete mode 100644 modules/automatic.nix delete mode 100644 modules/darwin.nix delete mode 100644 modules/default.nix delete mode 100644 modules/linux.nix rename {modules/ssh => ssh}/id_ed25519 (100%) rename {modules/ssh => ssh}/id_ed25519.pub (100%) diff --git a/flake.lock b/flake.lock index cd348f3..e07ee11 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1652712410, - "narHash": "sha256-hMJ2TqLt0DleEnQFGUHK9sV2aAzJPU8pZeiZoqRozbE=", + "lastModified": 1662241716, + "narHash": "sha256-urqPvSvvGUhkwzTDxUI8N1nsdMysbAfjmBNZaTYBZRU=", "owner": "ryantm", "repo": "agenix", - "rev": "7e5e58b98c3dcbf497543ff6f22591552ebfe65b", + "rev": "c96da5835b76d3d8e8d99a0fec6fe32f8539ee2e", "type": "github" }, "original": { @@ -21,15 +21,15 @@ "darwin": { "inputs": { "nixpkgs": [ - "nixpkgs" + "nixunstable" ] }, "locked": { - "lastModified": 1650976225, - "narHash": "sha256-PGM65SQHS63Dd5MmLJo3GJsZP9lJVZmpWxluQoG1Dt8=", + "lastModified": 1662478528, + "narHash": "sha256-Myjd0HPL5lXri3NXOcJ6gP7IKod2eMweQBKM4uxgEGw=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "bb3baef6e115ae47bc2ab4973bd3a486488485b0", + "rev": "3b69bf3cc26ae19de847bfe54d6ab22d7381a90a", "type": "github" }, "original": { @@ -78,11 +78,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1659342832, - "narHash": "sha256-ePnxG4hacRd6oZMk+YeCSYMNUnHCe+qPLI0/+VaTu48=", + "lastModified": 1662099760, + "narHash": "sha256-MdZLCTJPeHi/9fg6R9fiunyDwP3XHJqDd51zWWz9px0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e43cf1748462c81202a32b26294e9f8eefcc3462", + "rev": "67e45078141102f45eff1589a831aeaa3182b41e", "type": "github" }, "original": { @@ -94,11 +94,11 @@ }, "nixunstable": { "locked": { - "lastModified": 1659219666, - "narHash": "sha256-pzYr5fokQPHv7CmUXioOhhzDy/XyWOIXP4LZvv/T7Mk=", + "lastModified": 1662019588, + "narHash": "sha256-oPEjHKGGVbBXqwwL+UjsveJzghWiWV0n9ogo1X6l4cw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7b9be38c7250b22d829ab6effdee90d5e40c6e5c", + "rev": "2da64a81275b68fdad38af669afeda43d401e94b", "type": "github" }, "original": { @@ -110,11 +110,11 @@ }, "nurpkgs": { "locked": { - "lastModified": 1659423577, - "narHash": "sha256-i2wSHqFqu4xpBJU/o9SRpQblAHknnEtyeN6Kuq/c1JA=", + "lastModified": 1662575201, + "narHash": "sha256-hLWrWQ7PRLiKYzYMgICzktqZSN+r7i7zol6UVebn7Rg=", "owner": "nix-community", "repo": "NUR", - "rev": "0bdb7691364dc93c8f04016c0ed395b675bdc50c", + "rev": "8bdab6eab89b870fc90fa0ec766b4e8c0d8c33ba", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index acfb078..b93aceb 100644 --- a/flake.nix +++ b/flake.nix @@ -14,7 +14,7 @@ }; darwin = { url = "github:lnl7/nix-darwin/master"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs.follows = "nixunstable"; }; nurpkgs.url = "github:nix-community/NUR"; }; @@ -26,7 +26,8 @@ mods = hostname: [ { nixpkgs.overlays = [ nurpkgs.overlay local_overlay ]; } agenix.nixosModule - ./modules + ./modules-all + ./modules-linux ./hosts/${hostname} home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; @@ -44,8 +45,10 @@ }; darwinMods = hostname: [ + { nixpkgs.overlays = [ nurpkgs.overlay local_overlay ]; } inputs.agenix.nixosModule - ./modules + ./modules-all + ./modules-darwin ./hosts/${hostname} ]; diff --git a/home/gui/chat.nix b/home/gui/chat.nix index ffc9f8b..a6ec78f 100644 --- a/home/gui/chat.nix +++ b/home/gui/chat.nix @@ -1,8 +1,9 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: { - home.packages = with pkgs; [ + home.packages = with pkgs; ( if ( lib.hasSuffix "-darwin" pkgs.system) then + [] else + [ element-desktop - nheko - ]; + ]); } diff --git a/home/gui/default.nix b/home/gui/default.nix index 8ce60ed..adf2f0e 100644 --- a/home/gui/default.nix +++ b/home/gui/default.nix @@ -8,11 +8,17 @@ ]; home.packages = with pkgs; [ - bitwarden - gnucash - handbrake - onlyoffice-bin synology-drive-client - vlc - ]; + ] ++ ( if pkgs.system == "x86_64-darwin" then + [ + libreoffice-bin + ] else + [ + bitwarden + gnucash + handbrake + onlyoffice-bin + vlc + ] + ); } diff --git a/home/gui/firefox.nix b/home/gui/firefox.nix index d1b97c7..e3974e0 100644 --- a/home/gui/firefox.nix +++ b/home/gui/firefox.nix @@ -1,9 +1,10 @@ { lib, pkgs, ... }: let - ffPkgs = wayland: if wayland - then [ pkgs.firefox-wayland ] - else [ pkgs.firefox ]; + # For now, we ignore this and don't install it + ffPkgs = if ( lib.hasSuffix "-darwin" pkgs.system ) + then pkgs.firefox-unwrapped + else pkgs.firefox-wayland.override { cfg.enableGnomeExtensions = true; }; vars = { MOZ_ENABLE_WAYLAND = "1"; @@ -12,12 +13,8 @@ let in with lib; { programs.firefox = { - enable = true; - package = pkgs.firefox-wayland.override { - cfg = { - enableGnomeExtensions = true; - }; - }; + enable = (if (lib.hasSuffix "-darwin" pkgs.system) then false else true); + package = ffPkgs; extensions = with pkgs.nur.repos.rycee.firefox-addons; [ bitwarden octotree diff --git a/home/gui/terminal.nix b/home/gui/terminal.nix index 7d90605..822b30e 100644 --- a/home/gui/terminal.nix +++ b/home/gui/terminal.nix @@ -1,7 +1,7 @@ -{ ... }: +{ lib, pkgs, ... }: { - programs.gnome-terminal = { + programs.gnome-terminal = lib.mkIf ( pkgs.system != "x86_64-darwin") { enable = true; showMenubar = true; themeVariant = "dark"; diff --git a/hosts/work/default.nix b/hosts/work/default.nix index 2234a8e..a67ca90 100644 --- a/hosts/work/default.nix +++ b/hosts/work/default.nix @@ -1,6 +1,4 @@ { pkgs, ... }: { - services.nix-daemon.enable = true; - greg.darwin = true; } diff --git a/modules-all/automatic/default.nix b/modules-all/automatic/default.nix new file mode 100644 index 0000000..8e990d3 --- /dev/null +++ b/modules-all/automatic/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + ./nix.nix + ./programs.nix + ]; +} diff --git a/modules/automatic/nix.nix b/modules-all/automatic/nix.nix similarity index 93% rename from modules/automatic/nix.nix rename to modules-all/automatic/nix.nix index db570b5..f555dc6 100644 --- a/modules/automatic/nix.nix +++ b/modules-all/automatic/nix.nix @@ -5,8 +5,6 @@ nix = { package = pkgs.nixFlakes; - autoOptimiseStore = true; - # Keep freespace available, at a minimum, and enable Flakes extraOptions = '' experimental-features = nix-command flakes diff --git a/modules/automatic/programs.nix b/modules-all/automatic/programs.nix similarity index 100% rename from modules/automatic/programs.nix rename to modules-all/automatic/programs.nix diff --git a/modules-all/default.nix b/modules-all/default.nix new file mode 100644 index 0000000..c7c9579 --- /dev/null +++ b/modules-all/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + ./automatic + ./xprograms.nix + ]; +} diff --git a/modules/xprograms.nix b/modules-all/xprograms.nix similarity index 100% rename from modules/xprograms.nix rename to modules-all/xprograms.nix diff --git a/modules-darwin/default.nix b/modules-darwin/default.nix new file mode 100644 index 0000000..81c4be2 --- /dev/null +++ b/modules-darwin/default.nix @@ -0,0 +1,10 @@ +{ ... }: + +{ + system.stateVersion = 4; + programs = { + zsh.enable = true; + bash.enable = true; + }; + services.nix-daemon.enable = true; +} diff --git a/modules-linux/automatic/default.nix b/modules-linux/automatic/default.nix new file mode 100644 index 0000000..f20fb29 --- /dev/null +++ b/modules-linux/automatic/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + ./syncthing.nix + ./users.nix + ]; +} diff --git a/modules/automatic/syncthing.nix b/modules-linux/automatic/syncthing.nix similarity index 100% rename from modules/automatic/syncthing.nix rename to modules-linux/automatic/syncthing.nix diff --git a/modules/automatic/users.nix b/modules-linux/automatic/users.nix similarity index 100% rename from modules/automatic/users.nix rename to modules-linux/automatic/users.nix diff --git a/modules/backup.nix b/modules-linux/backup.nix similarity index 100% rename from modules/backup.nix rename to modules-linux/backup.nix diff --git a/modules-linux/default.nix b/modules-linux/default.nix new file mode 100644 index 0000000..9b25e49 --- /dev/null +++ b/modules-linux/default.nix @@ -0,0 +1,22 @@ +{ ... }: + +{ + imports = [ + ./automatic + ./backup.nix + ./gnome.nix + ./home.nix + ./linode.nix + ./linux.nix + ./proxy.nix + ./rpi4.nix + ./tailscale.nix + ]; + + system.stateVersion = "22.05"; + + # I am a fan of network manager, myself + networking.networkmanager.enable = true; + + nix.settings.auto-optimise-store = true; +} diff --git a/modules/gnome.nix b/modules-linux/gnome.nix similarity index 100% rename from modules/gnome.nix rename to modules-linux/gnome.nix diff --git a/modules/home.nix b/modules-linux/home.nix similarity index 100% rename from modules/home.nix rename to modules-linux/home.nix diff --git a/modules/linode.nix b/modules-linux/linode.nix similarity index 100% rename from modules/linode.nix rename to modules-linux/linode.nix diff --git a/modules-linux/linux.nix b/modules-linux/linux.nix new file mode 100644 index 0000000..a5ad118 --- /dev/null +++ b/modules-linux/linux.nix @@ -0,0 +1,11 @@ +{ config, lib, ... }: + +let + cfg = config.greg.linux; + +in with lib; { + options.greg.linux = mkEnableOption "This system is Linux"; + + config = mkIf cfg { + }; +} diff --git a/modules/proxy.nix b/modules-linux/proxy.nix similarity index 100% rename from modules/proxy.nix rename to modules-linux/proxy.nix diff --git a/modules/rpi4.nix b/modules-linux/rpi4.nix similarity index 100% rename from modules/rpi4.nix rename to modules-linux/rpi4.nix diff --git a/modules/tailscale.nix b/modules-linux/tailscale.nix similarity index 100% rename from modules/tailscale.nix rename to modules-linux/tailscale.nix diff --git a/modules/automatic.nix b/modules/automatic.nix deleted file mode 100644 index 2ec9bf1..0000000 --- a/modules/automatic.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ ... }: - -{ - imports = [ - ./automatic/nix.nix - ./automatic/programs.nix - ./automatic/syncthing.nix - # Users imported only for Linux machines - ]; -} diff --git a/modules/darwin.nix b/modules/darwin.nix deleted file mode 100644 index e15893a..0000000 --- a/modules/darwin.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.greg.darwin; - -in with lib; { - options = { - greg.darwin = mkEnableOption "This system is Darwin"; - }; - - config = mkIf cfg { - system.stateVersion = 4; - programs = { - zsh.enable = true; - bash.enable = true; - }; - }; -} diff --git a/modules/default.nix b/modules/default.nix deleted file mode 100644 index 26ee429..0000000 --- a/modules/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ ... }: - -{ - imports = [ - ./automatic.nix - ./backup.nix - ./darwin.nix - ./home.nix - ./gnome.nix - ./linode.nix - ./linux.nix - ./proxy.nix - ./rpi4.nix - ./tailscale.nix - ./xprograms.nix - ]; -} diff --git a/modules/linux.nix b/modules/linux.nix deleted file mode 100644 index 850317f..0000000 --- a/modules/linux.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.greg.linux; - -in with lib; { - options.greg.linux = mkEnableOption "This system is Linux"; - - config = mkIf cfg { - imports = [ - ./automatic/users.nix - ]; - - system.stateVersion = "22.05"; - - # I am a fan of network manager, myself - networking.networkmanager.enable = true; - }; -} diff --git a/overlays/hms.nix b/overlays/hms.nix index b3cefb1..a89d443 100644 --- a/overlays/hms.nix +++ b/overlays/hms.nix @@ -9,11 +9,18 @@ else target="gui" fi +if [ "$(uname -s)" == "Darwin" ]; then + src="$HOME/.config/nix/" + target=gui +else + src=/etc/nixos +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 +nix build --impure "$src#homeConfigurations.$(uname -m)-$target.activationPackage" ./result/activate popd > /dev/null rm -r "$dest" diff --git a/result b/result index 8a12386..ed0f1f7 120000 --- a/result +++ b/result @@ -1 +1 @@ -/nix/store/crvk81fyaw1jhqlylxnjcd2y90xpgalr-darwin-system-21.11.20220418.7b38b03+darwin4.bb3baef \ No newline at end of file +/nix/store/xz2mcip95r90gdahyff2vn87hilw7lhp-darwin-system-22.05.20220801.e43cf17+darwin4.bb3baef \ No newline at end of file diff --git a/modules/ssh/id_ed25519 b/ssh/id_ed25519 similarity index 100% rename from modules/ssh/id_ed25519 rename to ssh/id_ed25519 diff --git a/modules/ssh/id_ed25519.pub b/ssh/id_ed25519.pub similarity index 100% rename from modules/ssh/id_ed25519.pub rename to ssh/id_ed25519.pub From d8dceaaa061d0a6860bb28fef6880166d0f77ac7 Mon Sep 17 00:00:00 2001 From: greg-compass Date: Thu, 8 Sep 2022 10:24:39 -0500 Subject: [PATCH 04/14] Source bash properly --- home/xonsh.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/xonsh.nix b/home/xonsh.nix index 61352b1..1fe2b23 100644 --- a/home/xonsh.nix +++ b/home/xonsh.nix @@ -119,7 +119,7 @@ builtins.true = True builtins.false = False builtins.null = None -if not $__NIX_DARWIN_SET_ENVIRONMENT_DONE: +if '__NIX_DARWIN_SET_ENVIRONMENT_DONE' not in ''${...} or not $__NIX_DARWIN_SET_ENVIRONMENT_DONE: source-bash /etc/bashrc ''; }; From 5912ca4bcc5b465fff88d2b911c62c7551c81f60 Mon Sep 17 00:00:00 2001 From: greg-compass Date: Thu, 8 Sep 2022 10:24:53 -0500 Subject: [PATCH 05/14] Include local SSH config --- home/ssh.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home/ssh.nix b/home/ssh.nix index 56d239a..fcc2d3f 100644 --- a/home/ssh.nix +++ b/home/ssh.nix @@ -5,6 +5,8 @@ enable = true; serverAliveInterval = 60; + includes = ["config.local"]; + matchBlocks = let nas = { user = "admin"; }; From d0a233fed7600987d3a5f55b30527331d876bf3c Mon Sep 17 00:00:00 2001 From: greg-compass Date: Fri, 9 Sep 2022 11:54:18 -0500 Subject: [PATCH 06/14] Be more specific on Darwin --- home/default.nix | 42 +++++++++++++++++++++++++----------------- overlays/hms.nix | 17 ++++++++++------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/home/default.nix b/home/default.nix index ec0ed68..e27b5af 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,25 +1,32 @@ { 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; - }; + home = system: + if username == "root" then "/root" else + ( if ( nixpkgs.lib.hasSuffix "-darwin" system ) then "/Users/${username}" else "/home/${username}" ); mkhome = system: gui: - home-manager.lib.homeManagerConfiguration rec { + let + homeDirectory = home system; + + 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; + }; + + + in home-manager.lib.homeManagerConfiguration rec { inherit pkgs system username homeDirectory; stateVersion = "22.05"; configuration = import ./home.nix username { @@ -32,4 +39,5 @@ in { "aarch64-nogui" = mkhome "aarch64-linux" false; "x86_64-gui" = mkhome "x86_64-linux" true; "x86_64-nogui" = mkhome "x86_64-linux" false; + "x86_64-darwin" = mkhome "x86_64-darwin" true; } diff --git a/overlays/hms.nix b/overlays/hms.nix index a89d443..4f47acc 100644 --- a/overlays/hms.nix +++ b/overlays/hms.nix @@ -3,16 +3,19 @@ pkgs.writeShellScriptBin "hms" '' set -eo pipefail # Build different targets with GUI or not -if [ -z "$DISPLAY" ]; then - target="nogui" -else - target="gui" -fi +arch="$(uname -m)" if [ "$(uname -s)" == "Darwin" ]; then + # On macOS src="$HOME/.config/nix/" - target=gui + target="''${arch}-darwin" else + # On Linux/WSL2 systems + if [ -z "$DISPLAY" ]; then + target="''${arch}-nogui" + else + target="''${arch}-gui" + fi src=/etc/nixos fi @@ -20,7 +23,7 @@ fi echo "Building $(uname -m)-$target" dest=$(mktemp -d) pushd "$dest" > /dev/null -nix build --impure "$src#homeConfigurations.$(uname -m)-$target.activationPackage" +nix build --impure "$src#homeConfigurations.$target.activationPackage" ./result/activate popd > /dev/null rm -r "$dest" From 290914bf59298ec3fba637304129f9918c45d523 Mon Sep 17 00:00:00 2001 From: greg-compass Date: Fri, 9 Sep 2022 13:30:12 -0500 Subject: [PATCH 07/14] Improve Darwin support --- flake.lock | 6 +++--- flake.nix | 7 ++++++- home/xonsh.nix | 10 +++++++++- modules | 1 + modules-all/modules | 1 + overlays/datadog-api-client.nix | 20 ++++++++++++++++++++ overlays/default.nix | 11 ++++++++--- overlays/packages.nix | 18 ++++++++++++++++++ result | 2 +- 9 files changed, 67 insertions(+), 9 deletions(-) create mode 120000 modules create mode 120000 modules-all/modules create mode 100644 overlays/datadog-api-client.nix create mode 100644 overlays/packages.nix diff --git a/flake.lock b/flake.lock index e07ee11..5ad0509 100644 --- a/flake.lock +++ b/flake.lock @@ -110,11 +110,11 @@ }, "nurpkgs": { "locked": { - "lastModified": 1662575201, - "narHash": "sha256-hLWrWQ7PRLiKYzYMgICzktqZSN+r7i7zol6UVebn7Rg=", + "lastModified": 1662716683, + "narHash": "sha256-NU+YC3jT99fp8CPhtm+mgM/c8PP6DwIRzIGkuCO3Vss=", "owner": "nix-community", "repo": "NUR", - "rev": "8bdab6eab89b870fc90fa0ec766b4e8c0d8c33ba", + "rev": "44284844e8329dfd07163965d0b9e2c3192911bc", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index b93aceb..078db4f 100644 --- a/flake.nix +++ b/flake.nix @@ -95,6 +95,11 @@ ); overlay = local_overlay; - modules = import ./modules; + modules = import [ + ./modules-all + ./modules-linux + ./modules-darwin + ]; + packages = import ./overlays/packages.nix { pkgs = nixpkgs; }; }; } diff --git a/home/xonsh.nix b/home/xonsh.nix index 1fe2b23..4e7e963 100644 --- a/home/xonsh.nix +++ b/home/xonsh.nix @@ -44,7 +44,6 @@ 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"; }; configHeader = '' @@ -61,6 +60,14 @@ xontrib load direnv #$GOPATH = $HOME + '/.go' #$JAVA_HOME = '/etc/alternatives/java_sdk' configFooter = '' +def _rebuild(args): + import os + system = os.uname() + if system.sysname == 'Darwin': + darwin-rebuild --flake ~/.config/nix switch + else: + sudo nixos-rebuild switch + def _yaml2json(args, stdin=None, stdout=None): import sys, yaml, json from yaml import CLoader @@ -95,6 +102,7 @@ def _newdock(args): def _unknown_host(args): sed -i -e @(args[0])d ~/.ssh/known_hosts +aliases['rebuild'] = _rebuild aliases['yaml2json'] = _yaml2json aliases['py2env'] = _py2env aliases['py3env'] = _py3env diff --git a/modules b/modules new file mode 120000 index 0000000..89a6caa --- /dev/null +++ b/modules @@ -0,0 +1 @@ +modules-all \ No newline at end of file diff --git a/modules-all/modules b/modules-all/modules new file mode 120000 index 0000000..dc428f0 --- /dev/null +++ b/modules-all/modules @@ -0,0 +1 @@ +modules \ No newline at end of file diff --git a/overlays/datadog-api-client.nix b/overlays/datadog-api-client.nix new file mode 100644 index 0000000..6768563 --- /dev/null +++ b/overlays/datadog-api-client.nix @@ -0,0 +1,20 @@ +{ lib, buildPythonPackage, fetchPypi, pkgs}: + +buildPythonPackage rec { + pname = "datadog-api-client"; + version = "2.3.0"; + + src = fetchPypi { + inherit pname version; + sha256 = ""; + }; + + meta = with lib; { + description = "Datadog API client support"; + homepage = "https://github.com/DataDog/datadog-api-client-python"; + license = licenses.bsd; + maintainers = []; + }; + + doCheck = false; +} diff --git a/overlays/default.nix b/overlays/default.nix index e228946..2296b82 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,15 +1,20 @@ self: super: { - xonsh-direnv = super.callPackage ./xonsh-direnv.nix { + datadog-api-client = super.callPackage ./datadog-api-client.nix { buildPythonPackage = self.python3.pkgs.buildPythonPackage; fetchPypi = self.python.pkgs.fetchPypi; }; + hms = super.callPackage ./hms.nix { + pkgs = self.pkgs; + }; + xonsh = super.xonsh.overridePythonAttrs (old: rec{ propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.xonsh-direnv ]; }); - hms = super.callPackage ./hms.nix { - pkgs = self.pkgs; + xonsh-direnv = super.callPackage ./xonsh-direnv.nix { + buildPythonPackage = self.python3.pkgs.buildPythonPackage; + fetchPypi = self.python.pkgs.fetchPypi; }; } diff --git a/overlays/packages.nix b/overlays/packages.nix new file mode 100644 index 0000000..7ed2db4 --- /dev/null +++ b/overlays/packages.nix @@ -0,0 +1,18 @@ +{ pkgs, ... }: + +{ + datadog-api-client = pkgs.callPackage ./datadog-api-client.nix { + buildPythonPackage = pkgs.python3.pkgs.buildPythonPackage; + fetchPypi = pkgs.python.pkgs.fetchPypi; + }; + + hms = pkgs.callPackage ./hms.nix { + inherit pkgs; + }; + + xonsh-direnv = pkgs.callPackage ./xonsh-direnv.nix { + buildPythonPackage = pkgs.python3.pkgs.buildPythonPackage; + fetchPypi = pkgs.python.pkgs.fetchPypi; + }; + +} diff --git a/result b/result index ed0f1f7..1273b1b 120000 --- a/result +++ b/result @@ -1 +1 @@ -/nix/store/xz2mcip95r90gdahyff2vn87hilw7lhp-darwin-system-22.05.20220801.e43cf17+darwin4.bb3baef \ No newline at end of file +/nix/store/8n593dx13kiqwpkcjjwg98rvwjl14jhy-darwin-system-22.11.20220901.2da64a8+darwin4.3b69bf3 \ No newline at end of file From bc56e1b6384f894bd707ed786cbdb5359a509c9d Mon Sep 17 00:00:00 2001 From: greg-compass Date: Fri, 9 Sep 2022 14:19:12 -0500 Subject: [PATCH 08/14] Fix overlays names --- flake.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 078db4f..ad8851f 100644 --- a/flake.nix +++ b/flake.nix @@ -22,9 +22,16 @@ outputs = {nixpkgs, nixunstable, agenix, home-manager, nurpkgs, self, ...}@inputs: let local_overlay = import ./overlays; + overlays = [ + local_overlay + nurpkgs.overlay + ]; + overlaid = system: import nixpkgs { + inherit overlays system; + }; mods = hostname: [ - { nixpkgs.overlays = [ nurpkgs.overlay local_overlay ]; } + { nixpkgs.overlays = overlays; } agenix.nixosModule ./modules-all ./modules-linux @@ -45,7 +52,7 @@ }; darwinMods = hostname: [ - { nixpkgs.overlays = [ nurpkgs.overlay local_overlay ]; } + { nixpkgs.overlays = overlays; } inputs.agenix.nixosModule ./modules-all ./modules-darwin @@ -94,7 +101,7 @@ } ); - overlay = local_overlay; + overlays = local_overlay; modules = import [ ./modules-all ./modules-linux From efcece0c69d6f08dd7ab7ea1af1ab2aaab5a970a Mon Sep 17 00:00:00 2001 From: greg-compass Date: Fri, 9 Sep 2022 14:36:35 -0500 Subject: [PATCH 09/14] Fix datadog license --- overlays/datadog-api-client.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/overlays/datadog-api-client.nix b/overlays/datadog-api-client.nix index 6768563..64c7a86 100644 --- a/overlays/datadog-api-client.nix +++ b/overlays/datadog-api-client.nix @@ -6,13 +6,13 @@ buildPythonPackage rec { src = fetchPypi { inherit pname version; - sha256 = ""; + sha256 = "CIEQlw8S2lZk1n+ld/Ne7lBx4SKaJZUZfNbw9KvUcjk="; }; meta = with lib; { description = "Datadog API client support"; homepage = "https://github.com/DataDog/datadog-api-client-python"; - license = licenses.bsd; + license = licenses.asl20; maintainers = []; }; From 2e9a2eef7a2a8f26bde71f3be8b1dae66684ca60 Mon Sep 17 00:00:00 2001 From: greg-compass Date: Fri, 9 Sep 2022 14:41:37 -0500 Subject: [PATCH 10/14] Add git dep --- overlays/xonsh-direnv.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/overlays/xonsh-direnv.nix b/overlays/xonsh-direnv.nix index 07d57a5..2d91acf 100644 --- a/overlays/xonsh-direnv.nix +++ b/overlays/xonsh-direnv.nix @@ -17,4 +17,8 @@ buildPythonPackage rec { }; doCheck = false; + + nativeBuildInputs = [ + pkgs.git + ]; } From d20915e43d8735778bcb33e508ea06e68ef6ef7a Mon Sep 17 00:00:00 2001 From: greg-compass Date: Sun, 11 Sep 2022 22:45:11 -0500 Subject: [PATCH 11/14] Fix datadog-api-client package definition --- overlays/datadog-api-client.nix | 20 +++++++++++++++++++- overlays/packages.nix | 11 ++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/overlays/datadog-api-client.nix b/overlays/datadog-api-client.nix index 64c7a86..df815d1 100644 --- a/overlays/datadog-api-client.nix +++ b/overlays/datadog-api-client.nix @@ -1,6 +1,15 @@ { lib, buildPythonPackage, fetchPypi, pkgs}: -buildPythonPackage rec { +let + pydeps = pypkgs: with pypkgs; [ + certifi + dateutils + python-dateutil + typing-extensions + urllib3 + ]; + +in buildPythonPackage rec { pname = "datadog-api-client"; version = "2.3.0"; @@ -17,4 +26,13 @@ buildPythonPackage rec { }; doCheck = false; + + buildInputs = with pkgs; [ + (python3.withPackages pydeps) + ]; + + nativeBuildInputs = with pkgs; [ + (python3.withPackages pydeps) + git + ]; } diff --git a/overlays/packages.nix b/overlays/packages.nix index 7ed2db4..c094ce7 100644 --- a/overlays/packages.nix +++ b/overlays/packages.nix @@ -1,8 +1,13 @@ { pkgs, ... }: -{ - datadog-api-client = pkgs.callPackage ./datadog-api-client.nix { - buildPythonPackage = pkgs.python3.pkgs.buildPythonPackage; +let + callPackage = pkgs.lib.callPackageWith pkgs; + lib = pkgs.lib; + python = pkgs.packages.python3; +in { + datadog-api-client = callPackage ./datadog-api-client.nix { + inherit pkgs lib; + buildPythonPackage = python.pkgs.buildPythonPackage; fetchPypi = pkgs.python.pkgs.fetchPypi; }; From 8e2cd7575f4294ff08b1a3ec99c1016cebc22a85 Mon Sep 17 00:00:00 2001 From: greg-compass Date: Mon, 12 Sep 2022 10:05:07 -0500 Subject: [PATCH 12/14] Darwin updates Add Python modules that are needed for work and other things Move import of Bash into Xonsh to the head in order to avoid issues with being overwritten by Bash defaults --- home/xonsh.nix | 6 +++--- hosts/work/default.nix | 11 +++++++++++ modules-all/automatic/programs.nix | 9 +++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/home/xonsh.nix b/home/xonsh.nix index 4e7e963..9d9f9cd 100644 --- a/home/xonsh.nix +++ b/home/xonsh.nix @@ -47,6 +47,9 @@ }; configHeader = '' +if '__NIX_DARWIN_SET_ENVIRONMENT_DONE' not in ''${...} or not $__NIX_DARWIN_SET_ENVIRONMENT_DONE: + source-bash /etc/bashrc + # set -e == $RAISE_SUBPROC_ERROR = True # set -x == trace on; $XONSH_TRACE_SUBPROC = True # $? == _.rtn @@ -126,9 +129,6 @@ import builtins builtins.true = True builtins.false = False builtins.null = None - -if '__NIX_DARWIN_SET_ENVIRONMENT_DONE' not in ''${...} or not $__NIX_DARWIN_SET_ENVIRONMENT_DONE: - source-bash /etc/bashrc ''; }; } diff --git a/hosts/work/default.nix b/hosts/work/default.nix index a67ca90..a6e6219 100644 --- a/hosts/work/default.nix +++ b/hosts/work/default.nix @@ -1,4 +1,15 @@ { pkgs, ... }: { + #greg.pypackages = with pkgs; [ + # datadog-api-client + # datadog + # dateutil + # ipython + # pyyaml + # responses + # ruamel-yaml + # typing-extensions + # virtualenv + #]; } diff --git a/modules-all/automatic/programs.nix b/modules-all/automatic/programs.nix index f2f273a..55763ae 100644 --- a/modules-all/automatic/programs.nix +++ b/modules-all/automatic/programs.nix @@ -2,7 +2,16 @@ let myPackages = pypackages: with pypackages; [ + pkgs.datadog-api-client pkgs.xonsh-direnv + datadog + dateutil + ipython + pyyaml + responses + ruamel-yaml + typing-extensions + virtualenv ]; myPython = pkgs.python3.withPackages myPackages; From 52e3f7f1ae763d9baa190bcb10a7e1379cac8de9 Mon Sep 17 00:00:00 2001 From: greg-compass Date: Tue, 13 Sep 2022 16:34:05 -0500 Subject: [PATCH 13/14] How did that get added? --- result | 1 - 1 file changed, 1 deletion(-) delete mode 120000 result diff --git a/result b/result deleted file mode 120000 index 1273b1b..0000000 --- a/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/8n593dx13kiqwpkcjjwg98rvwjl14jhy-darwin-system-22.11.20220901.2da64a8+darwin4.3b69bf3 \ No newline at end of file From 538d08a2e8c26eb55e6527d37cbf3573f1f453e0 Mon Sep 17 00:00:00 2001 From: greg-compass Date: Tue, 13 Sep 2022 16:34:22 -0500 Subject: [PATCH 14/14] Add android file transfer for file transfers on Android --- modules-all/automatic/programs.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules-all/automatic/programs.nix b/modules-all/automatic/programs.nix index 55763ae..f4577c0 100644 --- a/modules-all/automatic/programs.nix +++ b/modules-all/automatic/programs.nix @@ -19,6 +19,7 @@ in { # Base packages that need to be in all my hosts environment.systemPackages = with pkgs; [ agenix.defaultPackage."${system}" + android-file-transfer bitwarden-cli diffutils git