mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-24 17:58:30 +02:00
Merge pull request #77 from ryan4yin/use-optionals
refactor: use lib.optionals instead of if...then...else
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
{pkgs, ...}: {
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
home.packages = with pkgs;
|
home.packages = with pkgs;
|
||||||
[
|
[
|
||||||
# general tools
|
# general tools
|
||||||
@@ -26,12 +30,10 @@
|
|||||||
aliyun-cli
|
aliyun-cli
|
||||||
]
|
]
|
||||||
++ (
|
++ (
|
||||||
if pkgs.stdenv.isLinux
|
lib.optionals pkgs.stdenv.isLinux [
|
||||||
then [
|
|
||||||
# cloud tools that nix do not have cache for.
|
# cloud tools that nix do not have cache for.
|
||||||
terraform
|
terraform
|
||||||
terraformer # generate terraform configs from existing cloud resources
|
terraformer # generate terraform configs from existing cloud resources
|
||||||
]
|
]
|
||||||
else []
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,7 @@
|
|||||||
exercism
|
exercism
|
||||||
]
|
]
|
||||||
++ (
|
++ (
|
||||||
if pkgs.stdenv.isLinux
|
lib.optionals pkgs.stdenv.isLinux [
|
||||||
then [
|
|
||||||
# Automatically trims your branches whose tracking remote refs are merged or gone
|
# Automatically trims your branches whose tracking remote refs are merged or gone
|
||||||
# It's really useful when you work on a project for a long time.
|
# It's really useful when you work on a project for a long time.
|
||||||
git-trim
|
git-trim
|
||||||
@@ -57,7 +56,6 @@
|
|||||||
wireshark # network analyzer
|
wireshark # network analyzer
|
||||||
ventoy # create bootable usb
|
ventoy # create bootable usb
|
||||||
]
|
]
|
||||||
else []
|
|
||||||
);
|
);
|
||||||
|
|
||||||
programs = {
|
programs = {
|
||||||
|
|||||||
@@ -129,9 +129,7 @@
|
|||||||
(ripgrep.override {withPCRE2 = true;}) # recursively searches directories for a regex pattern
|
(ripgrep.override {withPCRE2 = true;}) # recursively searches directories for a regex pattern
|
||||||
]
|
]
|
||||||
++ (
|
++ (
|
||||||
if pkgs.stdenv.isDarwin
|
lib.optionals pkgs.stdenv.isLinux [
|
||||||
then []
|
|
||||||
else [
|
|
||||||
#-- verilog / systemverilog
|
#-- verilog / systemverilog
|
||||||
verible
|
verible
|
||||||
gdb
|
gdb
|
||||||
|
|||||||
@@ -18,93 +18,88 @@
|
|||||||
# we can add wezterm as a flake input once this PR is merged:
|
# we can add wezterm as a flake input once this PR is merged:
|
||||||
# https://github.com/wez/wezterm/pull/3547
|
# https://github.com/wez/wezterm/pull/3547
|
||||||
|
|
||||||
programs.wezterm =
|
programs.wezterm = {
|
||||||
{
|
enable = true; # disable
|
||||||
enable = false; # disable
|
|
||||||
|
|
||||||
# TODO: Fix: https://github.com/wez/wezterm/issues/4483
|
# install wezterm via homebrew on macOS to avoid compilation, dummy package here.
|
||||||
# package = pkgs.wezterm.override { };
|
package =
|
||||||
|
if pkgs.stdenv.isLinux
|
||||||
|
then pkgs.wezterm
|
||||||
|
else pkgs.hello;
|
||||||
|
|
||||||
extraConfig = let
|
enableBashIntegration = pkgs.stdenv.isLinux;
|
||||||
fontsize =
|
enableZshIntegration = pkgs.stdenv.isLinux;
|
||||||
if pkgs.stdenv.isDarwin
|
|
||||||
then "14.0"
|
|
||||||
else "13.0";
|
|
||||||
in ''
|
|
||||||
-- Pull in the wezterm API
|
|
||||||
local wezterm = require 'wezterm'
|
|
||||||
|
|
||||||
-- This table will hold the configuration.
|
extraConfig = let
|
||||||
local config = {}
|
fontsize =
|
||||||
|
if pkgs.stdenv.isLinux
|
||||||
|
then "13.0"
|
||||||
|
else "14.0";
|
||||||
|
in ''
|
||||||
|
-- Pull in the wezterm API
|
||||||
|
local wezterm = require 'wezterm'
|
||||||
|
|
||||||
-- In newer versions of wezterm, use the config_builder which will
|
-- This table will hold the configuration.
|
||||||
-- help provide clearer error messages
|
local config = {}
|
||||||
if wezterm.config_builder then
|
|
||||||
config = wezterm.config_builder()
|
-- In newer versions of wezterm, use the config_builder which will
|
||||||
|
-- help provide clearer error messages
|
||||||
|
if wezterm.config_builder then
|
||||||
|
config = wezterm.config_builder()
|
||||||
|
end
|
||||||
|
|
||||||
|
wezterm.on('toggle-opacity', function(window, pane)
|
||||||
|
local overrides = window:get_config_overrides() or {}
|
||||||
|
if not overrides.window_background_opacity then
|
||||||
|
overrides.window_background_opacity = 0.93
|
||||||
|
else
|
||||||
|
overrides.window_background_opacity = nil
|
||||||
end
|
end
|
||||||
|
window:set_config_overrides(overrides)
|
||||||
|
end)
|
||||||
|
|
||||||
wezterm.on('toggle-opacity', function(window, pane)
|
wezterm.on('toggle-maximize', function(window, pane)
|
||||||
local overrides = window:get_config_overrides() or {}
|
window:maximize()
|
||||||
if not overrides.window_background_opacity then
|
end)
|
||||||
overrides.window_background_opacity = 0.93
|
|
||||||
else
|
|
||||||
overrides.window_background_opacity = nil
|
|
||||||
end
|
|
||||||
window:set_config_overrides(overrides)
|
|
||||||
end)
|
|
||||||
|
|
||||||
wezterm.on('toggle-maximize', function(window, pane)
|
-- This is where you actually apply your config choices
|
||||||
window:maximize()
|
config.color_scheme = "Catppuccin Mocha"
|
||||||
end)
|
config.font = wezterm.font_with_fallback {
|
||||||
|
"JetBrainsMono Nerd Font",
|
||||||
|
"FiraCode Nerd Font",
|
||||||
|
|
||||||
-- This is where you actually apply your config choices
|
-- To avoid 'Chinese characters displayed as variant (Japanese) glyphs'
|
||||||
config.color_scheme = "Catppuccin Mocha"
|
"Source Han Sans SC",
|
||||||
config.font = wezterm.font_with_fallback {
|
"Source Han Sans TC"
|
||||||
"JetBrainsMono Nerd Font",
|
|
||||||
"FiraCode Nerd Font",
|
|
||||||
|
|
||||||
-- To avoid 'Chinese characters displayed as variant (Japanese) glyphs'
|
|
||||||
"Source Han Sans SC",
|
|
||||||
"Source Han Sans TC"
|
|
||||||
}
|
|
||||||
|
|
||||||
config.hide_tab_bar_if_only_one_tab = true
|
|
||||||
config.scrollback_lines = 10000
|
|
||||||
config.enable_scroll_bar = true
|
|
||||||
config.term = 'wezterm'
|
|
||||||
|
|
||||||
config.keys = {
|
|
||||||
-- toggle opacity(CTRL + SHIFT + B)
|
|
||||||
{
|
|
||||||
key = 'B',
|
|
||||||
mods = 'CTRL',
|
|
||||||
action = wezterm.action.EmitEvent 'toggle-opacity',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key = 'M',
|
|
||||||
mods = 'CTRL',
|
|
||||||
action = wezterm.action.EmitEvent 'toggle-maximize',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
config.font_size = ${fontsize}
|
|
||||||
|
|
||||||
-- To resolve issues:
|
|
||||||
-- 1. https://github.com/ryan4yin/nix-config/issues/26
|
|
||||||
-- 2. https://github.com/ryan4yin/nix-config/issues/8
|
|
||||||
-- Spawn a nushell in login mode via `bash`
|
|
||||||
config.default_prog = { '${pkgs.bash}/bin/bash', '--login', '-c', 'nu --login --interactive' }
|
|
||||||
|
|
||||||
return config
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
// (
|
|
||||||
if pkgs.stdenv.isDarwin
|
|
||||||
then {
|
|
||||||
# install wezterm via homebrew on macOS to avoid compilation, dummy package here.
|
|
||||||
# package = pkgs.hello;
|
|
||||||
enableBashIntegration = false;
|
|
||||||
enableZshIntegration = false;
|
|
||||||
}
|
}
|
||||||
else {}
|
|
||||||
);
|
config.hide_tab_bar_if_only_one_tab = true
|
||||||
|
config.scrollback_lines = 10000
|
||||||
|
config.enable_scroll_bar = true
|
||||||
|
config.term = 'wezterm'
|
||||||
|
|
||||||
|
config.keys = {
|
||||||
|
-- toggle opacity(CTRL + SHIFT + B)
|
||||||
|
{
|
||||||
|
key = 'B',
|
||||||
|
mods = 'CTRL',
|
||||||
|
action = wezterm.action.EmitEvent 'toggle-opacity',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key = 'M',
|
||||||
|
mods = 'CTRL',
|
||||||
|
action = wezterm.action.EmitEvent 'toggle-maximize',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
config.font_size = ${fontsize}
|
||||||
|
|
||||||
|
-- To resolve issues:
|
||||||
|
-- 1. https://github.com/ryan4yin/nix-config/issues/26
|
||||||
|
-- 2. https://github.com/ryan4yin/nix-config/issues/8
|
||||||
|
-- Spawn a nushell in login mode via `bash`
|
||||||
|
config.default_prog = { '${pkgs.bash}/bin/bash', '--login', '-c', 'nu --login --interactive' }
|
||||||
|
|
||||||
|
return config
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,59 +4,59 @@
|
|||||||
nur-ryan4yin,
|
nur-ryan4yin,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs;
|
||||||
# Misc
|
[
|
||||||
tldr
|
# Misc
|
||||||
cowsay
|
tldr
|
||||||
gnupg
|
cowsay
|
||||||
gnumake
|
gnupg
|
||||||
|
gnumake
|
||||||
|
|
||||||
# Morden cli tools, replacement of grep/sed/...
|
# Morden cli tools, replacement of grep/sed/...
|
||||||
|
|
||||||
# Interactively filter its input using fuzzy searching, not limit to filenames.
|
# Interactively filter its input using fuzzy searching, not limit to filenames.
|
||||||
fzf
|
fzf
|
||||||
# search for files by name, faster than find
|
# search for files by name, faster than find
|
||||||
fd
|
fd
|
||||||
# search for files by its content, replacement of grep
|
# search for files by its content, replacement of grep
|
||||||
(ripgrep.override {withPCRE2 = true;})
|
(ripgrep.override {withPCRE2 = true;})
|
||||||
|
|
||||||
# A fast and polyglot tool for code searching, linting, rewriting at large scale
|
# A fast and polyglot tool for code searching, linting, rewriting at large scale
|
||||||
# supported languages: only some mainstream languages currently(do not support nix/nginx/yaml/toml/...)
|
# supported languages: only some mainstream languages currently(do not support nix/nginx/yaml/toml/...)
|
||||||
ast-grep
|
ast-grep
|
||||||
|
|
||||||
sad # CLI search and replace, just like sed, but with diff preview.
|
sad # CLI search and replace, just like sed, but with diff preview.
|
||||||
yq-go # yaml processer https://github.com/mikefarah/yq
|
yq-go # yaml processer https://github.com/mikefarah/yq
|
||||||
just # a command runner like make, but simpler
|
just # a command runner like make, but simpler
|
||||||
delta # A viewer for git and diff output
|
delta # A viewer for git and diff output
|
||||||
lazygit # Git terminal UI.
|
lazygit # Git terminal UI.
|
||||||
hyperfine # command-line benchmarking tool
|
hyperfine # command-line benchmarking tool
|
||||||
gping # ping, but with a graph(TUI)
|
gping # ping, but with a graph(TUI)
|
||||||
doggo # DNS client for humans
|
doggo # DNS client for humans
|
||||||
duf # Disk Usage/Free Utility - a better 'df' alternative
|
duf # Disk Usage/Free Utility - a better 'df' alternative
|
||||||
du-dust # A more intuitive version of `du` in rust
|
du-dust # A more intuitive version of `du` in rust
|
||||||
ncdu # analyzer your disk usage Interactively, via TUI(replacement of `du`)
|
ncdu # analyzer your disk usage Interactively, via TUI(replacement of `du`)
|
||||||
gdu # disk usage analyzer(replacement of `du`)
|
gdu # disk usage analyzer(replacement of `du`)
|
||||||
|
|
||||||
# nix related
|
# nix related
|
||||||
#
|
#
|
||||||
# it provides the command `nom` works just like `nix
|
# it provides the command `nom` works just like `nix
|
||||||
# with more details log output
|
# with more details log output
|
||||||
nix-output-monitor
|
nix-output-monitor
|
||||||
hydra-check # check hydra(nix's build farm) for the build status of a package
|
hydra-check # check hydra(nix's build farm) for the build status of a package
|
||||||
nix-index # A small utility to index nix store paths
|
nix-index # A small utility to index nix store paths
|
||||||
nix-init # generate nix derivation from url
|
nix-init # generate nix derivation from url
|
||||||
# https://github.com/nix-community/nix-melt
|
# https://github.com/nix-community/nix-melt
|
||||||
nix-melt # A TUI flake.lock viewer
|
nix-melt # A TUI flake.lock viewer
|
||||||
# https://github.com/utdemir/nix-tree
|
# https://github.com/utdemir/nix-tree
|
||||||
nix-tree # A TUI to visualize the dependency graph of a nix derivation
|
nix-tree # A TUI to visualize the dependency graph of a nix derivation
|
||||||
|
|
||||||
# productivity
|
|
||||||
caddy # A webserver with automatic HTTPS via Let's Encrypt(replacement of nginx)
|
|
||||||
croc # File transfer between computers securely and easily
|
|
||||||
|
|
||||||
|
# productivity
|
||||||
|
caddy # A webserver with automatic HTTPS via Let's Encrypt(replacement of nginx)
|
||||||
|
croc # File transfer between computers securely and easily
|
||||||
|
]
|
||||||
# self-hosted nix cache server
|
# self-hosted nix cache server
|
||||||
attic.packages.${pkgs.system}.attic-client
|
++ lib.optionals pkgs.stdenv.isLinux [attic.packages.${pkgs.system}.attic-client];
|
||||||
];
|
|
||||||
|
|
||||||
programs = {
|
programs = {
|
||||||
# A modern replacement for ‘ls’
|
# A modern replacement for ‘ls’
|
||||||
|
|||||||
Reference in New Issue
Block a user