Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Xonsh #5494

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
xonsh:init
  • Loading branch information
pasqui23 committed Dec 10, 2024
commit abdc3b2d4e7ea79203d53c27e48ff80ac878d828
1 change: 1 addition & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
@@ -262,6 +262,7 @@ let
./programs/wpaperd.nix
./programs/xmobar.nix
./programs/xplr.nix
./programs/xonsh.nix
./programs/yambar.nix
./programs/yazi.nix
./programs/yt-dlp.nix
64 changes: 64 additions & 0 deletions modules/programs/xonsh.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{ config, lib, pkgs, ... }:
let
cfg = config.programs.xonsh;
inherit (lib) types mkOption;
in {
options.programs.xonsh = {
enable = lib.mkEnableOption "xonsh";

package = lib.mkPackageOption pkgs "xonsh" { };
finalPackage = lib.mkOption {
type = types.package;
internal = true;
description = "Package that will actually get installed";
};
xonshrc = mkOption {
type = types.lines;
default = "";
description = ''
The contents of .xonshrc
'';
};
pythonPackages = mkOption {
type = types.raw;
default = pkgs.pythonPackages;
defaultText = "pkgs.pythonPackages";
description = ''
The pythonPackages set extraPackages are taken from
'';
};
shellAliases = mkOption {
type = with types; attrsOf (listOf str);
default = { };
example = { ll = [ "ls" "-l" ]; };
description = ''
An attribute set that maps aliases (the top level attribute names in
this option) to commands
'';
};
extraPackages = mkOption {
type = with types; functionTo (listOf package);
default = _: [ ];
defaultText = "_: []";
description = ''
List of python packages and xontrib to make avaiable
'';
};
};
config = lib.mkIf cfg.enable {
home.packages = [ cfg.finalPackage ];
programs.xonsh = {
xonshrc = lib.mkMerge
(lib.mapAttrsToList (n: v: "aliases['${n}']=${builtins.toJSON v}")
cfg.shellAliases);
shellAliases = lib.mapAttrs (n: v: lib.mkDefault (lib.splitString " " v))
config.home.shellAliases;
finalPackage =
(cfg.package.override (old: { inherit (cfg) extraPackages; }));
};
xdg.configFile."xonsh/rc.xsh" = {
enable = cfg.xonshrc != "";
text = cfg.xonshrc;
};
};
}