refactor: organize package management for poetry

This commit is contained in:
jeirmeister 2024-10-31 22:06:57 -07:00
parent a5f747815f
commit ff72e7ca4a
32 changed files with 375 additions and 240 deletions

View File

@ -1,5 +1,4 @@
# Modify the kernel and v4l2loopback section in your configuration.nix
{ config, pkgs, lib, ... }:
{ pkgs, lib, ... }:
let
jovianNixosRev = "f6423d86bec22c25a576b23262495c5536b0d069";
@ -8,7 +7,6 @@ let
sha256 = "sha256:1frd1dfqd97idwf1rj29ab0wvyfa2nx2h3bp9hkbmfa1m802avmb";
};
# Custom v4l2loopback configuration for Steam Deck
v4l2loopback-options = {
options = {
exclusive_caps = 1;
@ -23,6 +21,29 @@ in
(jovianNixos + "/modules")
];
# Basic System Configuration
system.stateVersion = "24.05";
networking = {
hostName = "steamnix";
networkmanager.enable = true;
};
time.timeZone = "America/Los_Angeles";
i18n = {
defaultLocale = "en_US.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
};
# Nix Package Manager Configuration
nixpkgs = {
overlays = [
(import (jovianNixos + "/overlay.nix"))
@ -30,23 +51,18 @@ in
config.allowUnfree = true;
};
# Nix Configuration
nix.settings = {
experimental-features = [ "nix-command" "flakes" ];
substituters = [ "https://cache.nixos.org" ];
substituters = [ "cache.nixos.org" ];
allowed-users = [ "@wheel" "jeirmeister" ];
auto-optimise-store = true;
};
# Steam Deck Configuration
# Steam Deck Specific Configuration
jovian = {
# Hardware detection
hardware.has.amd.gpu = true;
devices.steamdeck = {
enable = true;
# Hardware features
enableControllerUdevRules = true;
enableDefaultStage1Modules = true;
enablePerfControlUdevRules = true;
@ -54,20 +70,62 @@ in
enableSoundSupport = true;
enableXorgRotation = true;
enableKernelPatches = true;
# Disable firmware updates temporarily
enableFwupdBiosUpdates = false;
autoUpdate = false;
};
steam.enable = false;
workarounds.ignoreMissingKernelModules = true;
};
# Hardware and Display Configuration
hardware.video = {
displaylink.enable = true;
};
# System Services
# Desktop Environment and Display Configuration
services.xserver = {
enable = true;
xkb.layout = "us";
videoDrives = [ "displaylink" "modesetting" ];
desktopManager.plasma6 = {
enable = true;
extraSessionCommands = ''
${pkgs.xorg.xrandr}/bin/xrandr --setprovideroutputsource 2 0;
'';
};
displayManager = {
sddm = {
enable = true;
wayland = true;
};
sessionCommands = ''
${lib.getBin pkgs.xorg.xrandr}/bin/xrandr --setprovideroutputsource 2 0
'';
};
};
# System Services Configuration
services = {
# Audio Configuration
pipewire = {
enable = true;
alsa.enable = true;
pulse.enable = true;
};
# Network Services
openssh = {
enable = true;
settings = {
PasswordAuthentication = true;
AllowUsers = [ "jeirmeister" ];
};
};
tailscale.enable = true;
};
# Systemd Services
systemd.services = {
# Fan Control Service
jupiter-fan-control = {
path = [ pkgs.dmidecode ];
serviceConfig = lib.mkForce {
@ -81,70 +139,18 @@ in
};
};
# Immersed Video Service
# immersed-video = {
# description = "Load v4l2loopback module for Immersed";
# wantedBy = [ "multi-user.target" ];
# after = [ "systemd-modules-load.service" ];
# requires = [ "systemd-modules-load.service" ];
# serviceConfig = {
# Type = "oneshot";
# RemainAfterExit = true;
# ExecStartPre = "${pkgs.kmod}/bin/modprobe -r v4l2loopback || true";
# ExecStart = "${pkgs.kmod}/bin/modprobe v4l2loopback exclusive_caps=1 video_nr=0 card_label='Immersed Virtual Camera'";
# ExecStop = "${pkgs.kmod}/bin/rmmod v4l2loopback || true";
# };
# };
};
# Ensure module loading at boot
systemd.services."systemd-modules-load" = {
"systemd-modules-load" = {
wantedBy = [ "multi-user.target" ];
restartIfChanged = true;
};
};
# UDev Rules
services.udev.extraRules = ''
# Steam Deck Fan Control
SUBSYSTEM=="hwmon*", KERNEL=="hwmon*", ACTION=="add", RUN+="${pkgs.coreutils}/bin/chmod a+rw /sys/%p/pwm1"
SUBSYSTEM=="hwmon*", KERNEL=="hwmon*", ACTION=="add", RUN+="${pkgs.coreutils}/bin/chmod a+rw /sys/%p/fan1_input"
'';
# Network Configuration
networking = {
hostName = "steamnix";
networkmanager.enable = true;
};
# Desktop Environment
services = {
xserver = {
enable = true;
xkb.layout = "us";
};
desktopManager.plasma6.enable = true;
displayManager.sddm.enable = true;
# Audio
pipewire = {
enable = true;
alsa.enable = true;
pulse.enable = true;
};
# SSH Server
openssh = {
enable = true;
settings = {
PasswordAuthentication = true;
AllowUsers = [ "jeirmeister" ];
};
};
# Tailscale VPN
tailscale.enable = true;
};
# User Configuration
users = {
users.jeirmeister = {
@ -179,43 +185,41 @@ in
};
environment.systemPackages = with pkgs; [
# Debugging tools
# System Tools
pciutils
usbutils
lm_sensors
dmidecode
linuxPackages.v4l2loopback # Virtual display for ImmersedVR
v4l-utils
# Development tools
nixfmt-rfc-style
# Basic utilities
tree
git
wget
curl
binutils
# Virtual Display
linuxPackages.v4l2loopback
v4l-utils
# Development Tools
nixfmt-rfc-style
git
# Network Tools
wget
curl
# Utilities
tree
];
# Locale and Time
time.timeZone = "America/Los_Angeles";
i18n = {
defaultLocale = "en_US.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
};
system.stateVersion = "24.05";
}
# TODO: Incorporate this part later
# Immersed Video Service
# immersed-video = {
# description = "Load v4l2loopback module for Immersed";
# wantedBy = [ "multi-user.target" ];
# after = [ "systemd-modules-load.service" ];
# requires = [ "systemd-modules-load.service" ];
# serviceConfig = {
# Type = "oneshot";
# RemainAfterExit = true;
# ExecStartPre = "${pkgs.kmod}/bin/modprobe -r v4l2loopback || true";
# ExecStart = "${pkgs.kmod}/bin/modprobe v4l2loopback exclusive_caps=1 video_nr=0 card_label='Immersed Virtual Camera'";
# ExecStop = "${pkgs.kmod}/bin/rmmod v4l2loopback || true";
# };
# };

View File

@ -1,7 +1,7 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ config, lib, modulesPath, ... }:
{
imports =

View File

@ -3,5 +3,6 @@
{
imports = [
./floorp.nix
./ungoogled-chromium.nix
];
}

View File

@ -0,0 +1,7 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
ungoogled-chromium
];
}

View File

@ -0,0 +1,28 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
# Matrix/Mautrix bridges
element-desktop-wayland
mautrix-whatsapp
mautrix-signal
mautrix-telegram
# Signal
signal-cli
signal-export
signal-desktop
# Telegram
telegram-desktop
telegram-bot-api
tg
tdl
# WhatsApp
whatsapp-for-linux
whatsapp-chat-exporter
# Video conferencing
zoom-us
];
}

View File

@ -2,10 +2,13 @@
{
imports = [
./browsers
./communication
./development
./gaming
./productivity
./shell
./system
];
}

View File

@ -0,0 +1,17 @@
# Add to common/default.nix
{ config, pkgs, lib, ... }:
{
imports = [ ./paths.nix ./versions.nix ];
# Helper function for path concatenation
_module.args.pathJoin = fragments:
lib.concatStringsSep "/" fragments;
programs.zsh.initExtra = lib.concatStrings [
''
# Environment Setup
${builtins.concatStringsSep "\n" (map (path: "export PATH=\"${path}:$PATH\"") config.home.sessionPath)}
''
];
}

View File

@ -0,0 +1,57 @@
{ config, pkgs, ... }:
{
home.sessionVariables = {
# XDG Base Directories
XDG_CACHE_HOME = "$HOME/.cache";
XDG_CONFIG_HOME = "$HOME/.config";
XDG_DATA_HOME = "$HOME/.local/share";
XDG_STATE_HOME = "$HOME/.local/state";
XDG_RUNTIME_DIR = "/run/user/${toString config.home.uid}";
# Tool-specific paths
DEVELOPMENT_TOOLS_HOME = "$XDG_DATA_HOME/dev-tools";
VIRTUALENV_HOME = "$XDG_DATA_HOME/virtualenvs";
NODE_PACKAGES_DIR = "$XDG_DATA_HOME/node-packages";
CARGO_HOME = "$XDG_DATA_HOME/cargo";
GO_PATH = "$XDG_DATA_HOME/go";
};
# Ensure directories exist
home.file = {
"${config.home.sessionVariables.DEVELOPMENT_TOOLS_HOME}/.keep".text = "";
"${config.home.sessionVariables.VIRTUALENV_HOME}/.keep".text = "";
"${config.home.sessionVariables.NODE_PACKAGES_DIR}/.keep".text = "";
# Add standard cache directories
"${config.home.sessionVariables.XDG_CACHE_HOME}/yarn/.keep".text = "";
"${config.home.sessionVariables.XDG_CACHE_HOME}/pnpm/.keep".text = "";
# Add standard data directories
"${config.home.sessionVariables.XDG_DATA_HOME}/node/.keep".text = "";
"${config.home.sessionVariables.XDG_DATA_HOME}/python/.keep".text = "";
"${config.home.sessionVariables.XDG_DATA_HOME}/cargo/.keep".text = "";
};
# Add to env/common/paths.nix
home.sessionPath = [
"$HOME/.local/bin"
"${config.home.sessionVariables.CARGO_HOME}/bin"
"${config.home.sessionVariables.GO_PATH}/bin"
"${config.home.sessionVariables.NODE_PACKAGES_DIR}/bin"
];
assertions = [
{
assertion = config.home.sessionVariables.XDG_CACHE_HOME != "";
message = "XDG_CACHE_HOME must be set";
}
{
assertion = config.home.sessionVariables.XDG_DATA_HOME != "";
message = "XDG_DATA_HOME must be set";
}
{
assertion = config.home.sessionVariables.XDG_CONFIG_HOME != "";
message = "XDG_CONFIG_HOME must be set";
}
];
}

View File

@ -0,0 +1,10 @@
{ config, pkgs, ... }:
{
home.sessionVariables = {
PYTHON_VERSION = "3.11";
NODE_VERSION = "20";
GO_VERSION = "1.21";
RUST_VERSION = "stable";
};
}

View File

@ -3,6 +3,8 @@
{
imports = [
./direnv.nix
./common
./languages
];
}

View File

@ -9,9 +9,7 @@
];
home.sessionVariables = {
GOPATH = "$HOME/go";
GOBIN = "$HOME/go/bin";
GOPATH = "${config.home.sessionVariables.GO_PATH}";
GOBIN = "${config.home.sessionVariables.GO_PATH}/bin";
};
home.file."go/bin/.keep".text = "";
}

View File

@ -3,7 +3,6 @@
{
imports = [
./node.nix
./pnpm.nix
./yarn.nix
./package-managers
];
}

View File

@ -1,17 +1,16 @@
{ config, pkgs, ... }:
let
nodeVersion = if builtins.getEnv "NODE_VERSION" != ""
then builtins.getEnv "NODE_VERSION"
else "20";
in
{
home.packages = with pkgs; [
nodejs_20
nodePackages.npm
nodePackages.node-gyp
nodePackages.node-pre-gyp
home.packages = [
pkgs."nodejs_${nodeVersion}"
];
home.sessionVariables = {
NODE_PATH = "$HOME/.npm-packages/lib/node_modules";
NPM_CONFIG_PREFIX = "$HOME/.npm-packages";
NODE_PATH = "${config.home.sessionVariables.NODE_PACKAGES_DIR}/lib/node_modules";
};
home.file.".npmrc".text = "prefix=$HOME/.npm-packages";
}

View File

@ -0,0 +1,9 @@
{ config, pkgs, ... }:
{
imports = [
./npm.nix
./pnpm.nix
./yarn.nix
];
}

View File

@ -0,0 +1,13 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
nodePackages.npm
nodePackages.node-gyp
nodePackages.node-pre-gyp
];
home.file.".npmrc".text = ''
prefix=${config.home.sessionVariables.NODE_PACKAGES_DIR}
'';
}

View File

@ -0,0 +1,10 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [ nodePackages.pnpm ];
home.file.".pnpmrc".text = ''
pnpm-version=8.9.0
store-dir=${config.home.sessionVariables.XDG_DATA_HOME}/pnpm
'';
}

View File

@ -0,0 +1,9 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [ yarn ];
home.file.".yarnrc".text = ''
cache-folder "${config.home.sessionVariables.XDG_CACHE_HOME}/yarn"
'';
}

View File

@ -1,12 +0,0 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
nodePackages.pnpm
];
home.file.".pnpmrc".text = "
pnpm-version=8.9.0
store-dir=$HOME/.pnpm-store
";
}

View File

@ -1,11 +0,0 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
yarn
];
home.file.".yarnrc".text = "
cache-folder $HOME/.yarn-cache
";
}

View File

@ -0,0 +1,22 @@
{ pkgs, ... }:
let
pythonVersion = builtins.replaceStrings ["."] [""]
(if builtins.getEnv "PYTHON_VERSION" != ""
then builtins.getEnv "PYTHON_VERSION"
else "311");
in
{
home.packages = [
pkgs."python${pythonVersion}"
pkgs."python${pythonVersion}Packages"."pip"
pkgs."python${pythonVersion}Packages"."setuptools"
pkgs."python${pythonVersion}Packages"."wheel"
];
home.sessionVariables = {
PYTHONDONTWRITEBYTECODE = 1;
PYTHONIOENCODING = "UTF-8";
VIRTUAL_ENV_DISABLE_PROMPT = 1;
};
}

View File

@ -1,27 +1,8 @@
{ config, pkgs, ... }:
{ pkgs, ... }:
{
imports = [
./pipenv.nix
./poetry.nix
./pyenv.nix
./base.nix
./package-managers
];
# Base Python installation
home.packages = with pkgs; [
python311
python311Packages.pip
python311Packages.setuptools
python311Packages.wheel
];
# Common Python environment variables
home.sessionVariables = {
PYTHONDONTWRITEBYTECODE = 1;
PYTHONIOENCODING = "UTF-8";
PYTHONUSERBASE = "$HOME/.local/python";
};
# Create Python user directory
home.file.".local/python/.keep".text = "";
}

View File

@ -0,0 +1,10 @@
# Add to env/languages/python/package-managers/default.nix
{ config, pkgs, ... }:
{
imports = [
./pipenv.nix
./poetry
];
}

View File

@ -1,18 +1,14 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
pipenv
];
home.packages = with pkgs; [ pipenv ];
home.sessionVariables = {
PIPENV_VENV_IN_PROJECT = "1";
WORKON_HOME = "$HOME/.local/share/virtualenvs";
WORKON_HOME = "${config.home.sessionVariables.VIRTUALENV_HOME}";
PIP_NO_CACHE_DIR = "off";
PIPENV_SKIP_LOCK = "1";
PIPENV_IGNORE_VIRTUALENVS = "1";
PIPENV_MAX_DEPTH = "5";
};
home.file.".local/share/virtualenvs/.keep".text = "";
}

View File

@ -0,0 +1,32 @@
{ config, pkgs, ... }:
let
poetry2nix = import (pkgs.fetchFromGitHub {
owner = "nix-community";
repo = "poetry2nix";
rev = "1.0.0";
sha256 = "15mdb0lr7027qpm9s1v1d9sdb8abmcdrpqsv4zvinif8a8liqxkq";
}) { inherit pkgs; };
in
{
home.packages = with pkgs; [
poetry
];
imports = [
./packages
];
home.sessionVariables = {
POETRY_VIRTUALENVS_IN_PROJECT = "true";
POETRY_CACHE_DIR = "${config.home.sessionVariables.XDG_CACHE_HOME}/pypoetry";
};
home.file.".config/pypoetry/config.toml".text = ''
[virtualenvs]
in-project = true
path = "${config.home.sessionVariables.VIRTUALENV_HOME}/poetry"
create = true
clear = false
'';
}

View File

@ -1,5 +1,4 @@
# users/jeirmeister/packages/default.nix
{ pkgs }:
{ pkgs, ... }:
{
repo-to-text = pkgs.callPackage ./repo-to-text.nix {};

View File

@ -1,23 +0,0 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
poetry
];
home.sessionVariables = {
POETRY_VIRTUALENVS_IN_PROJECT = "true";
POETRY_CACHE_DIR = "$HOME/.cache/pypoetry";
POETRY_IGNORE_ENVIRONMENT_VARIABLES = "1";
};
home.file.".config/pypoetry/config.toml".text = ''
[virtualenvs]
in-project = true
path = "{cache-dir}/virtualenvs"
create = true
clear = false
[repositories]
'';
}

View File

@ -1,21 +0,0 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
pyenv
];
home.sessionVariables = {
PYENV_ROOT = "$HOME/.pyenv";
PYENV_SHELL = "zsh";
PYENV_VIRTUALENV_INIT = "1";
};
home.file.".pyenv/version".text = "system";
programs.zsh.initExtra = ''
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"
'';
}

View File

@ -2,7 +2,6 @@
{
home.packages = with pkgs; [
# cargo is provided by rustup
cargo-edit
cargo-watch
cargo-audit
@ -10,13 +9,9 @@
];
home.sessionVariables = {
CARGO_HOME = "$HOME/.cargo";
CARGO_HOME = "${config.home.sessionVariables.CARGO_HOME}";
};
programs.zsh.initExtra = ''
export PATH="$CARGO_HOME/bin:$PATH"
'';
home.file.".cargo/config.toml".text = ''
[build]
target-dir = "target"

View File

@ -3,6 +3,6 @@
{
imports = [
./cargo.nix
./rustup.nix
./toolchain.nix
];
}

View File

@ -6,11 +6,11 @@
];
home.sessionVariables = {
RUSTUP_HOME = "$HOME/.rustup";
RUSTUP_HOME = "${config.home.sessionVariables.XDG_DATA_HOME}/rustup";
};
home.file.".rustup/settings.toml".text = ''
default_toolchain = "stable"
default_toolchain = "${config.home.sessionVariables.RUST_VERSION}"
profile = "default"
'';
}

View File

@ -34,4 +34,5 @@
};
};
};
home.file."${config.home.sessionVariables.XDG_DATA_HOME}/ssh/.keep".text = "";
}