Compare commits

..

2 Commits

Author SHA1 Message Date
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
7 changed files with 186 additions and 51 deletions

45
archive-installs.nix Normal file
View 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)
);
}

View File

@@ -1,27 +1,6 @@
{ 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
{ pkgs, ... }:
{
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";
@@ -33,15 +12,21 @@ in
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-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

@@ -1,23 +1,17 @@
{ config, pkgs, ... }:
{ pkgs, ... }:
{
imports = [
./cli-tools.nix
./mac-settings.nix
./pkg-installs.nix
./archive-installs.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";
@@ -29,7 +23,6 @@
git
helix
librewolf
nicotine-plus
tea
yt-dlp
];
@@ -43,7 +36,9 @@
brews = [
"bun"
"defaultbrowser"
"harper"
"nicotine-plus"
"rust"
"ykman"
];
@@ -67,4 +62,4 @@
"firefox"
];
};
}
}

85
flake.lock generated Normal file
View 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
}

View File

@@ -2,21 +2,15 @@
description = "Brian's macOS nix-darwin configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-darwin.url = "github:nix-darwin/nix-darwin";
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";
cupsadmin = {
url = "github:kfattic/cupsadmin";
flake = false;
};
};
outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, ... }: {
darwinConfigurations."Brians-MacBook-Air" = nix-darwin.lib.darwinSystem {
specialArgs = { inherit inputs; };
modules = [
modules = [
./configuration.nix
nix-homebrew.darwinModules.nix-homebrew
{
@@ -24,10 +18,9 @@
enable = true;
enableRosetta = true;
user = "briannelson";
autoMigrate = true;
};
}
];
};
};
}
}

View File

@@ -1,5 +1,4 @@
# This is a WIP, this file is not yet imported to the config
{ ... }:
{ ... }:
{
system.defaults = {
@@ -62,4 +61,4 @@
TrackpadRightClick = true;
};
};
}
}

33
pkg-installs.nix Normal file
View 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;
}