diff --git a/dotfiles/.local/share/chezmoi/home/.chezmoi.yaml.tmpl b/dotfiles/.local/share/chezmoi/home/.chezmoi.yaml.tmpl index c12e6077..2084a1b0 100644 --- a/dotfiles/.local/share/chezmoi/home/.chezmoi.yaml.tmpl +++ b/dotfiles/.local/share/chezmoi/home/.chezmoi.yaml.tmpl @@ -47,6 +47,19 @@ {{- $chassisType = (output "powershell.exe" "-noprofile" "-command" "if (Get-WmiObject -Class win32_battery -ComputerName localhost) { echo laptop } else { echo desktop }") }} {{- end }} +{{- $cpuCores := 1 }} +{{- $cpuThreads := 1 }} +{{- if eq .chezmoi.os "darwin" }} +{{- $cpuCores = (output "sysctl" "-n" "hw.physicalcpu_max") | trim | atoi }} +{{- $cpuThreads = (output "sysctl" "-n" "hw.logicalcpu_max") | trim | atoi }} +{{- else if eq .chezmoi.os "linux" }} +{{- $cpuCores = (output "sh" "-c" "lscpu --online --parse | grep --invert-match '^#' | sort --field-separator=',' --key='2,4' --unique | wc --lines") | trim | atoi }} +{{- $cpuThreads = (output "sh" "-c" "lscpu --online --parse | grep --invert-match '^#' | wc --lines") | trim | atoi }} +{{- else if eq .chezmoi.os "windows" }} +{{- $cpuCores = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfCores") | trim | atoi }} +{{- $cpuThreads = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfLogicalProcessors") | trim | atoi }} +{{- end }} + {{- $toolchainsEnabled := dict }} {{- range $toolchain := $toolchains }} {{- $withoutToolchains := env "WITHOUT_TOOLCHAINS" -}} @@ -96,6 +109,9 @@ age: data: host: arch: "{{ .chezmoi.arch }}" + cpu: + cores: "{{ $cpuCores }}" + threads: "{{ $cpuThreads }}" distro: family: "{{ .chezmoi.os }}" id: "{{ get .chezmoi.osRelease "id" | default .chezmoi.os }}" diff --git a/dotfiles/.local/share/chezmoi/home/.chezmoitemplates/chassis-info b/dotfiles/.local/share/chezmoi/home/.chezmoitemplates/chassis-info deleted file mode 100644 index 3d15e2c7..00000000 --- a/dotfiles/.local/share/chezmoi/home/.chezmoitemplates/chassis-info +++ /dev/null @@ -1,12 +0,0 @@ -{{- $chassisType := "desktop" }} -{{- if eq .chezmoi.os "darwin" }} -{{- if contains "MacBook" (output "sysctl" "-n" "hw.model") }} -{{- $chassisType = "laptop" }} -{{- else }} -{{- $chassisType = "desktop" }} -{{- end }} -{{- else if eq .chezmoi.os "linux" }} -{{- $chassisType = (output "hostnamectl" "--json=short" | mustFromJson).Chassis }} -{{- else if eq .chezmoi.os "windows" }} -{{- $chassisType = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "if ((Get-CimInstance -Class Win32_Battery | Measure-Object).Count -gt 0) { Write-Output 'laptop' } else { Write-Output 'desktop' }") | trim }} -{{- end }} diff --git a/dotfiles/.local/share/chezmoi/home/.chezmoitemplates/cpu-info b/dotfiles/.local/share/chezmoi/home/.chezmoitemplates/cpu-info deleted file mode 100644 index 4c52ba12..00000000 --- a/dotfiles/.local/share/chezmoi/home/.chezmoitemplates/cpu-info +++ /dev/null @@ -1,12 +0,0 @@ -{{- $cpuCores := 1 }} -{{- $cpuThreads := 1 }} -{{- if eq .chezmoi.os "darwin" }} -{{- $cpuCores = (output "sysctl" "-n" "hw.physicalcpu_max") | trim | atoi }} -{{- $cpuThreads = (output "sysctl" "-n" "hw.logicalcpu_max") | trim | atoi }} -{{- else if eq .chezmoi.os "linux" }} -{{- $cpuCores = (output "sh" "-c" "lscpu --online --parse | grep --invert-match '^#' | sort --field-separator=',' --key='2,4' --unique | wc --lines") | trim | atoi }} -{{- $cpuThreads = (output "sh" "-c" "lscpu --online --parse | grep --invert-match '^#' | wc --lines") | trim | atoi }} -{{- else if eq .chezmoi.os "windows" }} -{{- $cpuCores = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfCores") | trim | atoi }} -{{- $cpuThreads = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfLogicalProcessors") | trim | atoi }} -{{- end }} diff --git a/dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg.sh b/dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg similarity index 100% rename from dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg.sh rename to dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg