diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/configuration.nix b/configuration.nix deleted file mode 100644 index 0d0fc60..0000000 --- a/configuration.nix +++ /dev/null @@ -1,65 +0,0 @@ -{ 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"; - - system.stateVersion = 6; - system.primaryUser = "briannelson"; - - environment.systemPackages = with pkgs; [ - exif - exiftool - ffmpeg - flac - git - helix - librewolf - tea - yt-dlp - ]; - - homebrew = { - enable = true; - onActivation = { - autoUpdate = true; - cleanup = "none"; - }; - - brews = [ - "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" - "vlc" - "vscodium" - "firefox" - ]; - }; -} diff --git a/flake.nix b/flake.nix index 28cc09b..50679be 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, ... }: { - darwinConfigurations."Brians-MacBook-Air" = nix-darwin.lib.darwinSystem { - modules = [ - ./configuration.nix - nix-homebrew.darwinModules.nix-homebrew - { - nix-homebrew = { - enable = true; - enableRosetta = true; - user = "briannelson"; - }; - } - ]; + 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 = { + personal = mkDarwin { profile = "personal"; user = "briannelson"; }; + work = mkDarwin { profile = "work"; user = "YOUR-WORK-USERNAME"; }; }; }; } diff --git a/modules/apps.nix b/modules/apps.nix new file mode 100644 index 0000000..07703d0 --- /dev/null +++ b/modules/apps.nix @@ -0,0 +1,42 @@ +{ pkgs, ... }: + +{ + # 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" + ]; +} diff --git a/archive-installs.nix b/modules/archive-installs.nix similarity index 66% rename from archive-installs.nix rename to modules/archive-installs.nix index 40062e3..08804d8 100644 --- a/archive-installs.nix +++ b/modules/archive-installs.nix @@ -1,17 +1,9 @@ -{ pkgs, lib, ... }: +{ pkgs, lib, config, ... }: 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 { - system.activationScripts.postActivation.text = - lib.concatStringsSep "\n" ( - (map appScript apps) - ); + 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"; + }; + + config.system.activationScripts.postActivation.text = + lib.concatMapStringsSep "\n" appScript cfg; } diff --git a/modules/base.nix b/modules/base.nix new file mode 100644 index 0000000..070d42d --- /dev/null +++ b/modules/base.nix @@ -0,0 +1,18 @@ +{ ... }: + +{ + nixpkgs.hostPlatform = "aarch64-darwin"; + + nix.settings.experimental-features = "nix-command flakes"; + + system.stateVersion = 6; + system.primaryUser = "briannelson"; + + homebrew = { + enable = true; + onActivation = { + autoUpdate = true; + cleanup = "none"; + }; + }; +} \ 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..44451ff --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,12 @@ +{ ... }: + +{ + 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/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 55% rename from pkg-installs.nix rename to modules/pkg-installs.nix index 3fb8342..df8fc28 100644 --- a/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 { - system.activationScripts.postActivation.text = - lib.concatMapStringsSep "\n" installScript pkgInstalls; + options.pkgInstalls = lib.mkOption { + type = lib.types.listOf (lib.types.attrsOf lib.types.str); + default = [ ]; + description = "PKG files to install on activation"; + }; + + config.system.activationScripts.postActivation.text = + lib.concatMapStringsSep "\n" installScript cfg; } diff --git a/profiles/personal/apps.nix b/profiles/personal/apps.nix new file mode 100644 index 0000000..04c42e6 --- /dev/null +++ b/profiles/personal/apps.nix @@ -0,0 +1,35 @@ +{ pkgs, ... }: + +{ + pkgInstalls = []; + + 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 + librewolf + tea + yt-dlp + ]; + + homebrew.brews = [ + "nicotine-plus" + ]; + + homebrew.casks = [ + "cap" + "discord" + "docker-desktop" + "libreoffice" + "protonvpn" + "rustdesk" + ]; +} 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..54aad5f --- /dev/null +++ b/profiles/personal/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + ./cli-tools.nix + ./apps.nix + ]; +} diff --git a/profiles/work/apps.nix b/profiles/work/apps.nix new file mode 100644 index 0000000..10af814 --- /dev/null +++ b/profiles/work/apps.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: + +{ + pkgInstalls = []; + + archiveApps = []; + + 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..ae75d3c --- /dev/null +++ b/profiles/work/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + ./apps.nix + ./cli-tools.nix + ]; +}