Skip to content

Instantly share code, notes, and snippets.

@kamilmodest
Last active October 14, 2024 19:42
Show Gist options
  • Save kamilmodest/7884e22fccaed05f1049d41d04b2685a to your computer and use it in GitHub Desktop.
Save kamilmodest/7884e22fccaed05f1049d41d04b2685a to your computer and use it in GitHub Desktop.
{
description = "Darwin system flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin";
nix-darwin.url = "github:LnL7/nix-darwin";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew";
};
outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew }:
let
configuration = { pkgs, config, ... }: {
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages =
[
pkgs.neovim
pkgs.git
pkgs.mkalias
pkgs.bat
pkgs.eza
pkgs.k9s
pkgs.jq
pkgs.fblog
pkgs.fzf
pkgs.k6
pkgs.kubectl
pkgs.kubectx
pkgs.nodejs_22
pkgs.okta-aws-cli
pkgs.postgresql
pkgs.saml2aws
pkgs.sops
pkgs.tealdeer
pkgs.tomcat9
pkgs.yabai
pkgs.zoxide
pkgs.ansible
pkgs.ansible-lint
pkgs.localstack
pkgs.localsend
pkgs.kubernetes-helm
pkgs.gnupg
pkgs.karabiner-elements
pkgs.raycast
pkgs.arc-browser
pkgs.obsidian
pkgs.itsycal
pkgs.sublime4
pkgs.iterm2
pkgs.telegram-desktop
pkgs._1password-gui
pkgs._1password
pkgs.languagetool
pkgs.lens
pkgs.jetbrains-toolbox
pkgs.jetbrains.idea-ultimate
pkgs.vscode
pkgs.bruno
pkgs.zoom-us
];
homebrew = {
enable = true;
brews = [
"colima"
"docker"
"docker-compose"
"docker-completion"
"kubectl-jq"
"mas"
];
casks = [
"syntax-highlight"
"quicklook-json"
"qlstephen"
"qlmarkdown"
"meetingbar"
"vanilla"
"mac-mouse-fix"
"multitouch"
"usr-sse2-rdm"
"devtoys"
];
masApps = {
"Pelican" = 1524721688;
"iBar" = 6443843900;
};
onActivation.autoUpdate = true;
onActivation.upgrade = true;
};
font.packages = [
(pkgs.nerdfonts.override{ fonts = [ "JetBrainsMono" "RobotoMono" ]; })
];
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 src; do
app_name=$(basename "$src")
echo "copying $src" >&2
${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name"
done
'';
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
# nix.package = pkgs.nix;
# Necessary for using flakes on this system.
nix.settings.experimental-features = "nix-command flakes";
# Create /etc/zshrc that loads the nix-darwin environment.
programs.zsh.enable = true; # default shell on catalina
# programs.fish.enable = true;
# Set Git commit hash for darwin-version.
system.configurationRevision = self.rev or self.dirtyRev or null;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 5;
# The platform the configuration will be used on.
nixpkgs.hostPlatform = "aarch64-darwin";
};
in
{
# Build darwin flake using:
# $ darwin-rebuild build --flake .#FQM36KWGJ4
darwinConfigurations."FQM36KWGJ4" = nix-darwin.lib.darwinSystem {
modules = [
configuration
nix-homebrew.darwinModules.nix-homebrew
{
nix-homebrew = {
enable = true;
enableRosetta = true;
user = "k.babaev";
autoMigrate = true;
};
}
];
};
# Expose the package set, including overlays, for convenience.
darwinPackages = self.darwinConfigurations."FQM36KWGJ4".pkgs;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment