Compare commits
32 Commits
working
...
892aa827c8
| Author | SHA1 | Date | |
|---|---|---|---|
| 892aa827c8 | |||
| bf40b1d4a6 | |||
| 1991b48f98 | |||
| 0a9ede2ba8 | |||
| 00147ba242 | |||
| b3f749f8bf | |||
| 10bac6ed32 | |||
| 3acbbe1803 | |||
|
|
e3706e95f8 | ||
| b4ce55c151 | |||
| f36234ea8c | |||
| 6b61eaf75d | |||
| 1368ac7d23 | |||
| 0774d02c5c | |||
| 262c5ae623 | |||
| 60f5073114 | |||
| a1b639bfa5 | |||
| ec53448c90 | |||
| ef2fe843b1 | |||
| ba26a2c3a2 | |||
| 32d5892ddd | |||
| 8b159a2eee | |||
| 2bb2eaa751 | |||
| 8750caa5d2 | |||
| 3cf16ff880 | |||
| 863b47e663 | |||
| f9a722aad8 | |||
| c9d180680d | |||
| fe2053bd10 | |||
| ea7507e7e3 | |||
| ca5ea4e1ab | |||
| b6711ec221 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
result
|
||||||
15
README.md
Normal file
15
README.md
Normal 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.
|
||||||
@@ -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"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
16
flake.nix
16
flake.nix
@@ -8,10 +8,14 @@
|
|||||||
nix-homebrew.url = "github:zhaofengli/nix-homebrew";
|
nix-homebrew.url = "github:zhaofengli/nix-homebrew";
|
||||||
};
|
};
|
||||||
|
|
||||||
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
|
||||||
|
mkDarwin = { profile, user, system ? "aarch-64-dawin" }:
|
||||||
|
nix-darwin.lib.darwinSystem {
|
||||||
|
specialArgs = { inherit user system; };
|
||||||
modules = [
|
modules = [
|
||||||
./configuration.nix
|
./modules
|
||||||
|
./profiles/${profile}
|
||||||
nix-homebrew.darwinModules.nix-homebrew
|
nix-homebrew.darwinModules.nix-homebrew
|
||||||
{
|
{
|
||||||
nix-homebrew = {
|
nix-homebrew = {
|
||||||
@@ -22,5 +26,11 @@
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
darwinConfigurations = {
|
||||||
|
personal = mkDarwin { profile = "personal"; user = "briannelson"; };
|
||||||
|
work = mkDarwin { profile = "work"; user = "YOUR-WORK-USERNAME"; };
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
27
install.sh
Normal file
27
install.sh
Normal 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
42
modules/apps.nix
Normal 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"
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -1,17 +1,9 @@
|
|||||||
{ pkgs, lib, ... }:
|
{ pkgs, lib, config, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
cfg = config.archiveApps;
|
||||||
stampDir = "/usr/local/share/nix-pkg-stamps";
|
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:
|
appScript = a:
|
||||||
let
|
let
|
||||||
src = pkgs.fetchurl { inherit (a) url sha256; };
|
src = pkgs.fetchurl { inherit (a) url sha256; };
|
||||||
@@ -38,8 +30,12 @@ let
|
|||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
system.activationScripts.postActivation.text =
|
options.archiveApps = lib.mkOption {
|
||||||
lib.concatStringsSep "\n" (
|
type = lib.types.listOf (lib.types.attrsOf lib.types.str);
|
||||||
(map appScript apps)
|
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
18
modules/base.nix
Normal 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
19
modules/cli-tools.nix
Normal 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
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
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -1,15 +1,7 @@
|
|||||||
{ pkgs, lib, ... }:
|
{ pkgs, lib, config, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
# Add one entry per program you want to install from a .pkg file
|
cfg = config.pkgInstalls;
|
||||||
pkgInstalls = [
|
|
||||||
{
|
|
||||||
name = "cupsadmin";
|
|
||||||
url = "https://github.com/kfattic/cupsadmin/releases/download/v1.4.1/cupsadmin-1.4.1.pkg";
|
|
||||||
hash = "sha256-DyIyDYSjAlcU7ivyfldMapIZw5nczEBXfnLicnK6k7Y=";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
installScript = p:
|
installScript = p:
|
||||||
let
|
let
|
||||||
src = pkgs.fetchurl { inherit (p) url hash; };
|
src = pkgs.fetchurl { inherit (p) url hash; };
|
||||||
@@ -28,6 +20,12 @@ let
|
|||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
system.activationScripts.postActivation.text =
|
options.pkgInstalls = lib.mkOption {
|
||||||
lib.concatMapStringsSep "\n" installScript pkgInstalls;
|
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;
|
||||||
}
|
}
|
||||||
35
profiles/personal/apps.nix
Normal file
35
profiles/personal/apps.nix
Normal 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"
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -1,19 +1,10 @@
|
|||||||
{ pkgs, ... }:
|
{ ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
environment.shellAliases = {
|
environment.shellAliases = {
|
||||||
yt = "yt-dlp";
|
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 = ''
|
environment.etc."yt-dlp.conf".text = ''
|
||||||
-o /Users/briannelson/Downloads/yt-dlp/%(title)s.%(ext)s
|
-o /Users/briannelson/Downloads/yt-dlp/%(title)s.%(ext)s
|
||||||
--no-mtime
|
--no-mtime
|
||||||
8
profiles/personal/default.nix
Normal file
8
profiles/personal/default.nix
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./cli-tools.nix
|
||||||
|
./apps.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
13
profiles/work/apps.nix
Normal file
13
profiles/work/apps.nix
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
pkgInstalls = [];
|
||||||
|
|
||||||
|
archiveApps = [];
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [];
|
||||||
|
|
||||||
|
homebrew.brews = [];
|
||||||
|
|
||||||
|
homebrew.casks = [];
|
||||||
|
}
|
||||||
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
|
||||||
|
'';
|
||||||
|
}
|
||||||
8
profiles/work/default.nix
Normal file
8
profiles/work/default.nix
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./apps.nix
|
||||||
|
./cli-tools.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user