Skip to content

Instantly share code, notes, and snippets.

@mal1k-me
Created February 1, 2026 08:01
Show Gist options
  • Select an option

  • Save mal1k-me/f23634500b0fb7b2d5fc2c8d3c99ad48 to your computer and use it in GitHub Desktop.

Select an option

Save mal1k-me/f23634500b0fb7b2d5fc2c8d3c99ad48 to your computer and use it in GitHub Desktop.
Catalina-Safe Nix Setup
{
description = "Catalina-Safe Nix + Unstable Packages";
inputs = {
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.11";
nix-darwin.url = "github:nix-darwin/nix-darwin/nix-darwin-24.11";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs-stable";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = inputs@{ self, nix-darwin, nixpkgs-stable, nixpkgs-unstable, ... }:
let
# Shells to install (get registered in /etc/shells)
myShells = [
"bash"
"fish"
];
# Other packages to install
myPackages = [
"iterm2"
"mkalias" # Needed to make apps show up in Launchpad and Spotlight
"lsd"
"bat"
"ripgrep"
"zoxide"
"starship"
"vim"
"htop"
"fastfetch"
"cmatrix"
"llvm"
"clang"
"lldb"
"gdb"
"python3"
"python313Packages.pip"
];
system = "x86_64-darwin";
# Import stable nixpkgs (for Catalina-compatible nix-darwin)
pkgsStable = import nixpkgs-stable {
inherit system;
config.allowUnfree = true;
};
# Import unstable nixpkgs (for bleeding-edge packages)
pkgsUnstable = import nixpkgs-unstable {
inherit system;
config.allowUnfree = true;
};
getPackage = path:
let
parts = builtins.filter builtins.isString (builtins.split "\\." path);
in
builtins.foldl' (acc: part: acc.${part}) pkgsUnstable parts;
shells = map (name: pkgsUnstable.${name}) myShells;
packages = map getPackage myPackages;
# Set priority 1 to override any stable versions (default is 5)
highPriority = pkg: pkgsStable.lib.setPrio 1 pkg;
in {
darwinConfigurations.catalina = nix-darwin.lib.darwinSystem {
inherit system;
modules = [
({ pkgs, lib, options, config, ... }: {
# Use stable as base (keeps nix-darwin Catalina-compatible)
nixpkgs.pkgs = pkgsStable;
nixpkgs.config.allowUnfree = true;
# Pin Nix itself to Catalina-compatible version
nix.package = pkgs.nixVersions.nix_2_24;
services.nix-daemon.enable = true;
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# Programmatically enable shells, checking if package option exists
programs = builtins.listToAttrs (
builtins.filter (x: x != null) (
map (name:
let
hasPackageOption = options.programs ? ${name} && options.programs.${name} ? package;
in
if hasPackageOption then {
inherit name;
value = {
enable = true;
package = pkgsUnstable.${name};
};
} else null
) myShells
)
);
# Install unstable packages with high priority
environment.systemPackages = map highPriority (shells ++ packages);
environment.shells = shells;
# Install fonts properly
fonts.packages = with pkgsUnstable; [
nerd-fonts.symbols-only
];
# macOS system defaults
system.defaults = {
NSGlobalDomain = {
AppleShowScrollBars = "Always";
NSUseAnimatedFocusRing = false;
NSWindowResizeTime = 0.001;
NSNavPanelExpandedStateForSaveMode = true;
NSNavPanelExpandedStateForSaveMode2 = true;
PMPrintingExpandedStateForPrint = true;
PMPrintingExpandedStateForPrint2 = true;
NSDocumentSaveNewDocumentsToCloud = false;
NSTextShowsControlCharacters = true;
NSDisableAutomaticTermination = true;
NSAutomaticCapitalizationEnabled = false;
NSAutomaticDashSubstitutionEnabled = false;
NSAutomaticPeriodSubstitutionEnabled = false;
NSAutomaticQuoteSubstitutionEnabled = false;
NSAutomaticSpellingCorrectionEnabled = false;
AppleKeyboardUIMode = 3;
ApplePressAndHoldEnabled = false;
AppleShowAllExtensions = true;
"com.apple.mouse.tapBehavior" = 1;
};
dock = {
tilesize = 48;
mineffect = "scale";
minimize-to-application = true;
show-process-indicators = true;
launchanim = false;
expose-animation-duration = 0.1;
expose-group-apps = false;
mru-spaces = false;
autohide-delay = 0.0;
autohide-time-modifier = 0.0;
autohide = false;
showhidden = true;
};
finder = {
QuitMenuItem = true;
FXEnableExtensionChangeWarning = false;
_FXShowPosixPathInTitle = true;
AppleShowAllFiles = false;
ShowStatusBar = true;
ShowPathbar = true;
FXDefaultSearchScope = "SCcf";
FXPreferredViewStyle = "Nlsv";
};
trackpad = {
Clicking = true;
TrackpadRightClick = true;
};
screencapture = {
type = "png";
};
};
# For settings not covered by system.defaults, use CustomUserPreferences
system.defaults.CustomUserPreferences = {
"com.apple.desktopservices" = {
DSDontWriteNetworkStores = true;
DSDontWriteUSBStores = true;
};
"com.apple.frameworks.diskimages" = {
skip-verify = true;
skip-verify-locked = true;
skip-verify-remote = true;
};
"com.apple.Safari" = {
UniversalSearchEnabled = false;
SuppressSearchSuggestions = true;
ShowFullURLInSmartSearchField = true;
AutoOpenSafeDownloads = false;
IncludeDevelopMenu = true;
WebKitDeveloperExtrasEnabledPreferenceKey = true;
};
"com.apple.screensaver" = {
askForPassword = 1;
askForPasswordDelay = 0;
};
"com.apple.TimeMachine".DoNotOfferNewDisksForBackup = true;
"com.apple.ActivityMonitor" = {
OpenMainWindow = true;
ShowCategory = 0;
SortColumn = "CPUUsage";
SortDirection = 0;
};
};
# Set up Applications symlinks using mkalias
system.activationScripts.applications.text = let
env = pkgs.buildEnv {
name = "system-applications";
paths = config.environment.systemPackages;
pathsToLink = "/Applications";
};
in
pkgs.lib.mkForce ''
# Set up applications.
echo "setting up /Applications..." >&2
rm -rf /Applications/Nix\ Apps
mkdir -p /Applications/Nix\ Apps
find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
while read -r src; do
app_name=$(basename "$src")
echo "copying $src" >&2
${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name"
done
# Force Spotlight to reindex Nix Apps
# echo "reindexing Spotlight..." >&2
# mdimport -i "/Applications/Nix Apps" 2>/dev/null || true
'';
system.configurationRevision = self.rev or self.dirtyRev or null;
system.stateVersion = 5;
nixpkgs.hostPlatform = system;
})
];
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment