From b3f749f8bf9d605cb12d2017e6913b11fa195cb4 Mon Sep 17 00:00:00 2001 From: Brian Nelson Date: Mon, 9 Nov 2026 10:58:31 -0500 Subject: [PATCH 1/5] restructed modules for home and work, untested --- flake.nix | 34 ++++++++++++------- configuration.nix => modules/base.nix | 21 +++--------- modules/cli-tools.nix | 19 +++++++++++ modules/default.nix | 10 ++++++ mac-settings.nix => modules/mac-settings.nix | 0 pkg-installs.nix => modules/pkg-installs.nix | 0 profiles/personal/apps.nix | 24 +++++++++++++ .../personal/archive-installs.nix | 0 .../personal/cli-tools.nix | 17 ++-------- profiles/personal/default.nix | 9 +++++ profiles/work/apps.nix | 9 +++++ profiles/work/cli-tools.nix | 9 +++++ profiles/work/default.nix | 8 +++++ 13 files changed, 116 insertions(+), 44 deletions(-) rename configuration.nix => modules/base.nix (76%) create mode 100644 modules/cli-tools.nix create mode 100644 modules/default.nix rename mac-settings.nix => modules/mac-settings.nix (100%) rename pkg-installs.nix => modules/pkg-installs.nix (100%) create mode 100644 profiles/personal/apps.nix rename archive-installs.nix => profiles/personal/archive-installs.nix (100%) rename cli-tools.nix => profiles/personal/cli-tools.nix (65%) create mode 100644 profiles/personal/default.nix create mode 100644 profiles/work/apps.nix create mode 100644 profiles/work/cli-tools.nix create mode 100644 profiles/work/default.nix diff --git a/flake.nix b/flake.nix index 28cc09b..2b154d4 100644 --- a/flake.nix +++ b/flake.nix @@ -8,19 +8,29 @@ nix-homebrew.url = "github:zhaofengli/nix-homebrew"; }; - outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, ... }: { + outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, ... }: + let + mkDarwin = { profile, user, system ? "aarch-64-dawin" }: + nix-darwin.lib.darwinSystem { + specialArgs = { inherit user system; }; + modules = [ + ./modules + ./profiles/${profile} + nix-homebrew.darwinModules.nix-homebrew + { + nix-homebrew = { + enable = true; + enableRosetta = true; + user = "briannelson"; + }; + } + ]; + }; + in + { darwinConfigurations."Brians-MacBook-Air" = nix-darwin.lib.darwinSystem { - modules = [ - ./configuration.nix - nix-homebrew.darwinModules.nix-homebrew - { - nix-homebrew = { - enable = true; - enableRosetta = true; - user = "briannelson"; - }; - } - ]; + personal = mkDarwin { profile = "personal"; user = "briannelson"; }; + work = mkDarwin { profile = "work"; user = "briannelson"; }; }; }; } diff --git a/configuration.nix b/modules/base.nix similarity index 76% rename from configuration.nix rename to modules/base.nix index 0d0fc60..6c4070b 100644 --- a/configuration.nix +++ b/modules/base.nix @@ -1,13 +1,12 @@ -{ pkgs, ... }: +{ ... }: { imports = [ ./cli-tools.nix ./mac-settings.nix ./pkg-installs.nix - ./archive-installs.nix - ]; - + ] + nixpkgs.hostPlatform = "aarch64-darwin"; nix.settings.experimental-features = "nix-command flakes"; @@ -18,13 +17,8 @@ environment.systemPackages = with pkgs; [ exif exiftool - ffmpeg - flac git helix - librewolf - tea - yt-dlp ]; homebrew = { @@ -38,22 +32,15 @@ "bun" "defaultbrowser" "harper" - "nicotine-plus" "rust" "ykman" ]; casks = [ "bitwarden" - "cap" - "discord" - "docker-desktop" "harper-desktop" - "libreoffice" "nextcloud" "obsidian" - "protonvpn" - "rustdesk" "signal" "task-manager-tmog" "twingate" @@ -62,4 +49,4 @@ "firefox" ]; }; -} +} \ No newline at end of file diff --git a/modules/cli-tools.nix b/modules/cli-tools.nix new file mode 100644 index 0000000..072d7fb --- /dev/null +++ b/modules/cli-tools.nix @@ -0,0 +1,19 @@ +{ ... }: + +{ + environment.shellAliases = { + ll = "ls -la"; + }; + + environment.etc."gitconfig".text = '' + [user] + name = Brian Nelson + email = brian@briannelson.dev + [init] + defaultBranch = main + [credential] + helper = osxkeychain + ''; + + environment.variables.GIT_CONFIG_SYSTEM = "/etc/gitconfig"; +} \ No newline at end of file diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..afbbf70 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,10 @@ +{ ... }: + +{ + imports = [ + ./base.nix + ./cli-tools.nix + ./mac-settings.nix + ./pkg-installs.nix + ]; +} \ No newline at end of file diff --git a/mac-settings.nix b/modules/mac-settings.nix similarity index 100% rename from mac-settings.nix rename to modules/mac-settings.nix diff --git a/pkg-installs.nix b/modules/pkg-installs.nix similarity index 100% rename from pkg-installs.nix rename to modules/pkg-installs.nix diff --git a/profiles/personal/apps.nix b/profiles/personal/apps.nix new file mode 100644 index 0000000..b09f880 --- /dev/null +++ b/profiles/personal/apps.nix @@ -0,0 +1,24 @@ +{ pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + ffmpeg + flac + librewolf + tea + yt-dlp + ]; + + homebrew.brews = [ + "nicotine-plus" + ]; + + homebrew.casks = [ + "cap" + "discord" + "docker-desktop" + "libreoffice" + "protonvpn" + "rustdesk" + ] +} \ No newline at end of file diff --git a/archive-installs.nix b/profiles/personal/archive-installs.nix similarity index 100% rename from archive-installs.nix rename to profiles/personal/archive-installs.nix diff --git a/cli-tools.nix b/profiles/personal/cli-tools.nix similarity index 65% rename from cli-tools.nix rename to profiles/personal/cli-tools.nix index c80a5ef..17b161d 100644 --- a/cli-tools.nix +++ b/profiles/personal/cli-tools.nix @@ -1,23 +1,10 @@ -{ pkgs, ... }: +{ ... }: { environment.shellAliases = { yt = "yt-dlp"; - ll = "ls -la"; }; - environment.etc."gitconfig".text = '' - [user] - name = Brian Nelson - email = brian@briannelson.dev - [init] - defaultBranch = main - [credential] - helper = osxkeychain - ''; - - environment.variables.GIT_CONFIG_SYSTEM = "/etc/gitconfig"; - environment.etc."yt-dlp.conf".text = '' -o /Users/briannelson/Downloads/yt-dlp/%(title)s.%(ext)s --no-mtime @@ -33,4 +20,4 @@ sudo -u briannelson /opt/homebrew/bin/defaultbrowser librewolf || echo "could not set deffault browser, skipping" fi ''; -} +} \ No newline at end of file diff --git a/profiles/personal/default.nix b/profiles/personal/default.nix new file mode 100644 index 0000000..a121e2b --- /dev/null +++ b/profiles/personal/default.nix @@ -0,0 +1,9 @@ +{ ... }: + +{ + imports = [ + ./cli-tools.nix + ./apps.nix + ./archive-installs.nix + ] +} \ No newline at end of file diff --git a/profiles/work/apps.nix b/profiles/work/apps.nix new file mode 100644 index 0000000..fb2cb01 --- /dev/null +++ b/profiles/work/apps.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: + +{ + environment.systemPackages = with pkgs; []; + + homebrew.brews = []; + + homebrew.casks = []; +} \ No newline at end of file diff --git a/profiles/work/cli-tools.nix b/profiles/work/cli-tools.nix new file mode 100644 index 0000000..8f5a48a --- /dev/null +++ b/profiles/work/cli-tools.nix @@ -0,0 +1,9 @@ +{ ... }: + +{ + system.activationScripts.postActivation.text = '' + if [ -x /opt/homebrew/bin/defaultbrowser ]; then + sudo -u briannelson /opt/homebrew/bin/defaultbrowser firefox || echo "could not set deffault browser, skipping" + fi + ''; +} \ No newline at end of file diff --git a/profiles/work/default.nix b/profiles/work/default.nix new file mode 100644 index 0000000..54a0b0a --- /dev/null +++ b/profiles/work/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + ./apps.nix + ./cli-tools.nix + ] +} \ No newline at end of file -- 2.49.1 From 00147ba24260948ea3983e43c877a08e9f0acb62 Mon Sep 17 00:00:00 2001 From: Brian Nelson Date: Mon, 9 Nov 2026 11:01:18 -0500 Subject: [PATCH 2/5] removed imports from base --- modules/base.nix | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/base.nix b/modules/base.nix index 6c4070b..5d37283 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -1,12 +1,6 @@ { ... }: { - imports = [ - ./cli-tools.nix - ./mac-settings.nix - ./pkg-installs.nix - ] - nixpkgs.hostPlatform = "aarch64-darwin"; nix.settings.experimental-features = "nix-command flakes"; -- 2.49.1 From 0a9ede2ba835c159ae372c24041c497d7a123b91 Mon Sep 17 00:00:00 2001 From: Brian Nelson Date: Mon, 9 Nov 2026 13:41:03 -0500 Subject: [PATCH 3/5] added option for global and per profile pkg and zip installs --- modules/apps.nix | 42 +++++++++++++++++++ .../personal => modules}/archive-installs.nix | 20 ++++----- modules/base.nix | 28 ------------- modules/default.nix | 2 + modules/pkg-installs.nix | 20 ++++----- profiles/personal/apps.nix | 9 ++++ 6 files changed, 70 insertions(+), 51 deletions(-) create mode 100644 modules/apps.nix rename {profiles/personal => modules}/archive-installs.nix (72%) diff --git a/modules/apps.nix b/modules/apps.nix new file mode 100644 index 0000000..cf617fd --- /dev/null +++ b/modules/apps.nix @@ -0,0 +1,42 @@ +{ ... }: + +{ + # This file installs these apps on all configurations + pkgInstalls = [ + { + name = "cupsadmin"; + url = "https://github.com/kfattic/cupsadmin/releases/download/v1.4.1/cupsadmin-1.4.1.pkg"; + hash = "sha256-DyIyDYSjAlcU7ivyfldMapIZw5nczEBXfnLicnK6k7Y="; + } + ]; + + archiveApps = []; + + environment.systemPackages = with pkgs; [ + exif + exiftool + git + helix + ]; + + homebrew.brews = [ + "bun" + "defaultbrowser" + "harper" + "rust" + "ykman" + ]; + + homebrew.casks = [ + "bitwarden" + "harper-desktop" + "nextcloud" + "obsidian" + "signal" + "task-manager-tmog" + "twingate" + "vlc" + "vscodium" + "firefox" + ]; +} \ No newline at end of file diff --git a/profiles/personal/archive-installs.nix b/modules/archive-installs.nix similarity index 72% rename from profiles/personal/archive-installs.nix rename to modules/archive-installs.nix index 40062e3..828cf94 100644 --- a/profiles/personal/archive-installs.nix +++ b/modules/archive-installs.nix @@ -1,17 +1,9 @@ { pkgs, lib, ... }: let + cfg = config.archiveApps; stampDir = "/usr/local/share/nix-pkg-stamps"; - apps = [ - { - name = "removemacai-app"; - app = "RemoveMacAI.app"; - url = "https://github.com/omlahore/RemoveMacAI/releases/download/v1.1.4/RemoveMacAI.zip"; - sha256 = "2063d4dc7e0b41b15cebcd9e1b9807b04615b96e3e23db35cbd1196be3c96bee"; - } - ]; - appScript = a: let src = pkgs.fetchurl { inherit (a) url sha256; }; @@ -38,8 +30,12 @@ let ''; in { + optiosn.archiveApps = lib.mkOption { + type = lib.types.typesOf (lib.types.attrsOf lib.types.str); + default = [ ]; + description = "Apps distributed as .zip archives to install into /Applications"; + } + system.activationScripts.postActivation.text = - lib.concatStringsSep "\n" ( - (map appScript apps) - ); + lib.concatMapStringsSep "\n" appScript cfg; } diff --git a/modules/base.nix b/modules/base.nix index 5d37283..070d42d 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -8,39 +8,11 @@ system.stateVersion = 6; system.primaryUser = "briannelson"; - environment.systemPackages = with pkgs; [ - exif - exiftool - git - helix - ]; - homebrew = { enable = true; onActivation = { autoUpdate = true; cleanup = "none"; }; - - brews = [ - "bun" - "defaultbrowser" - "harper" - "rust" - "ykman" - ]; - - casks = [ - "bitwarden" - "harper-desktop" - "nextcloud" - "obsidian" - "signal" - "task-manager-tmog" - "twingate" - "vlc" - "vscodium" - "firefox" - ]; }; } \ No newline at end of file diff --git a/modules/default.nix b/modules/default.nix index afbbf70..44451ff 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -3,8 +3,10 @@ { imports = [ ./base.nix + ./apps.nix ./cli-tools.nix ./mac-settings.nix ./pkg-installs.nix + ./archive-installs.nix ]; } \ No newline at end of file diff --git a/modules/pkg-installs.nix b/modules/pkg-installs.nix index 3fb8342..041691b 100644 --- a/modules/pkg-installs.nix +++ b/modules/pkg-installs.nix @@ -1,15 +1,7 @@ -{ pkgs, lib, ... }: +{ pkgs, lib, config, ... }: let - # Add one entry per program you want to install from a .pkg file - pkgInstalls = [ - { - name = "cupsadmin"; - url = "https://github.com/kfattic/cupsadmin/releases/download/v1.4.1/cupsadmin-1.4.1.pkg"; - hash = "sha256-DyIyDYSjAlcU7ivyfldMapIZw5nczEBXfnLicnK6k7Y="; - } - ]; - + cfg = config.pkgInstalls; installScript = p: let src = pkgs.fetchurl { inherit (p) url hash; }; @@ -28,6 +20,12 @@ let ''; in { + options.pkgInstalls = lib.mkOption { + type = lib.types.listOf (lib.types.attrsOf lib.types.str); + default = [ ];' + description = "PKG files to install on activation"; + }; + system.activationScripts.postActivation.text = - lib.concatMapStringsSep "\n" installScript pkgInstalls; + lib.concatMapStringsSep "\n" installScript cfg; } diff --git a/profiles/personal/apps.nix b/profiles/personal/apps.nix index b09f880..e783521 100644 --- a/profiles/personal/apps.nix +++ b/profiles/personal/apps.nix @@ -1,6 +1,15 @@ { pkgs, ... }: { + archiveApps = [ + { + name = "removemacai-app"; + app = "RemoveMacAI.app"; + url = "https://github.com/omlahore/RemoveMacAI/releases/download/v1.1.4/RemoveMacAI.zip"; + sha256 = "2063d4dc7e0b41b15cebcd9e1b9807b04615b96e3e23db35cbd1196be3c96bee"; + } + ]; + environment.systemPackages = with pkgs; [ ffmpeg flac -- 2.49.1 From 1991b48f9837f6c175eb3071c7dbb28d606f9042 Mon Sep 17 00:00:00 2001 From: Brian Nelson Date: Mon, 9 Nov 2026 13:49:44 -0500 Subject: [PATCH 4/5] updated apps inside profiles --- profiles/personal/apps.nix | 2 ++ profiles/work/apps.nix | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/profiles/personal/apps.nix b/profiles/personal/apps.nix index e783521..50f420c 100644 --- a/profiles/personal/apps.nix +++ b/profiles/personal/apps.nix @@ -1,6 +1,8 @@ { pkgs, ... }: { + pkgInstalls = []; + archiveApps = [ { name = "removemacai-app"; diff --git a/profiles/work/apps.nix b/profiles/work/apps.nix index fb2cb01..10af814 100644 --- a/profiles/work/apps.nix +++ b/profiles/work/apps.nix @@ -1,6 +1,10 @@ { pkgs, ... }: { + pkgInstalls = []; + + archiveApps = []; + environment.systemPackages = with pkgs; []; homebrew.brews = []; -- 2.49.1 From bf40b1d4a6e0f89f63a64091139597d3ce6a6a4b Mon Sep 17 00:00:00 2001 From: Brian Nelson Date: Mon, 9 Nov 2026 18:15:45 -0500 Subject: [PATCH 5/5] tested and confirms it works --- .gitignore | 1 + flake.nix | 4 ++-- modules/apps.nix | 4 ++-- modules/archive-installs.nix | 10 +++++----- modules/pkg-installs.nix | 4 ++-- profiles/personal/apps.nix | 4 ++-- profiles/personal/default.nix | 5 ++--- profiles/work/default.nix | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/flake.nix b/flake.nix index 2b154d4..50679be 100644 --- a/flake.nix +++ b/flake.nix @@ -28,9 +28,9 @@ }; in { - darwinConfigurations."Brians-MacBook-Air" = nix-darwin.lib.darwinSystem { + darwinConfigurations = { personal = mkDarwin { profile = "personal"; user = "briannelson"; }; - work = mkDarwin { profile = "work"; user = "briannelson"; }; + work = mkDarwin { profile = "work"; user = "YOUR-WORK-USERNAME"; }; }; }; } diff --git a/modules/apps.nix b/modules/apps.nix index cf617fd..07703d0 100644 --- a/modules/apps.nix +++ b/modules/apps.nix @@ -1,4 +1,4 @@ -{ ... }: +{ pkgs, ... }: { # This file installs these apps on all configurations @@ -39,4 +39,4 @@ "vscodium" "firefox" ]; -} \ No newline at end of file +} diff --git a/modules/archive-installs.nix b/modules/archive-installs.nix index 828cf94..08804d8 100644 --- a/modules/archive-installs.nix +++ b/modules/archive-installs.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, ... }: +{ pkgs, lib, config, ... }: let cfg = config.archiveApps; @@ -30,12 +30,12 @@ let ''; in { - optiosn.archiveApps = lib.mkOption { - type = lib.types.typesOf (lib.types.attrsOf lib.types.str); + options.archiveApps = lib.mkOption { + type = lib.types.listOf (lib.types.attrsOf lib.types.str); default = [ ]; description = "Apps distributed as .zip archives to install into /Applications"; - } + }; - system.activationScripts.postActivation.text = + config.system.activationScripts.postActivation.text = lib.concatMapStringsSep "\n" appScript cfg; } diff --git a/modules/pkg-installs.nix b/modules/pkg-installs.nix index 041691b..df8fc28 100644 --- a/modules/pkg-installs.nix +++ b/modules/pkg-installs.nix @@ -22,10 +22,10 @@ in { options.pkgInstalls = lib.mkOption { type = lib.types.listOf (lib.types.attrsOf lib.types.str); - default = [ ];' + default = [ ]; description = "PKG files to install on activation"; }; - system.activationScripts.postActivation.text = + config.system.activationScripts.postActivation.text = lib.concatMapStringsSep "\n" installScript cfg; } diff --git a/profiles/personal/apps.nix b/profiles/personal/apps.nix index 50f420c..04c42e6 100644 --- a/profiles/personal/apps.nix +++ b/profiles/personal/apps.nix @@ -31,5 +31,5 @@ "libreoffice" "protonvpn" "rustdesk" - ] -} \ No newline at end of file + ]; +} diff --git a/profiles/personal/default.nix b/profiles/personal/default.nix index a121e2b..54aad5f 100644 --- a/profiles/personal/default.nix +++ b/profiles/personal/default.nix @@ -4,6 +4,5 @@ imports = [ ./cli-tools.nix ./apps.nix - ./archive-installs.nix - ] -} \ No newline at end of file + ]; +} diff --git a/profiles/work/default.nix b/profiles/work/default.nix index 54a0b0a..ae75d3c 100644 --- a/profiles/work/default.nix +++ b/profiles/work/default.nix @@ -4,5 +4,5 @@ imports = [ ./apps.nix ./cli-tools.nix - ] -} \ No newline at end of file + ]; +} -- 2.49.1