From b3f749f8bf9d605cb12d2017e6913b11fa195cb4 Mon Sep 17 00:00:00 2001 From: Brian Nelson Date: Mon, 9 Nov 2026 10:58:31 -0500 Subject: [PATCH] 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