nix/flake.nix

141 lines
4.3 KiB
Nix
Raw Normal View History

2024-11-04 05:05:05 +00:00
{
description = "Triston Darwin system Flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-darwin.url = "github:LnL7/nix-darwin";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew";
};
outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew }:
let
configuration = { pkgs, config, ... }: {
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
# allows unfree packages like discord
nixpkgs.config.allowUnfree = true;
2024-11-04 05:32:50 +00:00
# ---- ADD NIX APPS HERE ------
2024-11-04 05:05:05 +00:00
environment.systemPackages =
[
pkgs.vim
pkgs.mkalias
pkgs.alacritty
pkgs.discord
pkgs.lazygit
pkgs.bun
pkgs.nodejs_22
pkgs.gnupg
pkgs.pinentry_mac
2024-11-04 05:32:50 +00:00
pkgs.rustup
2024-11-04 05:05:05 +00:00
];
2024-11-04 05:32:50 +00:00
# ---- ADD FONTS CONFIGS HERE ------
2024-11-04 05:05:05 +00:00
fonts.packages = [
(pkgs.nerdfonts.override { fonts = ["JetBrainsMono"]; })
];
2024-11-04 05:32:50 +00:00
# ---- THIS JUST MOVES NIX APPS ------
2024-11-04 05:05:05 +00:00
system.activationScripts.applications.text = let
env = pkgs.buildEnv {
name = "system-applications";
paths = config.environment.systemPackages;
pathsToLink = "/Applications";
};
in
2024-11-04 05:32:50 +00:00
pkgs.lib.mkForce /*bash*/''
2024-11-04 05:05:05 +00:00
# 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
'';
2024-11-04 05:32:50 +00:00
# ---- ADD HOMEBREW APPS HERE ------
2024-11-04 05:05:05 +00:00
homebrew = {
enable = true;
casks = [
];
masApps = {
# "NAME" = id from appstore share link
};
onActivation.cleanup = "zap";
onActivation.autoUpdate = true;
onActivation.upgrade = true;
2024-11-04 05:05:05 +00:00
};
2024-11-04 05:32:50 +00:00
# ---- ADD SYSTEM CONFIGS HERE ------
system.defaults = {
dock.autohide = true;
2024-11-04 06:04:31 +00:00
dock.orientation = "bottom";
2024-11-04 06:05:53 +00:00
dock.show-recents = false;
2024-11-04 05:32:50 +00:00
dock.persistent-apps = [
"${pkgs.alacritty}/Applications/Alacritty.app"
"/Applications/Safari.app"
"/System/Applications/Mail.app"
"/System/Applications/Calendar.app"
];
finder.FXPreferredViewStyle = "clmv";
loginwindow.GuestEnabled = false;
NSGlobalDomain.AppleICUForce24HourTime = false;
NSGlobalDomain.AppleInterfaceStyle = "Dark";
NSGlobalDomain.KeyRepeat = 2;
};
2024-11-04 05:05:05 +00:00
# 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";
# Enable alternative shell support in nix-darwin.
# 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";
2024-11-04 06:04:31 +00:00
# use touchid for password auth
security.pam.enableSudoTouchIdAuth = true;
2024-11-04 05:05:05 +00:00
};
in
{
# Build darwin flake using:
# $ darwin-rebuild build --flake .#simple
darwinConfigurations."macpro" = nix-darwin.lib.darwinSystem {
modules = [
configuration
nix-homebrew.darwinModules.nix-homebrew
{
nix-homebrew = {
enable = true;
enableRosetta = true;
user = "tristonarmstrong";
autoMigrate = true;
};
}
];
};
# Expose the package set, including overlays, for convenience.
darwinPackages = self.darwinConfigurations."simple".pkgs;
};
}