Working nix-darwin config from this Mac
This commit is contained in:
45
archive-installs.nix
Normal file
45
archive-installs.nix
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{ pkgs, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
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; };
|
||||||
|
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
|
||||||
|
{
|
||||||
|
system.activationScripts.postActivation.text =
|
||||||
|
lib.concatStringsSep "\n" (
|
||||||
|
(map appScript apps)
|
||||||
|
);
|
||||||
|
}
|
||||||
32
cli-tools.nix
Normal file
32
cli-tools.nix
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{ 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
|
||||||
|
--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
|
||||||
|
'';
|
||||||
|
}
|
||||||
65
configuration.nix
Normal file
65
configuration.nix
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
{ 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"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
85
flake.lock
generated
Normal file
85
flake.lock
generated
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
26
flake.nix
Normal file
26
flake.nix
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
description = "Brian's macOS nix-darwin configuration";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-26.05-darwin";
|
||||||
|
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";
|
||||||
|
};
|
||||||
|
|
||||||
|
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";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
64
mac-settings.nix
Normal file
64
mac-settings.nix
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
system.defaults = {
|
||||||
|
NSGlobalDomain = {
|
||||||
|
AppleEnableSwipeNavigateWithScrolls = true;
|
||||||
|
AppleIconAppearanceTheme = "RegularDark";
|
||||||
|
AppleInterfaceStyle = "Dark";
|
||||||
|
NSDocumentSaveNewDocumentsToCloud = false;
|
||||||
|
NSNavPanelExpandedStateForSaveMode = true;
|
||||||
|
NSNavPanelExpandedStateForSaveMode2 = true;
|
||||||
|
"com.apple.trackpad.enableSecondaryClick" = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
controlcenter = {
|
||||||
|
AirDrop = true;
|
||||||
|
Bluetooth = true;
|
||||||
|
Sound = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
dock = {
|
||||||
|
autohide = true;
|
||||||
|
largesize = 40;
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
finder = {
|
||||||
|
AppleShowAllExtensions = true;
|
||||||
|
AppleShowAllFiles = true;
|
||||||
|
FXPreferredViewStyle = "clmv";
|
||||||
|
ShowPathbar = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
magicmouse.MouseButtonMode = "TwoButton";
|
||||||
|
|
||||||
|
trackpad = {
|
||||||
|
TrackpadPinch = true;
|
||||||
|
TrackpadRightClick = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
33
pkg-installs.nix
Normal file
33
pkg-installs.nix
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{ pkgs, lib, ... }:
|
||||||
|
|
||||||
|
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=";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
system.activationScripts.postActivation.text =
|
||||||
|
lib.concatMapStringsSep "\n" installScript pkgInstalls;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user