commit adbaa5ddb3a981ccb83532362e8925d713aedb87 Author: Lukas Cech Date: Fri Jan 3 21:06:04 2025 +0100 Initialize configuration on mac diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..113e6e4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,69 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1735900408, + "narHash": "sha256-U+oZBQ3f5fF2hHsupKQH4ihgTKLHgcJh6jEmKDg+W10=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "1c8d4c8d592e8fab4cff4397db5529ec6f078cf9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1735685839, + "narHash": "sha256-62xAPSs5VRZoPH7eRanUn5S5vZEd+8vM4bD5I+zxokc=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "6a1fdb2a1204c0de038847b601cff5012e162b5e", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1735821806, + "narHash": "sha256-cuNapx/uQeCgeuhUhdck3JKbgpsml259sjUQnWM7zW8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d6973081434f88088e5321f83ebafe9a1167c367", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e47ff69 --- /dev/null +++ b/flake.nix @@ -0,0 +1,102 @@ +{ + 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"; + } + ]; + }; + }; + }; +} diff --git a/lcech-mac-veracode.nix b/lcech-mac-veracode.nix new file mode 100644 index 0000000..461e09c --- /dev/null +++ b/lcech-mac-veracode.nix @@ -0,0 +1,26 @@ +{ + config, + pkgs, + ... +}: +{ + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + home.username = "lcech"; + + home.homeDirectory = "/Users/lcech"; + + home.stateVersion = "24.11"; + + home.packages = with pkgs; [ + awscli2 + ]; + + programs.git = { + enable = true; + userName = "Lukas Cech"; + userEmail = "lcech@veracode.com"; + }; +} +