Compare commits
28 Commits
e3706e95f8
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 29314ffa7b | |||
| 3d01855c3d | |||
| e5a27bcbd3 | |||
| 2e34604ac5 | |||
| c1f9a1d8e6 | |||
| d227e5c9e1 | |||
| bf2b9c8762 | |||
| 9ebe106841 | |||
| 700fbdc2b4 | |||
| 6ee6cad1df | |||
| d37abc556d | |||
| 928b090957 | |||
| 6b9a18c948 | |||
| 51f82bd25f | |||
| 6c0d871f16 | |||
| 0a9c270e31 | |||
| 833cad7df8 | |||
| 25cf488f18 | |||
| 9542e348cd | |||
| d8ebcad70c | |||
| 892aa827c8 | |||
| bf40b1d4a6 | |||
| 1991b48f98 | |||
| 0a9ede2ba8 | |||
| 00147ba242 | |||
| b3f749f8bf | |||
| 10bac6ed32 | |||
| 3acbbe1803 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
result
|
||||
36
README.md
36
README.md
@@ -1,15 +1,33 @@
|
||||
# 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.
|
||||
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
|
||||
1. Have an implementation of nix installed [nixos.org](https://nixos.org/download/)
|
||||
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. 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
|
||||
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.
|
||||
|
||||
@@ -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"
|
||||
];
|
||||
};
|
||||
}
|
||||
23
flake.lock
generated
23
flake.lock
generated
@@ -76,7 +76,28 @@
|
||||
"inputs": {
|
||||
"nix-darwin": "nix-darwin",
|
||||
"nix-homebrew": "nix-homebrew",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"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"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
22
flake.nix
22
flake.nix
@@ -6,21 +6,37 @@
|
||||
nix-darwin.url = "github:nix-darwin/nix-darwin/nix-darwin-26.05";
|
||||
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
|
||||
nix-homebrew.url = "github:zhaofengli/nix-homebrew";
|
||||
|
||||
rusty-pw = {
|
||||
url = "git+https://git.briannelson.dev/brian/rusty-pw";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, ... }: {
|
||||
darwinConfigurations."Brians-MacBook-Air" = nix-darwin.lib.darwinSystem {
|
||||
outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, ... }:
|
||||
let
|
||||
mkDarwin = { profile, user, system ? "aarch-64-dawin" }:
|
||||
nix-darwin.lib.darwinSystem {
|
||||
specialArgs = { inherit inputs user system; };
|
||||
modules = [
|
||||
./configuration.nix
|
||||
./modules
|
||||
./profiles/${profile}
|
||||
nix-homebrew.darwinModules.nix-homebrew
|
||||
{
|
||||
nix-homebrew = {
|
||||
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
47
modules/apps.nix
Normal 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"
|
||||
];
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
20
modules/base.nix
Normal file
20
modules/base.nix
Normal 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
20
modules/cli-tools.nix
Normal 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
12
modules/default.nix
Normal file
@@ -0,0 +1,12 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./base.nix
|
||||
./apps.nix
|
||||
./cli-tools.nix
|
||||
./mac-settings.nix
|
||||
./pkg-installs.nix
|
||||
./archive-installs.nix
|
||||
];
|
||||
}
|
||||
@@ -20,29 +20,11 @@
|
||||
|
||||
dock = {
|
||||
autohide = true;
|
||||
largesize = 40;
|
||||
tilesize = 45;
|
||||
largesize = 85;
|
||||
magnification = true;
|
||||
mineffect = "scale";
|
||||
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-tl-corner = 13; # lock screen
|
||||
};
|
||||
@@ -60,5 +42,9 @@
|
||||
TrackpadPinch = true;
|
||||
TrackpadRightClick = true;
|
||||
};
|
||||
|
||||
CustomUserPreferences = {
|
||||
"com.apple.AdLib".allowApplePersonalizedAdvertising = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
38
profiles/personal/apps.nix
Normal file
38
profiles/personal/apps.nix
Normal 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"
|
||||
];
|
||||
}
|
||||
@@ -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
|
||||
28
profiles/personal/default.nix
Normal file
28
profiles/personal/default.nix
Normal 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
19
profiles/work/apps.nix
Normal 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"
|
||||
];
|
||||
}
|
||||
9
profiles/work/cli-tools.nix
Normal file
9
profiles/work/cli-tools.nix
Normal 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
24
profiles/work/default.nix
Normal 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"; }
|
||||
];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user