home/python: collect python config into module

This commit is contained in:
Oystein Kristoffer Tveit 2025-04-25 14:40:28 +02:00
parent 7ca3b76226
commit c429cdf347
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
3 changed files with 22 additions and 12 deletions

@ -32,6 +32,7 @@ in {
./programs/nix-index
./programs/nushell.nix
./programs/pandoc.nix
./programs/python.nix
./programs/ripgrep.nix
./programs/skim.nix
./programs/sqlite.nix
@ -138,7 +139,6 @@ in {
keyboard.options = [ "caps:escape" ];
sessionVariables = {
PYTHONSTARTUP = "${config.xdg.configHome}/python/pyrc";
_JAVA_AWT_WM_NONREPARENTING = "1";
};
};
@ -160,16 +160,6 @@ in {
"ghc/ghci.conf".text = ''
:set prompt "${extendedLib.termColors.front.magenta "[GHCi]λ"} "
'';
"python/pyrc".text = ''
#!/usr/bin/env python3
import sys
# You also need \x01 and \x02 to separate escape sequence, due to:
# https://stackoverflow.com/a/9468954/1147688
sys.ps1='\x01\x1b${extendedLib.termColors.front.blue "[Python]> "}\x02>>>\x01\x1b[0m\x02 ' # bright yellow
sys.ps2='\x01\x1b[1;49;31m\x02...\x01\x1b[0m\x02 ' # bright red
'';
};
news.display = "silent";

@ -52,7 +52,6 @@
pipr
progress
pwntools
python3
rclone
rip2
rnr

21
home/programs/python.nix Normal file

@ -0,0 +1,21 @@
{ config, pkgs, extendedLib, ... }:
{
# Python for interactive use
home.packages = [
(pkgs.python3.withPackages (pypkgs: with pypkgs; [
requests
]))
];
xdg.configFile."python/pyrc".text = ''
#!/usr/bin/env python3
import sys
# You also need \x01 and \x02 to separate escape sequence, due to:
# https://stackoverflow.com/a/9468954/1147688
sys.ps1='\x01\x1b${extendedLib.termColors.front.blue "[Python]> "}\x02>>>\x01\x1b[0m\x02 ' # bright yellow
sys.ps2='\x01\x1b[1;49;31m\x02...\x01\x1b[0m\x02 ' # bright red
'';
home.sessionVariables.PYTHONSTARTUP = "${config.xdg.configHome}/python/pyrc";
}