nix-configuration/flake.nix

207 lines
6.2 KiB
Nix

{
description = "nix system flake";
inputs = {
# Not manager by home manager, to update: nix flake lock --update-input <input>
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";
mac-app-util.url = "github:hraban/mac-app-util";
mac-app-util.inputs.nixpkgs.follows = "nixpkgs";
nixgl.url = "github:nix-community/nixGL";
nixgl.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
inputs@{
self,
home-manager,
mac-app-util,
nix-darwin,
nixgl,
nixpkgs,
}:
let
systems = nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
darwin-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";
# 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
};
};
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
nix = {
configureBuildUsers = true;
distributedBuilds = true;
gc = {
automatic = true;
options = "--delete-older-than 7d";
};
settings = {
experimental-features = "nix-command flakes";
};
};
homebrew = {
enable = true;
onActivation = {
autoUpdate = true;
# 'zap': uninstalls all formulae(and related files) not listed here.
cleanup = "zap";
upgrade = true;
};
};
};
in
{
lib = {
forAllSystems =
function:
systems (
system:
function (
import nixpkgs {
inherit system;
config.allowUnfreePredicate = (pkg: builtins.elem (nixpkgs.lib.getName pkg) [ "nvidia" ]);
}
)
);
};
formatter = self.lib.forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
homeConfigurations =
let
pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [
nixgl.overlay
];
config = {
allowUnfree = true;
};
};
in
{
# init with
# nix run home-manager/master -- switch --flake ~/.config/nix
# update with
# home-manager switch --flake ~/.config/nix
"becky@dingleberry" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
./modules/common.nix
./devices/becky-dingleberry.nix
];
};
};
darwinConfigurations = {
# init with
# nix run nix-darwin -- switch --flake ~/.config/nix
# update with
# darwin-rebuild switch --flake ~/.config/nix
lcech-mac = nix-darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = [
mac-app-util.darwinModules.default
darwin-common
{
# brew install --cask
# these need to be updated manually
homebrew.casks = [
"ghostty"
"spotify"
"keepassxc"
];
}
home-manager.darwinModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.lcech.imports = [
mac-app-util.homeManagerModules.default
./modules/common.nix
./devices/lcech-mac-veracode.nix
];
};
users.users.lcech.home = "/Users/lcech";
}
];
};
};
};
}