helm/profiles/core/default.nix
Anish L 285e319681 refactor core into cli so it can be used from hm as well
this gives me portable shellAliases and direnv
2022-05-22 21:10:29 +10:00

131 lines
3.2 KiB
Nix

{ self, config, lib, pkgs, ... }:
let inherit (lib) fileContents;
in
{
imports = [ ../cachix ];
nix.systemFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ];
fonts = {
fonts = with pkgs; [ powerline-fonts dejavu_fonts ];
fontconfig.defaultFonts = {
monospace = [ "DejaVu Sans Mono for Powerline" ];
sansSerif = [ "DejaVu Sans" ];
};
};
nix = {
autoOptimiseStore = true;
gc.automatic = true;
optimise.automatic = true;
useSandbox = true;
allowedUsers = [ "@wheel" ];
trustedUsers = [ "root" "@wheel" ];
extraOptions = ''
min-free = 536870912
keep-outputs = true
keep-derivations = true
fallback = true
'';
};
#programs.bash = {
# promptInit = ''
# eval "$(starship init bash)"
# '';
# interactiveShellInit = ''
# flakify() {
# if [ ! -e flake.nix ]; then
# nix flake new -t github:nix-community/nix-direnv .
# elif [ ! -e .envrc ]; then
# echo "use flake" > .envrc
# direnv allow
# fi
# vim flake.nix
# }
# export STARSHIP_CONFIG=${
# pkgs.writeText "starship.toml"
# (builtins.readFile ./starship.toml)
# }
# eval "$(${pkgs.direnv}/bin/direnv hook bash)"
# '';
# enableCompletion = true;
#};
programs.zsh.enable = true;
environment = {
shellInit = ''
export STARSHIP_CONFIG=${
pkgs.writeText "starship.toml"
(fileContents ./starship.toml)
}
'';
shellAliases =
let ifSudo = lib.mkIf config.security.sudo.enable;
in
{
# nix
n = "nix";
np = "n profile";
ni = "np install";
nr = "np remove";
ns = "n search --no-update-lock-file";
nf = "n flake";
nepl = "n repl '<nixpkgs>'";
srch = "ns nixos";
orch = "ns override";
nrb = ifSudo "cd /tmp; sudo nixos-rebuild switch --flake '/etc/nixos/#curve'; cd $OLDPWD";
nrt = ifSudo "sudo nixos-rebuild test --flake '/etc/nixos/#curve'";
nedit = "cd /etc/nixos; vim";
ncd = "cd /etc/nixos";
mn = ''
manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | sk --preview="manix '{}'" | xargs manix
'';
# fix nixos-option
nixos-option = "nixos-option -I nixpkgs=${self}/lib/compat";
# sudo
s = ifSudo "sudo -E ";
pls = ifSudo "s";
si = ifSudo "sudo -i";
se = ifSudo "sudoedit";
# top
top = "btm";
# systemd
ctl = "systemctl";
stl = ifSudo "s systemctl";
utl = "systemctl --user";
ut = "systemctl --user start";
un = "systemctl --user stop";
up = ifSudo "s systemctl start";
dn = ifSudo "s systemctl stop";
jtl = "journalctl";
# quick ssh
sm = "ssh 10.0.69.4";
ss = "ssh sealight.xyz";
sc = "ssh lakhwara.com"; # cube
};
};
services.devmon.enable = true;
# For rage encryption, all hosts need a ssh key pair
services.openssh = {
enable = true;
openFirewall = lib.mkDefault false;
};
programs.gnupg.agent.enable = true;
#programs.gnupg.agent.pinentryFlavor = "curses";
services.earlyoom.enable = true;
}