Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions .config/home-manager/flake.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "Home Manager configuration of connerohnesorge";
description = "Home Manager configuration";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
Expand All @@ -17,17 +17,38 @@
...
}: {
homeConfigurations = {
# macOS configuration
# Personal macOS configuration
"[email protected]" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.aarch64-darwin; # Assuming M1/M2 Mac, use x86_64-darwin for Intel
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
extraSpecialArgs = {username = "connerohnesorge";};
modules = [
./home-darwin.nix
];
};

# Linux configuration
# Work macOS configuration
"[email protected]" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
extraSpecialArgs = {username = "cohnesor";};
modules = [
./home-darwin.nix
];
};

# Personal Linux configuration
"connerohnesorge" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
extraSpecialArgs = {username = "connerohnesorge";};
modules = [
stylix.homeManagerModules.stylix
./home.nix
];
};

# Work Linux configuration (if needed)
"cohnesor" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
extraSpecialArgs = {username = "cohnesor";};
modules = [
stylix.homeManagerModules.stylix
./home.nix
Expand Down
5 changes: 3 additions & 2 deletions .config/home-manager/home-darwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
config,
pkgs,
lib,
username ? "connerohnesorge",
...
}: {
home = {
username = "connerohnesorge";
homeDirectory = "/home/connerohnesorge";
inherit username;
homeDirectory = "/Users/${username}";

# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
Expand Down
5 changes: 3 additions & 2 deletions .config/home-manager/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
pkgs,
lib,
stylix,
username ? "connerohnesorge",
...
}: {
home = {
username = "connerohnesorge";
homeDirectory = "/home/connerohnesorge";
inherit username;
homeDirectory = "/home/${username}";

# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
Expand Down
73 changes: 34 additions & 39 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
zen-browser.url = "github:connerohnesorge/zen-browser-flake";
zen-browser = {
url = "github:0xc000022070/zen-browser-flake";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};

firefox-addons = {
url = "github:connerohnesorge/nur-expressions?dir=pkgs/firefox-addons";
inputs.nixpkgs.follows = "nixpkgs";
};

proton-authenticator.url = "github:connerohnesorge/proton-authenticator-flake?ref=0494e1b70724861b4f8e2fb314b744e0591dfbb5";
proton-authenticator.inputs.nixpkgs.follows = "nixpkgs";

Expand Down Expand Up @@ -141,7 +151,8 @@
flake = let
mkConfigurations = moduleSystem:
denix.lib.configurations {
homeManagerUser = "connerohnesorge";
# homeManagerUser is set dynamically per-host via myconfig.host.username
# See modules/config/constants.nix and modules/config/home.nix
inherit moduleSystem;

paths = [./hosts ./modules ./rices];
Expand Down
113 changes: 113 additions & 0 deletions hosts/CB14957.local/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
delib,
inputs,
pkgs,
config,
lib,
...
}: let
system = "aarch64-darwin";
in
delib.host {
name = "CB14957.local";

# Work machine username
username = "cohnesor";

rice = "empty";
type = "laptop";

home.home.stateVersion = "24.11";
homeManagerSystem = system;

myconfig = {
features = {
engineer.enable = true;
};
programs = {
dx.enable = true;
catls.enable = true;
convert_img.enable = true;
};
};

nixos = {
imports = [
inputs.determinate.nixosModules.default
];
nixpkgs.hostPlatform = "x86_64-linux";
nixpkgs.config.allowUnfree = true;
nixpkgs.config.allowUnsupportedSystem = true;
system.stateVersion = "24.11";

# Minimal file system configuration to prevent assertion failures
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};

boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
};

darwin = {myconfig, ...}: {
imports = [
# inputs.determinate.darwinModules.default
];

nixpkgs = {
hostPlatform = system;
config.allowUnfree = true;
};
nix.enable = false;
programs = {
direnv = {
enable = true;
nix-direnv = {
enable = true;
package = pkgs.nix-direnv;
};
};
ssh = {
extraConfig = ''
SetEnv TERM=xterm-256color
'';
};
};
system = {
stateVersion = 5;
primaryUser = myconfig.constants.username;
defaults = {
dock.autohide = true;

trackpad = {
Clicking = true;
TrackpadThreeFingerDrag = true;
Dragging = true;
};
};
};

environment = {
systemPackages = [
# Macos Only
pkgs.aerospace
pkgs.raycast
pkgs.xcodes
# Shared
];
shells = [pkgs.zsh];

pathsToLink = ["/share/qemu"];
etc."containers/containers.conf.d/99-gvproxy-path.conf".text = ''
[engine]
helper_binaries_dir = ["${pkgs.gvproxy}/bin"]
'';
};
users.users.${myconfig.constants.username} = {
home = "/Users/${myconfig.constants.username}";
};

security.pam.services.sudo_local.touchIdAuth = true;
};
Comment on lines +1 to +112
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Hardcoded username/path checks (tune allowlist as needed)
echo "=== Checking for hardcoded usernames/paths ==="
rg -n --hidden -S -g '!.git/**' \
  'connerohnesorge|/Users/connerohnesorge|/home/connerohnesorge|users\.users\.connerohnesorge' || echo "No matches found"

echo ""
echo "=== Checking for any hardcoded 'cohnesor' references ==="
rg -n --hidden -S -g '!.git/**' \
  'cohnesor' || echo "No matches found"

# 2) Potential recursion footgun: host.username derived from constants.username
echo ""
echo "=== Checking for potential recursion (username = myconfig.constants.username) ==="
rg -nP --hidden -g '!.git/**' \
  '(^|\s)username\s*=\s*myconfig\.constants\.username\b' || echo "No matches found"

# 3) Additional check: Look at the specific file and surrounding context
echo ""
echo "=== Contents of hosts/CB14957.local/default.nix (first 50 lines) ==="
head -50 hosts/CB14957.local/default.nix

Repository: connerohnesorge/dotfiles

Length of output: 8855


Fix remaining hardcoded usernames and paths to support multi-user deployments.

The verification found hardcoded usernames/paths throughout the codebase:

  • flake.nix:144: homeManagerUser = "connerohnesorge"
  • .zshrc: Multiple hardcoded paths like /home/connerohnesorge/ and /Users/connerohnesorge/
  • .config/home-manager/flake.nix: Hardcoded username = "cohnesor" and username = "connerohnesorge"

Additionally, this file (hosts/CB14957.local/default.nix:15) hardcodes username = "cohnesor" instead of deriving it from myconfig.constants.username. Use the host/constants pattern consistently across all configurations.

Good news: No host→constants recursion patterns detected.

🤖 Prompt for AI Agents
In @hosts/CB14957.local/default.nix around lines 1 - 112, The username is
hardcoded as "cohnesor" in the host definition (symbol: username = "cohnesor")
which breaks multi-user deployments; replace that literal with the constant
reference used elsewhere (myconfig.constants.username) so the host uses the
centralized host/constants value, and update any remaining hardcoded paths and
settings (e.g., home paths, homeManagerUser, .zshrc entries, and
.config/home-manager/flake.nix username fields referenced in the review) to
derive from the same myconfig.constants.username symbol rather than string
literals to ensure consistency across hosts.

}
8 changes: 4 additions & 4 deletions hosts/mac-nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ in
boot.loader.efi.canTouchEfiVariables = true;
};

darwin = {
darwin = {myconfig, ...}: {
imports = [
# inputs.determinate.darwinModules.default
];
Expand All @@ -73,7 +73,7 @@ in
};
system = {
stateVersion = 5;
primaryUser = "connerohnesorge";
primaryUser = myconfig.constants.username;
defaults = {
dock.autohide = true;

Expand Down Expand Up @@ -101,8 +101,8 @@ in
helper_binaries_dir = ["${pkgs.gvproxy}/bin"]
'';
};
users.users.connerohnesorge = {
home = "/Users/connerohnesorge";
users.users.${myconfig.constants.username} = {
home = "/Users/${myconfig.constants.username}";
};

security.pam.services.sudo_local.touchIdAuth = true;
Expand Down
10 changes: 8 additions & 2 deletions modules/config/constants.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ delib.module {
name = "constants";

options.constants = with delib; {
# Primary username for the system (used for account creation and home directory)
username = readOnly (strOption "connerohnesorge");
# Primary username for the system (derived from host configuration)
# This allows different usernames per machine (e.g., "connerohnesorge" locally, "cohnesor" at work)
username = strOption "connerohnesorge";

# Full display name for the user (used in Git commits and system identification)
userfullname = readOnly (strOption "Conner Ohnesorge");

# Primary email address (used for Git commits, SSH keys, and notifications)
useremail = readOnly (strOption "[email protected]");
};

# Derive username from host configuration
myconfig.always = {myconfig, ...}: {
constants.username = myconfig.host.username;
};
}
Loading