Compare commits

..

30 Commits

Author SHA1 Message Date
29314ffa7b Update README.md 2026-11-13 10:56:46 -05:00
3d01855c3d added homebrew.autoMigrate 2026-11-13 10:08:22 -05:00
e5a27bcbd3 added altersend to work dock 2026-11-12 20:06:40 -05:00
2e34604ac5 turned personalized advertising off 2026-11-12 16:44:29 -05:00
c1f9a1d8e6 added altersend to personal dock 2026-11-12 16:30:46 -05:00
d227e5c9e1 updated work profile username 2026-11-12 10:52:36 -05:00
bf2b9c8762 dock apps for work 2026-11-12 10:14:11 -05:00
9ebe106841 fix config 2026-11-11 08:17:01 -05:00
700fbdc2b4 added nd to aliases 2026-11-11 08:15:11 -05:00
6ee6cad1df updated apps 2026-11-11 08:13:21 -05:00
d37abc556d updated nixpkgs 2026-11-10 16:19:31 -05:00
928b090957 updated apps and added touchId for sudo 2026-11-10 15:05:19 -05:00
6b9a18c948 updated README 2026-11-10 14:38:27 -05:00
51f82bd25f note about adding google chrome 2026-11-10 11:44:54 -05:00
6c0d871f16 added 1Pass to work and set work dock apps 2026-11-10 11:41:10 -05:00
0a9c270e31 added apps to personal dock 2026-11-10 11:33:50 -05:00
833cad7df8 added prismlauncher to personal 2026-11-09 19:16:22 -05:00
25cf488f18 added fladder to personal 2026-11-09 18:49:08 -05:00
9542e348cd added rusty-pw as global 2026-11-09 18:39:27 -05:00
d8ebcad70c updated README 2026-11-09 18:31:37 -05:00
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
Brian Nelson
ee735ee782 Working nix-darwin config from this Mac 2026-11-08 11:55:45 -05:00
19 changed files with 484 additions and 170 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
result

View File

@@ -1,15 +1,33 @@
# My nix-darwin Configuration # 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. 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.
This config contains options for both personal user and work use. There are shared packages found in [modules/apps](./modules/apps.nix) along with "profile" specific packages in their respective directories [profiles/personal](./profiles/personal/) and [profiles/work](./profiles/work/).
> [!important]
> Ignore the `install.sh` file for now, it's out dated and I don't believe will work in the current state.
> I'll think about adding a new install script but the default installation by cloning the repo into `/etc/nix-darwin` works pretty good.
## Installation ## 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` 1. Have an implementation of nix installed [nixos.org](https://nixos.org/download/)
2. `cd` into the repo 2. 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`
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. 3. Copy the repo into `/etc/nix-darwin`
```bash
sudo mkdir -p /etc/nix-darwin
sudo chown $(id -nu):$(id -ng) /etc/nix-darwin
sudo cp [PATH/TO/REPO] /etc/nix-darwin
```
4. Install nix-darwin and the profile you want with
```bash
sudo nix run nix-darwin/nix-darwin-26.05#darwin-rebuild --extra-experimental-features "nix-command flakes" -- switch --flake "/etc/nix-darwin#PROFILE_NAME"
# where PROFILE_NAME is either personal or work
```
5. Maintianing nix-darwin if any changes get made locally you can run the rebuild switch command. If changes get made remotely make sure to run `git pull` then the rebuild switch command.
```bash
cd /etc/nix-darwin
git pull
sudo darwin-rebuild switch --flake ".#PROFILE"
```
## Homebrew ## 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. 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,47 +0,0 @@
{ inputs, pkgs, ... }:
let
cupsadminPkg = pkgs.fetchurl {
url = "https://github.com/kfattic/cupsadmin/releases/download/v1.4.1/cupsadmin-1.4.1.pkg";
hash = "sha256-DyIyDYSjAlcU7ivyfldMapIZw5nczEBXfnLicnK6k7Y=";
};
in
{
system.activationScripts.postActivation.text = ''
want="${cupsadminPkg}"
stamp=/usr/local/share/cupsadmin-pkg.stamp
if [ "$(cat "$stamp" 2>/dev/null)" != "$want" ]; then
echo "installing cupsadmin..."
if /usr/sbin/installer -pkg "$want" -target /; then
mkdir -p /usr/local/share
echo "$want" > "$stamp"
else
echo "cupsadmin install failed, skipping"
fi
fi
'';
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
--restrict-filenames
--embed-thumbnails
--embed-metadata
--format "bestvideo[height<=1080]+bestaudio/best[height<=1080]"
--merge-output-format mp4
'';
}

View File

@@ -1,70 +0,0 @@
{ config, pkgs, ... }:
{
imports = [
./cli-tools.nix
./mac-settings.nix
];
nixpkgs.hostPlatform = "aarch64-darwin";
nixpkgs.config.problems.handlers = {
live555.broken = "warn";
};
nix.enable = false;
nix.settings.experimental-features = "nix-command flakes";
nixpkgs.config.allowUnsupportedSystem = true;
system.stateVersion = 6;
system.primaryUser = "briannelson";
environment.systemPackages = with pkgs; [
exif
exiftool
ffmpeg
flac
git
helix
librewolf
nicotine-plus
tea
yt-dlp
];
homebrew = {
enable = true;
onActivation = {
autoUpdate = true;
cleanup = "none";
};
brews = [
"bun"
"harper"
"rust"
"ykman"
];
casks = [
"bitwarden"
"cap"
"discord"
"docker-desktop"
"harper-desktop"
"libreoffice"
"nextcloud"
"obsidian"
"protonvpn"
"rustdesk"
"signal"
"task-manager-tmog"
"twingate"
"vlc"
"vscodium"
"firefox"
];
};
}

106
flake.lock generated Normal file
View File

@@ -0,0 +1,106 @@
{
"nodes": {
"brew-src": {
"flake": false,
"locked": {
"lastModified": 1793000687,
"narHash": "sha256-8mCor0DDjNhi+0e+FllfqiMABujBl+/RxYW+wgMpcto=",
"owner": "Homebrew",
"repo": "brew",
"rev": "c6069d2a943b71b0a90d91fc1ac93cb9c1634dcc",
"type": "github"
},
"original": {
"owner": "Homebrew",
"ref": "7.0.11",
"repo": "brew",
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1792800221,
"narHash": "sha256-53jIZEWNh96irEXhsMZFoNhLJgGSU3nYl1i4wFQHAsU=",
"owner": "nix-darwin",
"repo": "nix-darwin",
"rev": "d31953cf55f9027a56e9be938daf5db8c5655663",
"type": "github"
},
"original": {
"owner": "nix-darwin",
"ref": "nix-darwin-26.05",
"repo": "nix-darwin",
"type": "github"
}
},
"nix-homebrew": {
"inputs": {
"brew-src": "brew-src"
},
"locked": {
"lastModified": 1793543863,
"narHash": "sha256-oDYLVD8KGT/M57c8HziYSSj0le4wCyA+jZ7+/qUS91M=",
"owner": "zhaofengli",
"repo": "nix-homebrew",
"rev": "52bc87da3f30c2261a6d1cfef3c892097b53daeb",
"type": "github"
},
"original": {
"owner": "zhaofengli",
"repo": "nix-homebrew",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1793976852,
"narHash": "sha256-bWDN3JZcE9ovYoaD0/6WYbMtXYpUu0vd5onpK0pc/SE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "57f1c8965649ce5bcac5118a0d2e41f1fbdc56e5",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-26.05-darwin",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nix-darwin": "nix-darwin",
"nix-homebrew": "nix-homebrew",
"nixpkgs": "nixpkgs",
"rusty-pw": "rusty-pw"
}
},
"rusty-pw": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1792878430,
"narHash": "sha256-SZm2FqJr6tWrDdoEBa1+WUmSQZn514uXulM9opozoQ8=",
"ref": "refs/heads/main",
"rev": "d8faadac139e0856c6730cf9f5fcc74383362bef",
"revCount": 13,
"type": "git",
"url": "https://git.briannelson.dev/brian/rusty-pw"
},
"original": {
"type": "git",
"url": "https://git.briannelson.dev/brian/rusty-pw"
}
}
},
"root": "root",
"version": 7
}

View File

@@ -2,32 +2,41 @@
description = "Brian's macOS nix-darwin configuration"; description = "Brian's macOS nix-darwin configuration";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-26.05-darwin";
nix-darwin.url = "github:nix-darwin/nix-darwin"; nix-darwin.url = "github:nix-darwin/nix-darwin/nix-darwin-26.05";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
nix-homebrew.url = "github:zhaofengli/nix-homebrew"; nix-homebrew.url = "github:zhaofengli/nix-homebrew";
cupsadmin = { rusty-pw = {
url = "github:kfattic/cupsadmin"; url = "git+https://git.briannelson.dev/brian/rusty-pw";
flake = false; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, ... }: { outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, ... }:
darwinConfigurations."Brians-MacBook-Air" = nix-darwin.lib.darwinSystem { let
specialArgs = { inherit inputs; }; mkDarwin = { profile, user, system ? "aarch-64-dawin" }:
modules = [ nix-darwin.lib.darwinSystem {
./configuration.nix specialArgs = { inherit inputs user system; };
nix-homebrew.darwinModules.nix-homebrew modules = [
{ ./modules
nix-homebrew = { ./profiles/${profile}
enable = true; nix-homebrew.darwinModules.nix-homebrew
enableRosetta = true; {
user = "briannelson"; nix-homebrew = {
autoMigrate = true; enable = true;
}; enableRosetta = true;
} user = "briannelson";
]; autoMigrate = true;
};
}
];
};
in
{
darwinConfigurations = {
personal = mkDarwin { profile = "personal"; user = "briannelson"; };
work = mkDarwin { profile = "work"; user = "briannelson"; };
}; };
}; };
} }

47
modules/apps.nix Normal file
View File

@@ -0,0 +1,47 @@
{ inputs, 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 = [];
nixpkgs.overlays = [
inputs.rusty-pw.overlays.default
];
environment.systemPackages = with pkgs; [
exif
exiftool
git
helix
rusty-pw
];
homebrew.brews = [
"bun"
"defaultbrowser"
"harper"
"rust"
];
homebrew.casks = [
"altersend"
"bitwarden"
"harper-desktop"
"nextcloud"
"obsidian"
"signal"
"task-manager-tmog"
"twingate"
"vlc"
"vscodium"
"firefox"
];
}

View File

@@ -0,0 +1,41 @@
{ pkgs, lib, config, ... }:
let
cfg = config.archiveApps;
stampDir = "/usr/local/share/nix-pkg-stamps";
appScript = a:
let
src = pkgs.fetchurl { inherit (a) url sha256; };
in ''
stamp="${stampDir}/${a.name}"
want="${src}"
if [ "$(cat "$stamp" 2>/dev/null)" != "$want" ]; then
echo "installing ${a.name}..."
tmp=$(mktemp -d)
if /usr/bin/unzip -q "$want" -d "$tmp"; then
if [ -d "$tmp/${a.app}" ]; then
rm -rf "/Applications/${a.app}"
/usr/bin/ditto "$tmp/${a.app}" "/Applications/${a.app}"
mkdir -p "${stampDir}"
echo "$want" > "$stamp"
else
echo "${a.name}: ${a.app} not found in zip, skipping"
fi
else
echo "${a.name}: could not unzip, skipping"
fi
rm -rf "$tmp"
fi
'';
in
{
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;
}

20
modules/base.nix Normal file
View File

@@ -0,0 +1,20 @@
{ ... }:
{
nixpkgs.hostPlatform = "aarch64-darwin";
nix.settings.experimental-features = "nix-command flakes";
system.stateVersion = 6;
system.primaryUser = "briannelson";
security.pam.services.sudo_local.touchIdAuth = true;
homebrew = {
enable = true;
onActivation = {
autoUpdate = true;
cleanup = "none";
};
};
}

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

@@ -0,0 +1,20 @@
{ ... }:
{
environment.shellAliases = {
ll = "ls -la";
nd = "cd /etc/nix-darwin";
};
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,5 +1,4 @@
# This is a WIP, this file is not yet imported to the config { ... }:
{ ... }:
{ {
system.defaults = { system.defaults = {
@@ -21,29 +20,11 @@
dock = { dock = {
autohide = true; autohide = true;
largesize = 40; tilesize = 45;
largesize = 85;
magnification = true; magnification = true;
mineffect = "scale"; mineffect = "scale";
minimize-to-application = true; minimize-to-application = true;
# This is all an example of how to set the apps in the Dock.
# The key is to remember to update this before rebuilding.
# I may move this item to another file to keep things clean.
# persistent-apps = [
# {
# app = "/Applications/Safari.app";
# }
# {
# spacer = {
# small = true;
# };
# }
# {
# folder = "/System/Applications/Utilities";
# }
# {
# file = "/User/example/Downloads/test.csv";
# }
# ]
wvous-br-corner = 11; # Launchpad or Apps wvous-br-corner = 11; # Launchpad or Apps
wvous-tl-corner = 13; # lock screen wvous-tl-corner = 13; # lock screen
}; };
@@ -61,5 +42,9 @@
TrackpadPinch = true; TrackpadPinch = true;
TrackpadRightClick = true; TrackpadRightClick = true;
}; };
CustomUserPreferences = {
"com.apple.AdLib".allowApplePersonalizedAdvertising = false;
};
}; };
} }

31
modules/pkg-installs.nix Normal file
View File

@@ -0,0 +1,31 @@
{ pkgs, lib, config, ... }:
let
cfg = config.pkgInstalls;
installScript = p:
let
src = pkgs.fetchurl { inherit (p) url hash; };
in ''
stamp="/usr/local/share/nix-pkg-stamps/${p.name}"
want="${src}"
if [ "$(cat "$stamp" 2>/dev/null)" != "$want" ]; then
echo "installing ${p.name}..."
if /usr/sbin/installer -pkg "$want" -target /; then
mkdir -p /usr/local/share/nix-pkg-stamps
echo "$want" > "$stamp"
else
echo "${p.name} install failed, skipping"
fi
fi
'';
in
{
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,38 @@
{ 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
fladder
librewolf
qbittorrent
tea
yt-dlp
];
homebrew.brews = [
"nicotine-plus"
];
homebrew.casks = [
"cap"
"discord"
"docker-desktop"
"libreoffice"
"prismlauncher"
"protonvpn"
"rustdesk"
];
}

View File

@@ -0,0 +1,23 @@
{ ... }:
{
environment.shellAliases = {
yt = "yt-dlp";
};
environment.etc."yt-dlp.conf".text = ''
-o /Users/briannelson/Downloads/yt-dlp/%(title)s.%(ext)s
--no-mtime
--restrict-filenames
--embed-thumbnail
--embed-metadata
--format "bestvideo[height<=1080]+bestaudio/best[height<=1080]"
--merge-output-format mp4
'';
system.activationScripts.postActivation.text = ''
if [ -x /opt/homebrew/bin/defaultbrowser ]; then
sudo -u briannelson /opt/homebrew/bin/defaultbrowser librewolf || echo "could not set deffault browser, skipping"
fi
'';
}

View File

@@ -0,0 +1,28 @@
{ ... }:
{
imports = [
./cli-tools.nix
./apps.nix
];
system.defaults.dock = {
persistent-apps = [
{ app = "/System/Applications/Apps.app"; }
{ app = "/Applications/Nix Apps/LibreWolf.app"; }
{ app = "/System/Applications/Utilities/Terminal.app"; }
{ app = "/System/Applications/Messages.app"; }
{ app = "/Applications/Obsidian.app"; }
{ app = "/Applications/VSCodium.app"; }
{ app = "/System/Applications/Maps.app"; }
{ app = "/System/Applications/Calendar.app"; }
{ app = "/System/Applications/Reminders.app"; }
{ app = "/Applications/Bitwarden.app"; }
{ app = "/Applications/ProtonVPN.app"; }
{ app = "/Applications/Nix Apps/Fladder.app"; }
{ app = "/System/Applications/App Store.app"; }
{ app = "/Applications/AlterSend.app"; }
{ app = "/System/Applications/System Settings.app"; }
];
};
}

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

@@ -0,0 +1,19 @@
{ pkgs, ... }:
{
pkgInstalls = [];
archiveApps = [];
environment.systemPackages = with pkgs; [];
homebrew.brews = [
"ykman"
];
homebrew.casks = [
"1Password"
# I would add google chrome but that will be installed by Mosyle
# "google-chrome"
];
}

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

24
profiles/work/default.nix Normal file
View File

@@ -0,0 +1,24 @@
{ ... }:
{
imports = [
./apps.nix
./cli-tools.nix
];
system.defaults.dock = {
persistent-apps = [
{ app = "/System/Applications/Apps.app"; }
{ app = "/Applications/Firefox.app"; }
{ app = "/System/Applications/Utilities/Terminal.app"; }
{ app = "/Applications/Obsidian.app"; }
{ app = "/Applications/VSCodium.app"; }
{ app = "/System/Applications/App Store.app"; }
{ app = "/Applications/1Password.app"; }
{ app = "/Applications/Manager.app"; }
{ app = "/Applications/CUPS Admin.app"; }
{ app = "/Applications/AlterSend.app"; }
{ app = "/System/Applications/System Settings.app"; }
];
};
}