Skip to content

Commit

Permalink
Add support for multiple programming languages in the configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
yousiki committed Dec 16, 2024
1 parent 9f1bec5 commit b85bede
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 1 deletion.
1 change: 1 addition & 0 deletions homes/x86_64-linux/yousiki@hakase/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ _: {
nichijou = {
suites = {
graphical.enable = true;
languages.enable = true;
terminal.enable = true;
};

Expand Down
27 changes: 27 additions & 0 deletions modules/home/languages/javascript/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
lib,
pkgs,
namespace,
config,
...
}: let
cfg = config.${namespace}.languages.javascript;
in {
options.${namespace}.languages.javascript = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable javascript programming language.";
};
};

config = lib.mkIf cfg.enable {
home = {
packages = with pkgs; [
nodejs
pnpm
yarn-berry
];
};
};
}
30 changes: 30 additions & 0 deletions modules/home/languages/nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
lib,
pkgs,
namespace,
config,
...
}: let
cfg = config.${namespace}.languages.nix;
in {
options.${namespace}.languages.nix = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable nix programming language.";
};
};

config = lib.mkIf cfg.enable {
home = {
packages = with pkgs; [
alejandra
cachix
deadnix
nil
nixd
statix
];
};
};
}
70 changes: 70 additions & 0 deletions modules/home/languages/python/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
lib,
pkgs,
namespace,
config,
...
}: let
cfg = config.${namespace}.languages.python;

condarc = ''
channels:
- defaults
changeps1: false
show_channel_urls: true
auto_activate_base: false
default_channels:
- https://mirrors.pku.edu.cn/anaconda/pkgs/main
- https://mirrors.pku.edu.cn/anaconda/pkgs/r
custom_channels:
Paddle: https://mirrors.pku.edu.cn/anaconda/cloud
bioconda: https://mirrors.pku.edu.cn/anaconda/cloud
conda-forge: https://mirrors.pku.edu.cn/anaconda/cloud
intel: https://mirrors.pku.edu.cn/anaconda/cloud
numba: https://mirrors.pku.edu.cn/anaconda/cloud
pytorch3d: https://mirrors.pku.edu.cn/anaconda/cloud
pytorch: https://mirrors.pku.edu.cn/anaconda/cloud
rapidsai: https://mirrors.pku.edu.cn/anaconda/cloud
'';

ryeconfig = ''
[[sources]]
name = "default"
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
'';

pipconfig = ''
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
'';
in {
options.${namespace}.languages.python = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable python programming language.";
};
};

config = lib.mkIf cfg.enable {
home = {
packages = with pkgs; [
micromamba
python3
ruff
rye
];
file = {
".condarc".text = condarc;
".mambarc".text = condarc;
".rye/config.toml".text = ryeconfig;
".config/pip/pip.conf".text = pipconfig;
};
};
programs.zsh.initExtra = ''
if [[ -x "$(command -v micromamba)" ]]; then
eval "$(micromamba shell hook --shell zsh)"
fi
'';
};
}
28 changes: 28 additions & 0 deletions modules/home/languages/rust/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
lib,
pkgs,
namespace,
config,
...
}: let
cfg = config.${namespace}.languages.rust;
in {
options.${namespace}.languages.rust = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable rust programming language.";
};
};

config = lib.mkIf cfg.enable {
home = {
packages = with pkgs; [
rustup
];
};
home.sessionPath = [
"$HOME/.cargo/bin"
];
};
}
23 changes: 23 additions & 0 deletions modules/home/suites/languages/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
lib,
namespace,
config,
...
}: let
cfg = config.${namespace}.suites.languages;
in {
options.${namespace}.suites.languages = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable languages suite.";
};
};

config = lib.mkIf cfg.enable {
${namespace}.languages = {
python.enable = true;
nix.enable = true;
};
};
}
1 change: 0 additions & 1 deletion modules/nixos/basic/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
services.vscode-server = {
enable = true;
enableFHS = true;
installPath = "$HOME/.windsurf-server";
};

# Enable nix-ld.
Expand Down

0 comments on commit b85bede

Please sign in to comment.