initial probably not working mac config
This commit is contained in:
35
flake.lock
generated
35
flake.lock
generated
@@ -493,6 +493,24 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-darwin": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1709771483,
|
||||
"narHash": "sha256-Hjzu9nCknHLQvhdaRFfCEprH0o15KcaNu1QDr3J88DI=",
|
||||
"owner": "LnL7",
|
||||
"repo": "nix-darwin",
|
||||
"rev": "550340062c16d7ef8c2cc20a3d2b97bcd3c6b6f6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "LnL7",
|
||||
"repo": "nix-darwin",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-filter": {
|
||||
"locked": {
|
||||
"lastModified": 1705332318,
|
||||
@@ -615,6 +633,20 @@
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b8697e57f10292a6165a20f03d2f42920dfaf973",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1709703039,
|
||||
"narHash": "sha256-6hqgQ8OK6gsMu1VtcGKBxKQInRLHtzulDo9Z5jxHEFY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9df3e30ce24fd28c7b3e2de0d986769db5d6225d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -661,9 +693,10 @@
|
||||
"home-manager": "home-manager_2",
|
||||
"impermanence": "impermanence",
|
||||
"lanzaboote": "lanzaboote",
|
||||
"nix-darwin": "nix-darwin",
|
||||
"nix-flatpak": "nix-flatpak",
|
||||
"nixos-hardware": "nixos-hardware",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
}
|
||||
},
|
||||
"rust-analyzer-src": {
|
||||
|
||||
79
flake.nix
79
flake.nix
@@ -16,40 +16,63 @@
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
nix-darwin.url = "github:LnL7/nix-darwin";
|
||||
|
||||
# Pi4
|
||||
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, chaotic, lanzaboote, impermanence, nix-flatpak, home-manager
|
||||
, nixos-hardware }@inputs: {
|
||||
nixosConfigurations = {
|
||||
# Desktop
|
||||
"matt-nixos" = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
impermanence.nixosModules.impermanence
|
||||
lanzaboote.nixosModules.lanzaboote
|
||||
nix-flatpak.nixosModules.nix-flatpak
|
||||
./hosts/desktop/configuration.nix
|
||||
./share/impermanence
|
||||
chaotic.nixosModules.default
|
||||
home-manager.nixosModules.home-manager
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.users.matt = import ./hosts/desktop/home.nix;
|
||||
}
|
||||
];
|
||||
};
|
||||
, nixos-hardware, nix-darwin }@inputs: {
|
||||
nixosConfigurations = {
|
||||
# Desktop
|
||||
"matt-nixos" = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
impermanence.nixosModules.impermanence
|
||||
lanzaboote.nixosModules.lanzaboote
|
||||
nix-flatpak.nixosModules.nix-flatpak
|
||||
./hosts/desktop/configuration.nix
|
||||
./share/impermanence
|
||||
chaotic.nixosModules.default
|
||||
home-manager.nixosModules.home-manager
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.users.matt = import ./hosts/desktop/home.nix;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
# Pi4
|
||||
"nixos-pi4" = nixpkgs.lib.nixosSystem {
|
||||
system = "aarch64-linux";
|
||||
modules = [
|
||||
nixos-hardware.nixosModules.raspberry-pi-4
|
||||
./hosts/pi4/configuration.nix
|
||||
];
|
||||
};
|
||||
# Pi4
|
||||
"nixos-pi4" = nixpkgs.lib.nixosSystem {
|
||||
system = "aarch64-linux";
|
||||
modules = [
|
||||
nixos-hardware.nixosModules.raspberry-pi-4
|
||||
./hosts/pi4/configuration.nix
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
darwinConfigurations = {
|
||||
"MacBook-Pro" = nix-darwin.lib.darwinSystem {
|
||||
system = "aarch64-darwin";
|
||||
modules = [
|
||||
./hosts/mac/configuration.nix
|
||||
home-manager.darwinModules.home-manager
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.users.mattjallen = import ./hosts/mac/home.nix;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
# Expose the package set, including overlays, for convenience.
|
||||
darwinPackages = self.darwinConfigurations."MacBook-Pro".pkgs;
|
||||
|
||||
# Set Git commit hash for darwin-version.
|
||||
system.configurationRevision = self.rev or self.dirtyRev or null;
|
||||
};
|
||||
}
|
||||
|
||||
67
hosts/mac/configuration.nix
Normal file
67
hosts/mac/configuration.nix
Normal file
@@ -0,0 +1,67 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
# List packages installed in system profile. To search by name, run:
|
||||
# $ nix-env -qaP | grep wget
|
||||
environment.systemPackages =
|
||||
[
|
||||
pkgs.vim
|
||||
pkgs.asitop
|
||||
];
|
||||
|
||||
# Homebrew
|
||||
homebrew.enable = true;
|
||||
homebrew.casks =
|
||||
[
|
||||
"spotify"
|
||||
"protonvpn"
|
||||
"firefox"
|
||||
"discord"
|
||||
"vmware-horizon-client"
|
||||
"tg-pro"
|
||||
"steam"
|
||||
"orcaslicer"
|
||||
"vscode"
|
||||
"epic-games"
|
||||
];
|
||||
# homebrew.masApps = {
|
||||
# Tailscale = 1475387142;
|
||||
# Infuse = 1136220934;
|
||||
# Amphetamine = 937984704;
|
||||
# LunaTask = 1583719331;
|
||||
# };
|
||||
homebrew.global.autoUpdate = true;
|
||||
|
||||
system.defaults.trackpad.Clicking = true;
|
||||
system.defaults.NSGlobalDomain."com.apple.mouse.tapBehavior" = 1;
|
||||
system.defaults.dock.autohide = false;
|
||||
system.defaults.NSGlobalDomain.AppleInterfaceStyle = "Dark";
|
||||
system.defaults.NSGlobalDomain."com.apple.keyboard.fnState" = true;
|
||||
security.pam.enableSudoTouchIdAuth = true;
|
||||
|
||||
|
||||
# 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";
|
||||
|
||||
# Allow unfree
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
|
||||
# Create /etc/zshrc that loads the nix-darwin environment.
|
||||
# programs.zsh.enable = true; # default shell on catalina
|
||||
programs.fish.enable = true;
|
||||
|
||||
# Used for backwards compatibility, please read the changelog before changing.
|
||||
# $ darwin-rebuild changelog
|
||||
system.stateVersion = 4;
|
||||
|
||||
# The platform the configuration will be used on.
|
||||
nixpkgs.hostPlatform = "aarch64-darwin";
|
||||
|
||||
users.users.mattjallen = {
|
||||
name = "mattjallen";
|
||||
home = "/Users/mattjallen";
|
||||
};
|
||||
}
|
||||
35
hosts/mac/home.nix
Normal file
35
hosts/mac/home.nix
Normal file
@@ -0,0 +1,35 @@
|
||||
{ config, pkgs, inputs, ... }:
|
||||
|
||||
{
|
||||
imports = [ ./trampoline-apps ];
|
||||
# Home Manager needs a bit of information about you and the
|
||||
# paths it should manage.
|
||||
home.username = "mattjallen";
|
||||
home.homeDirectory = "/Users/mattjallen";
|
||||
|
||||
# This value determines the Home Manager release that your
|
||||
# configuration is compatible with. This helps avoid breakage
|
||||
# when a new Home Manager release introduces backwards
|
||||
# incompatible changes.
|
||||
#
|
||||
# You can update Home Manager without changing this value. See
|
||||
# the Home Manager release notes for a list of state version
|
||||
# changes in each release.
|
||||
home.stateVersion = "23.11";
|
||||
|
||||
programs= {
|
||||
# Let Home Manager install and manage itself.
|
||||
home-manager = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
vscode = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
htop.enable = true;
|
||||
};
|
||||
|
||||
# Manage bug in compilations - who uses manpages in 2024 anyways? :P
|
||||
manual.manpages.enable = false;
|
||||
}
|
||||
24
hosts/mac/trampoline-apps/default.nix
Normal file
24
hosts/mac/trampoline-apps/default.nix
Normal file
@@ -0,0 +1,24 @@
|
||||
# Hook home-manager to make a trampoline for each app we install
|
||||
# from: https://github.com/nix-community/home-manager/issues/1341#issuecomment-1870352014
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
config = mkIf pkgs.stdenv.hostPlatform.isDarwin {
|
||||
# Install MacOS applications to the user Applications folder. Also update Docked applications
|
||||
home.extraActivationPath = with pkgs; [
|
||||
rsync
|
||||
dockutil
|
||||
gawk
|
||||
];
|
||||
home.activation.trampolineApps = hm.dag.entryAfter ["writeBoundary"] ''
|
||||
${builtins.readFile ./lib-bash/trampoline-apps.sh}
|
||||
fromDir="$HOME/Applications/Home Manager Apps"
|
||||
toDir="$HOME/Applications/Home Manager Trampolines"
|
||||
sync_trampolines "$fromDir" "$toDir"
|
||||
'';
|
||||
};
|
||||
}
|
||||
131
hosts/mac/trampoline-apps/lib-bash/trampoline-apps.sh
Normal file
131
hosts/mac/trampoline-apps/lib-bash/trampoline-apps.sh
Normal file
@@ -0,0 +1,131 @@
|
||||
# Utilities not in nixpkgs.
|
||||
plutil="/usr/bin/plutil"
|
||||
killall="/usr/bin/killall"
|
||||
osacompile="/usr/bin/osacompile"
|
||||
|
||||
copyable_app_props=(
|
||||
"CFBundleDevelopmentRegion"
|
||||
"CFBundleDocumentTypes"
|
||||
"CFBundleGetInfoString"
|
||||
"CFBundleIconFile"
|
||||
"CFBundleIdentifier"
|
||||
"CFBundleInfoDictionaryVersion"
|
||||
"CFBundleName"
|
||||
"CFBundleShortVersionString"
|
||||
"CFBundleURLTypes"
|
||||
"NSAppleEventsUsageDescription"
|
||||
"NSAppleScriptEnabled"
|
||||
"NSDesktopFolderUsageDescription"
|
||||
"NSDocumentsFolderUsageDescription"
|
||||
"NSDownloadsFolderUsageDescription"
|
||||
"NSPrincipalClass"
|
||||
"NSRemovableVolumesUsageDescription"
|
||||
"NSServices"
|
||||
"UTExportedTypeDeclarations"
|
||||
)
|
||||
|
||||
function sync_icons() {
|
||||
local from="$1"
|
||||
local to="$2"
|
||||
from_resources="$from/Contents/Resources/"
|
||||
to_resources="$to/Contents/Resources/"
|
||||
|
||||
find "$to_resources" -name "*.icns" -delete
|
||||
rsync --include "*.icns" --exclude "*" --recursive "$from_resources" "$to_resources"
|
||||
}
|
||||
|
||||
function copy_paths() {
|
||||
local from="$1"
|
||||
local to="$2"
|
||||
local paths=("${@:3}")
|
||||
|
||||
keys=$(jq -n '$ARGS.positional' --args "${paths[@]}")
|
||||
jqfilter="to_entries |[.[]| select(.key as \$item| \$keys | index(\$item) >= 0) ] | from_entries"
|
||||
|
||||
temp_dir=$(mktemp -d)
|
||||
trap 'rm -rf "$temp_dir"' EXIT
|
||||
|
||||
pushd $temp_dir >/dev/null
|
||||
|
||||
cp "$from" "orig"
|
||||
chmod u+w "orig"
|
||||
|
||||
cp "$to" "bare-wrapper"
|
||||
chmod u+w "bare-wrapper"
|
||||
|
||||
$plutil -convert json -- "orig"
|
||||
$plutil -convert json -- "bare-wrapper"
|
||||
jq --argjson keys "$keys" "$jqfilter" <"orig" >"filtered"
|
||||
cat "bare-wrapper" "filtered" | jq -s add >"final"
|
||||
$plutil -convert xml1 -- "final"
|
||||
|
||||
cp "final" "$to"
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
function sync_dock() {
|
||||
# Make sure all environment variables are cleared that might affect dockutil
|
||||
unset SUDO_USER
|
||||
|
||||
# Array of applications to sync
|
||||
declare -a apps=("$@")
|
||||
|
||||
# Iterate through each provided app
|
||||
for app_path in "${apps[@]}"; do
|
||||
if [ -d "$app_path" ]; then
|
||||
# Extract the name of the app from the path
|
||||
app_name=$(basename "$app_path")
|
||||
app_name=${app_name%.*} # Remove the '.app' extension
|
||||
resolved_path=$(realpath "$app_path")
|
||||
|
||||
# Find the current Dock item for the app, if it exists
|
||||
current_dock_item=$(dockutil --list --no-restart | grep "$app_name.app" | awk -F "\t" '{print $1}' || echo "")
|
||||
|
||||
if [ -n "$current_dock_item" ]; then
|
||||
# The app is currently in the Dock, attempt to replace it
|
||||
echo "Updating $app_name in Dock..."
|
||||
dockutil --add "$resolved_path" --replacing "$current_dock_item" --no-restart
|
||||
else
|
||||
# The app is not in the Dock; you might choose to add it or do nothing
|
||||
echo "$app_name is not currently in the Dock."
|
||||
fi
|
||||
else
|
||||
echo "Warning: Provided path $app_path is not valid."
|
||||
fi
|
||||
done
|
||||
|
||||
# Restart the Dock to apply changes
|
||||
$killall Dock
|
||||
}
|
||||
|
||||
function mktrampoline() {
|
||||
local app="$1"
|
||||
local trampoline="$2"
|
||||
|
||||
if [[ ! -d $app ]]; then
|
||||
echo "app path is not directory."
|
||||
return 1
|
||||
fi
|
||||
|
||||
cmd="do shell script \"open '$app'\""
|
||||
$osacompile -o "$trampoline" -e "$cmd"
|
||||
sync_icons "$app" "$trampoline"
|
||||
copy_paths "$(realpath "$app/Contents/Info.plist")" "$(realpath "$trampoline/Contents/Info.plist")" "${copyable_app_props[@]}"
|
||||
}
|
||||
|
||||
function sync_trampolines() {
|
||||
[[ ! -d "$1" ]] && echo "Source directory does not exist" && return 1
|
||||
|
||||
if [[ -d "$2" ]]; then
|
||||
rm -rf "$2"
|
||||
fi
|
||||
mkdir -p "$2"
|
||||
|
||||
apps=("$1"/*.app)
|
||||
|
||||
for app in "${apps[@]}"; do
|
||||
trampoline="$2/$(basename "$app")"
|
||||
mktrampoline "$app" "$trampoline"
|
||||
done
|
||||
sync_dock "${apps[@]}"
|
||||
}
|
||||
1
result
Symbolic link
1
result
Symbolic link
@@ -0,0 +1 @@
|
||||
/nix/store/9sz0d13mzbbi4ri2ndl5sjpnjhs1k6bv-darwin-installer
|
||||
2
scripts/mac-rebuild
Normal file
2
scripts/mac-rebuild
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
nix run nix-darwin -- switch --flake ~/nix-config
|
||||
Reference in New Issue
Block a user