Compare commits

..

32 Commits

Author SHA1 Message Date
892aa827c8 Merge pull request 'brian/profiles' (#1) from brian/profiles into main
Reviewed-on: #1
2026-11-09 18:16:33 -05:00
bf40b1d4a6 tested and confirms it works 2026-11-09 18:15:45 -05:00
1991b48f98 updated apps inside profiles 2026-11-09 13:49:44 -05:00
0a9ede2ba8 added option for global and per profile pkg and zip installs 2026-11-09 13:41:03 -05:00
00147ba242 removed imports from base 2026-11-09 11:01:18 -05:00
b3f749f8bf restructed modules for home and work, untested 2026-11-09 10:58:31 -05:00
10bac6ed32 added credential helper 2026-11-08 12:29:16 -05:00
3acbbe1803 fix git config 2026-11-08 12:23:32 -05:00
Brian Nelson
e3706e95f8 Merge existing repo history, keep working config 2026-11-08 11:58:22 -05:00
b4ce55c151 changed cupsadmin 2026-11-07 08:07:54 -05:00
f36234ea8c added cupsadmin as input and native build 2026-11-06 11:03:32 -05:00
6b61eaf75d added libreoffice 2026-11-06 10:37:18 -05:00
1368ac7d23 added task-manager 2026-11-06 09:16:38 -05:00
0774d02c5c vlc as cask 2026-11-05 18:22:06 -05:00
262c5ae623 fix mac-settings 2026-11-05 18:19:35 -05:00
60f5073114 warn problems 2026-11-05 18:18:26 -05:00
a1b639bfa5 allow unfree 2026-11-05 18:04:08 -05:00
ec53448c90 git isnt a program in nix 2026-11-05 18:02:57 -05:00
ef2fe843b1 moved some brews to pkgs and changed hostname 2026-11-05 17:59:45 -05:00
ba26a2c3a2 added packages and brews 2026-11-02 10:43:01 -05:00
32d5892ddd updated install script for usb installation 2026-10-20 14:05:20 -04:00
8b159a2eee added mac-settings to imports 2026-10-20 14:00:20 -04:00
2bb2eaa751 updated README 2026-10-20 13:52:55 -04:00
8750caa5d2 updated README 2026-10-20 13:52:19 -04:00
3cf16ff880 added install script and git config 2026-10-20 13:47:55 -04:00
863b47e663 added git and obsidian 2026-10-20 11:22:40 -04:00
f9a722aad8 moved some cli stuff to cli-tools.nix 2026-10-20 11:13:32 -04:00
c9d180680d updated hostname 2026-10-20 11:10:26 -04:00
fe2053bd10 fixed magnification value 2026-10-20 11:06:07 -04:00
ea7507e7e3 started on mac-settings 2026-10-20 10:57:47 -04:00
ca5ea4e1ab added ykman and updated README 2026-10-20 09:59:14 -04:00
b6711ec221 initial commit 2026-10-20 09:46:14 -04:00
18 changed files with 252 additions and 115 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
result

15
README.md Normal file
View File

@@ -0,0 +1,15 @@
# My nix-darwin Configuration
This repo is meant to be a declarative setup for new macOS devices, specifically focused on the application installs. All GUI applications will be handled by homebrew and some brews or CLI tools. The more stable and maintained CLI tools are installed via nixpkgs.
## Installation
1. Clone this repo onto the machine (probably fastest via usb) or install `git` seperatly and run `git clone https://git.briannelson.dev/brian/nix-darwin.git`
2. `cd` into the repo
3. Run `./install.sh` this will run a bash script that handles all of the installation of nix, file renaming and copying the files to the correct directory.
## Homebrew
I like using homebrew as my package manager for most apps as its really easy and convienent to run `brew upgrade` to update all apps in 1 go. I love nix for many other reasons but some of the packages on the stable branch aren't always up-to-date and take a while to update.
## Future Options
I like the option of setting the dock up using some of the options in nix-darwin but only on initial build. I found that getting the macOS machine setup with nix-darwin and setting all the dock apps was cool but if you made changes to to dock for whatever reason (installing a new app, having a different prefernce, etc.), rebuilding the system would then set the dock back to the original option.
I think that the use of Homebrew can help with this a little bit in the sense that I can update most apps without having to rebuild the system. So making changes to the dock via the "normal" click and drag on macOS can stay persistent for the most part but remembering to set the change in the config will be important for rebuilds.

View File

@@ -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"
];
};
}

View File

@@ -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"; };
};
};
}

27
install.sh Normal file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail
echo "==> Checking for Nix..."
if ! command -v nix >/dev/null 2>&1; then
echo "==> Installing Nix vis Determinate Systems installer..."
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
else
echo "Nix already installed, skipping."
fi
echo "==> Copying config to /etc/nix-darwin..."
sudo mkdir -p /etc/nix-darwin
sudo cp -r "$(pwd)/." /etc/nix-darwin
sudo chown -R root:wheel /etc/nix-darwin
echo "==> Renaming conflicting shell files if present..."
[ -f /etc/bashrc ] && sudo mv /etc/bashrc /etc/bashrc.before-nix-darwin
[ -f /etc/zshrc ] && sudo mv /etc/zshrc /etc/zshrc.before-nix-darwin
[ -f /etc/zshenv ] && sudo mv /etc/zshenv /etc/zshenv.before-nix-darwin
echo "==> Bootstraping nix-darwin..."
nix run nix-darwin/master#darwin-rebuild -- switch --flake /etc/nix-darwin
echo "==> Done! Restart your terminal to apply all changes."

42
modules/apps.nix Normal file
View File

@@ -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"
];
}

View File

@@ -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;
}

18
modules/base.nix Normal file
View File

@@ -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";
};
};
}

19
modules/cli-tools.nix Normal file
View File

@@ -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";
}

12
modules/default.nix Normal file
View File

@@ -0,0 +1,12 @@
{ ... }:
{
imports = [
./base.nix
./apps.nix
./cli-tools.nix
./mac-settings.nix
./pkg-installs.nix
./archive-installs.nix
];
}

View File

@@ -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;
}

View File

@@ -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"
];
}

View File

@@ -1,19 +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
'';
environment.etc."yt-dlp.conf".text = ''
-o /Users/briannelson/Downloads/yt-dlp/%(title)s.%(ext)s
--no-mtime
@@ -29,4 +20,4 @@
sudo -u briannelson /opt/homebrew/bin/defaultbrowser librewolf || echo "could not set deffault browser, skipping"
fi
'';
}
}

View File

@@ -0,0 +1,8 @@
{ ... }:
{
imports = [
./cli-tools.nix
./apps.nix
];
}

13
profiles/work/apps.nix Normal file
View File

@@ -0,0 +1,13 @@
{ pkgs, ... }:
{
pkgInstalls = [];
archiveApps = [];
environment.systemPackages = with pkgs; [];
homebrew.brews = [];
homebrew.casks = [];
}

View File

@@ -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
'';
}

View File

@@ -0,0 +1,8 @@
{ ... }:
{
imports = [
./apps.nix
./cli-tools.nix
];
}