nix-configuration/flake.nix
2025-01-03 21:06:04 +01:00

103 lines
3.3 KiB
Nix

{
description = "nix-darwin system flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
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";
};
outputs = inputs@{ self, nix-darwin, nixpkgs, home-manager }:
let
mac-common = { pkgs, ... }:
let
custom-key-mapping = {
# AI Instructions
# I need a mapping that switches my keyboard keys in the following way:
# the key above TAB and left of number 1 (lets call this key NEWTILDE has a code 30064771172)
# the key between left shift and Z (lets call this key NEWPIPE has a code 30064771125)
# the key above right shift and left of the big enter key (lets call this key NEWPLUSMINUS has a code 30064771121)
#
# Write the mapping in such a way that:
# NEWTILDE switches with NEWPIPE
# NEWPIPE overrides NEWPLUSMINUS
UserKeyMapping = [
{
HIDKeyboardModifierMappingSrc = 30064771125;
HIDKeyboardModifierMappingDst = 30064771172;
}
{
HIDKeyboardModifierMappingSrc = 30064771172;
HIDKeyboardModifierMappingDst = 30064771121;
}
];
};
in
{
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages = with pkgs; [
git
vim
];
launchd.user.agents = {
"custom-key-mapping" = {
script = ''
/usr/bin/hidutil property --set '${builtins.toJSON custom-key-mapping}' > /dev/null
'';
serviceConfig = {
RunAtLoad = true;
};
};
};
# The platform the configuration will be used on.
nixpkgs.hostPlatform = "aarch64-darwin";
# Necessary for using flakes on this system.
nix.settings.experimental-features = "nix-command flakes";
# 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;
system.defaults = {
finder = {
_FXShowPosixPathInTitle = true; # show full path in finder title
AppleShowAllExtensions = true; # show all file extensions
FXEnableExtensionChangeWarning = false; # disable warning when changing file extension
QuitMenuItem = true; # enable quit menu item
ShowPathbar = true; # show path bar
ShowStatusBar = true; # show status bar
};
};
};
in
{
darwinConfigurations = {
# darwin-rebuild build --flake .#lcech-mac-veracode
lcech-mac-veracode = nix-darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = [
mac-common
home-manager.darwinModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.lcech = import ./lcech-mac-veracode.nix;
};
users.users.lcech.home = "/Users/lcech";
}
];
};
};
};
}