Big updates

This commit is contained in:
Arnie 2025-01-05 23:10:55 +01:00
parent aa7fd15924
commit 5751958cad
28 changed files with 257 additions and 199 deletions

View File

@ -1,2 +0,0 @@
# Impure because of nixgl wrapper
alias hm-switch="home-manager switch --impure --flake ~/.config/nix"

View File

@ -1,2 +0,0 @@
# Impure because of nixgl wrapper
alias hm-switch="darwin-rebuild switch --flake ~/.config/nix"

View File

@ -7,17 +7,16 @@ let
username = "becky"; username = "becky";
homedir = "/home/${username}"; homedir = "/home/${username}";
zshSourceCommon = ../.zsh/common; zshSourceDirs = [
zshSourceUser = ../.zsh/dingleberry; ../modules/zsh/dingleberry
];
in in
{ {
# Let Home Manager install and manage itself. #targets.genericLinux.enable = true;
programs.home-manager.enable = true;
# Enable XDG for non terminal apps # Enable XDG for non terminal apps
# https://github.com/nix-community/home-manager/issues/1439 # https://github.com/nix-community/home-manager/issues/1439
#programs.bash.enable = true; #programs.bash.enable = true;
#targets.genericLinux.enable = true;
#xdg = { #xdg = {
# enable = true; # enable = true;
# mime = { # mime = {
@ -35,7 +34,6 @@ in
home.stateVersion = "24.11"; home.stateVersion = "24.11";
home.packages = with pkgs; [ home.packages = with pkgs; [
bat
nixd nixd
# TODO: Move from system to nix # TODO: Move from system to nix
# awscli2 # awscli2
@ -72,25 +70,27 @@ in
}; };
}; };
programs.ghostty = { programs.ghostty = {
enable = true; enable = true;
installBatSyntax = true;
installVimSyntax = true; installVimSyntax = true;
enableZshIntegration = true; enableZshIntegration = true;
package = config.lib.nixGL.wrap pkgs.ghostty; package = config.lib.nixGL.wrap pkgs.ghostty;
settings = {
theme = "catppuccin-mocha";
font-size = 10;
};
}; };
programs.zsh = { programs.zsh = {
enable = true; enable = true;
autocd = true;
shellAliases = { shellAliases = {
cat = "bat --paging=never"; hm-switch = "home-manager switch --impure --flake ~/.config/nix";
}; };
dirHashes = { dirHashes = {
mac = "${homedir}/storage/.macshare"; mac = "${homedir}/storage/.macshare";
nix = "${homedir}/.config/nix"; nix = "${homedir}/.config/nix";
@ -119,13 +119,13 @@ in
}; };
initExtra = '' initExtra = ''
for file in ${zshSourceCommon}/*.zsh; do ${builtins.concatStringsSep "\n" (
source "$file" builtins.map (dir: ''
done for file in ${dir}/*.zsh; do
source "$file"
for file in ${zshSourceUser}/*.zsh; do done
source "$file" '') zshSourceDirs
done )}
autoload -U +X bashcompinit && bashcompinit autoload -U +X bashcompinit && bashcompinit

View File

@ -1,5 +1,4 @@
{ {
config,
pkgs, pkgs,
... ...
}: }:
@ -9,13 +8,10 @@ let
zshSourceDirs = [ zshSourceDirs = [
../.zsh/common ../.zsh/common
../.zsh/macos ../modules/zsh/macos
]; ];
in in
{ {
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
home.username = username; home.username = username;
home.homeDirectory = homedir; home.homeDirectory = homedir;
@ -24,7 +20,6 @@ in
home.packages = with pkgs; [ home.packages = with pkgs; [
awscli2 awscli2
bat
k9s k9s
kubectl kubectl
nixd nixd
@ -64,29 +59,20 @@ in
programs.zsh = { programs.zsh = {
enable = true; enable = true;
autocd = true;
shellAliases = {
cat = "bat --paging=never";
};
dirHashes = { dirHashes = {
mac = "${homedir}/storage/.macshare"; mac = "${homedir}/storage/.macshare";
nix = "${homedir}/.config/nix"; nix = "${homedir}/.config/nix";
}; };
initExtra = '' initExtra = ''
${builtins.concatStringsSep "\n" ${builtins.concatStringsSep "\n" (
(builtins.map (dir: builtins.map (dir: ''
'' for file in ${dir}/*.zsh; do
for file in ${dir}/*.zsh; do source "$file"
source "$file" done
done '') zshSourceDirs
'' )}
) zshSourceDirs)
}
# ${pkgs.keepassxc}
autoload -U +X bashcompinit && bashcompinit autoload -U +X bashcompinit && bashcompinit
source <(kubectl completion zsh) source <(kubectl completion zsh)
@ -101,7 +87,6 @@ in
}; };
} }
# TODO: launchd timers # TODO: launchd timers
# <?xml version="1.0" encoding="UTF-8"?> # <?xml version="1.0" encoding="UTF-8"?>

335
flake.nix
View File

@ -14,165 +14,192 @@
nixgl.inputs.nixpkgs.follows = "nixpkgs"; nixgl.inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = inputs@{ outputs =
self, inputs@{
home-manager, self,
mac-app-util, home-manager,
nix-darwin, mac-app-util,
nixgl, nix-darwin,
nixpkgs, nixgl,
}: nixpkgs,
let }:
darwin-common = { pkgs, ... }:
let let
custom-key-mapping = { systems = nixpkgs.lib.genAttrs [
# AI Instructions "x86_64-linux"
# I need a mapping that switches my keyboard keys in the following way: "aarch64-linux"
# the key above TAB and left of number 1 (lets call this key NEWTILDE has a code 30064771172) "aarch64-darwin"
# 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 = { darwin-common =
"custom-key-mapping" = { { pkgs, ... }:
script = '' let
/usr/bin/hidutil property --set '${builtins.toJSON custom-key-mapping}' > /dev/null custom-key-mapping = {
''; # AI Instructions
serviceConfig = { # I need a mapping that switches my keyboard keys in the following way:
RunAtLoad = true; # 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:
# The platform the configuration will be used on. # NEWTILDE switches with NEWPIPE
nixpkgs.hostPlatform = "aarch64-darwin"; # NEWPIPE overrides NEWPLUSMINUS
UserKeyMapping = [
# Set Git commit hash for darwin-version. {
system.configurationRevision = self.rev or self.dirtyRev or null; HIDKeyboardModifierMappingSrc = 30064771125;
HIDKeyboardModifierMappingDst = 30064771172;
# Used for backwards compatibility, please read the changelog before changing. }
# $ darwin-rebuild changelog {
system.stateVersion = 5; HIDKeyboardModifierMappingSrc = 30064771172;
HIDKeyboardModifierMappingDst = 30064771121;
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
{
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 {
# pkgs = nixpkgs.legacyPackages.x86_64-linux;
inherit pkgs;
modules = [
./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 in
{ {
home-manager = { # List packages installed in system profile. To search by name, run:
useGlobalPkgs = true; # $ nix-env -qaP | grep wget
useUserPackages = true; environment.systemPackages = with pkgs; [
users.lcech.imports = [ git
mac-app-util.homeManagerModules.default vim
./devices/lcech-mac-veracode.nix ];
];
launchd.user.agents = {
"custom-key-mapping" = {
script = ''
/usr/bin/hidutil property --set '${builtins.toJSON custom-key-mapping}' > /dev/null
'';
serviceConfig = {
RunAtLoad = true;
};
}; };
users.users.lcech.home = "/Users/lcech"; };
}
]; # 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"
];
}
./modules/common.nix
home-manager.darwinModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.lcech.imports = [
mac-app-util.homeManagerModules.default
./devices/lcech-mac-veracode.nix
];
};
users.users.lcech.home = "/Users/lcech";
}
];
};
}; };
}; };
};
} }

50
modules/common.nix Normal file
View File

@ -0,0 +1,50 @@
{
lib,
pkgs,
...
}:
let
zshSourceCommon = ./zsh/common;
isDarwin = pkgs.stdenv.hostPlatform.isDarwin;
isLinux = pkgs.stdenv.hostPlatform.isLinux;
in
{
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
programs.bat = {
enable = true;
};
programs.zsh = {
enable = true;
autocd = lib.mkDefault true;
shellAliases =
{
cat = lib.mkDefault "bat --paging=never";
nixfix = lib.mkDefault "nix fmt ./**/*.nix";
}
// (
if isDarwin then
{
hm-switch = lib.mkDefault "darwin-rebuild switch --flake ~/.config/nix";
}
else if isLinux then
{
hm-switch = lib.mkDefault "home-manager switch --flake ~/.config/nix";
}
else
{ }
);
initExtra = ''
for file in ${zshSourceCommon}/*.zsh; do
source "$file"
done
'';
};
}