Compare commits

...

3 Commits

Author SHA1 Message Date
Elnu 0efadb66eb elnudrop: nginx & proof of concept server outage handling
9 months ago
Elnu efa926d33f Configure elnudrop
9 months ago
Elnu 5b8dbadbb1 flake.lock: Update
9 months ago

@ -104,11 +104,11 @@
]
},
"locked": {
"lastModified": 1689432596,
"narHash": "sha256-Vixn4nhjeHjGG3o6hDAnSZbXsYMYA5b39+NwAbUPpi0=",
"lastModified": 1690982105,
"narHash": "sha256-32AzoLuwhtxBItcULRiCnxRfJcbVXbPZSH9TDVg21mU=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "346032240c15d8b6034847dc7a5f53312a5a57fc",
"rev": "b2ac1d2c32ac11b8d231d23622cdc4b2f28d07d2",
"type": "github"
},
"original": {
@ -119,11 +119,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1689282004,
"narHash": "sha256-VNhuyb10c9SV+3hZOlxwJwzEGytZ31gN9w4nPCnNvdI=",
"lastModified": 1690881714,
"narHash": "sha256-h/nXluEqdiQHs1oSgkOOWF+j8gcJMWhwnZ9PFabN6q0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e74e68449c385db82de3170288a28cd0f608544f",
"rev": "9e1960bc196baf6881340d53dccb203a951745a2",
"type": "github"
},
"original": {
@ -151,11 +151,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1690548937,
"narHash": "sha256-x3ZOPGLvtC0/+iFAg9Kvqm/8hTAIkGjc634SqtgaXTA=",
"lastModified": 1690031011,
"narHash": "sha256-kzK0P4Smt7CL53YCdZCBbt9uBFFhE0iNvCki20etAf4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2a9d660ff0f7ffde9d73be328ee6e6f10ef66b28",
"rev": "12303c652b881435065a98729eb7278313041e49",
"type": "github"
},
"original": {

@ -5,8 +5,6 @@
# Command line utilities
wget
neofetch
pfetch
fortune
killall
htop
trash-cli # aliased to rm in .bashrc

@ -7,16 +7,6 @@
options = "--delete-generations 8d";
};
networking = {
networkmanager.enable = true;
resolvconf.enable = false; # prevent default nameservers
nameservers = [ "1.1.1.1" "1.0.0.1" ];
extraHosts =
''
192.168.0.26 elnuhub
'';
};
time.timeZone = "America/Los_Angeles";
users.users.${user} = {

@ -11,6 +11,9 @@ let
(import ./home.nix)
inputs.nixvim.homeManagerModules.nixvim
];
desktopHmImports = hmImports ++ [
(import ./home-desktop.nix)
];
hmArgs = { inherit user configDir; };
in
{
@ -30,7 +33,7 @@ in
useUserPackages = true;
extraSpecialArgs = hmArgs;
users.${user} = {
imports = hmImports ++ [
imports = desktopHmImports ++ [
(import ./desktop/home.nix)
];
};
@ -59,7 +62,7 @@ in
useUserPackages = true;
extraSpecialArgs = hmArgs;
users.${user} = {
imports = hmImports ++ [
imports = desktopHmImports ++ [
(import ./thinkpads/home.nix)
];
};
@ -84,7 +87,7 @@ in
useUserPackages = true;
extraSpecialArgs = hmArgs;
users.${user} = {
imports = hmImports ++ [
imports = desktopHmImports ++ [
(import ./thinkpads/home.nix)
];
};
@ -108,7 +111,7 @@ in
useUserPackages = true;
extraSpecialArgs = { inherit user; };
users.${user} = {
imports = hmImports ++ [
imports = desktopHmImports ++ [
(import ./virtualbox/home.nix)
];
};
@ -116,4 +119,27 @@ in
}
];
};
elnudrop = lib.nixosSystem {
inherit system;
specialArgs = { inherit user; };
modules = [
./elnudrop
./configuration.nix
{
networking.hostName = "elnudrop";
}
home-manager.nixosModules.home-manager {
home-manager = {
useUserPackages = true;
extraSpecialArgs = { inherit user; };
users.${user} = {
imports = hmImports ++ [
(import ./elnudrop/home.nix)
];
};
};
}
];
};
}

@ -31,6 +31,12 @@ in
gvfs.enable = true; # For Trash
};
networking = {
networkmanager.enable = true;
resolvconf.enable = false; # prevent default nameservers
nameservers = [ "1.1.1.1" "1.0.0.1" ];
};
xdg.portal.enable = true;
environment.systemPackages = with pkgs; [ yubioath-flutter ];
@ -50,6 +56,11 @@ in
# To prevent `Unit dconf.service not found.` after theming GTK in HM
programs.dconf.enable = true;
networking.extraHosts = ''
192.168.0.26 elnuhub
24.199.72.8 elnudrop
'';
#sound.enable = true;
#hardware.pulseaudio.enable = true;
#nixpkgs.config.pulseaudio = true;

@ -0,0 +1,48 @@
{ lib, user, ... }:
let keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEQNlGt62dBMojVCX7EUIia+wfSDfLzV4YCPi8SZ2xrp elnu@elnu.com"
]; in
{
imports = [
./hardware-configuration.nix
# Remember to update for new instances
./networking.nix # generated at runtime by nixos-infect
];
networking.firewall = {
enable = true;
allowedTCPPorts = [ 80 443 ];
};
security.acme = {
acceptTerms = true;
defaults.email = "elnu@elnu.com";
};
services.nginx = {
enable = true;
virtualHosts = {
"default" = {
default = true;
serverName = null;
# https://stackoverflow.com/a/42802777
locations."/".return = "444";
};
"jichan.org" = {
extraConfig = ''
error_page 502 /502.html;
'';
locations = {
"/" = {
proxyPass = "http://127.0.0.1:8000";
proxyWebsockets = true;
};
"/502.html".root = "${./hosts/jichan.org}";
"/logo.svg".root = "${./hosts/jichan.org}";
"/missing.min.css".root = "${./hosts/jichan.org}";
};
};
};
};
services.do-agent.enable = true;
services.openssh.enable = true;
users.users.root.openssh.authorizedKeys.keys = keys;
users.users.${user}.openssh.authorizedKeys.keys = keys;
}

@ -0,0 +1,9 @@
{ modulesPath, ... }:
{
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
boot.loader.grub.device = "/dev/vda";
boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi" ];
boot.initrd.kernelModules = [ "nvme" ];
fileSystems."/" = { device = "/dev/vda1"; fsType = "ext4"; };
}

@ -0,0 +1,13 @@
{ lib, ... }:
{
imports = [
../../modules/bash
../../modules/neovim
];
# Disable greeter, which is getting run twice somehow
programs.bash = with import ../../modules/bash/bashrc.nix; {
bashrcExtra = lib.mkForce bashrcExtra;
profileExtra = greeter;
};
}

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="missing.min.css"> <!-- missing.css@1.0.9 -->
<style>:root { cursor: inherit } button { cursor: pointer }</style>
<title>jichan.org is offline</title>
</head>
<body>
<main>
<img src="logo.svg" alt="Logo" style="height: 4em; display: block; margin: 1em auto 1em auto">
<p class="<h3>">
<b>jichan.org</b> is currently offline for maintenance or due to an electrical outage.
Thank you for your patience and please check back soon. Sorry for the inconvenience!
</p>
<p lang="ja" class="<h4>">
現在、<b>jichan.org</b>はメンテナンスのため、または停電のためオフラインとなっております。
しばらくお待ちください。ご迷惑をおかけして申し訳ございません!
</p>
<p class="text-align:center">Prolonged outage? <a href="https://discord.com/users/441283734214279178">Notify me on Discord.</a></p>
</main>
</body>
</html>

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="306.39175mm"
height="69.833031mm"
viewBox="0 0 306.39175 69.833031"
version="1.1"
id="svg5"
sodipodi:docname="logo.svg"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="false"
showguides="false"
inkscape:zoom="1.1951475"
inkscape:cx="579.00803"
inkscape:cy="132.20126"
inkscape:window-width="1920"
inkscape:window-height="1048"
inkscape:window-x="1920"
inkscape:window-y="32"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-11.936241,34.186479)">
<g
aria-label="jichan.org"
id="text843"
style="font-weight:bold;font-size:67.7333px;font-family:Arimo;-inkscape-font-specification:'Arimo Bold';letter-spacing:-4.23333px;fill:#ffffff;fill-opacity:0.75;stroke-width:0.264583">
<path
d="m 25.6861,-23.010484 q -3.047998,0 -4.809064,-1.4224 -1.693332,-1.490132 -1.693332,-4.199464 0,-2.438399 1.693332,-3.996265 1.761066,-1.557866 4.809064,-1.557866 3.047999,0 4.741331,1.490133 1.693333,1.422399 1.693333,4.063998 0,2.506132 -1.761066,4.063998 -1.693332,1.557866 -4.673598,1.557866 z m -9.618128,57.302371 -4.131731,-8.398929 q 4.605864,0 6.36693,-1.896533 1.761066,-1.828799 1.761066,-6.705596 v -33.189317 h 10.837328 v 35.763182 q 0,7.450663 -3.860799,10.905061 -3.793064,3.522132 -10.972794,3.522132 z"
style="fill:#d94455;fill-opacity:1"
id="path1545" />
<path
d="m 42.517825,-23.010484 q -3.047998,0 -4.809064,-1.4224 -1.693333,-1.490132 -1.693333,-4.199464 0,-2.438399 1.693333,-3.996265 1.761066,-1.557866 4.809064,-1.557866 3.047999,0 4.741331,1.490133 1.693332,1.422399 1.693332,4.063998 0,2.506132 -1.761065,4.063998 -1.693333,1.557866 -4.673598,1.557866 z m -5.418664,43.078378 v -35.966382 h 10.837328 v 35.966382 z"
style="fill:#d94455;fill-opacity:1"
id="path1547" />
<path
d="m 69.645028,20.745227 q -5.215464,0 -9.347196,-2.438399 -4.131731,-2.438399 -6.57013,-6.637863 -2.370665,-4.267198 -2.370665,-9.6181286 0,-5.3509307 2.370665,-9.5503952 2.438399,-4.2671982 6.57013,-6.7055962 4.131732,-2.438399 9.347196,-2.438399 4.809064,0 8.805329,1.693332 4.063998,1.693333 6.434663,4.741331 l -5.892797,7.0442633 q -1.354666,-1.6933324 -3.589865,-2.8447985 -2.167465,-1.2191994 -4.741331,-1.2191994 -3.860798,0 -6.299197,2.6415987 -2.370665,2.5738653 -2.370665,6.6378633 0,3.9285313 2.438399,6.57013 2.438399,2.6415986 6.231463,2.6415986 2.573866,0 4.605865,-1.015999 2.099732,-1.0159999 3.725331,-2.9125323 l 5.825064,7.1119963 q -2.302932,2.912532 -6.434664,4.605864 -4.063998,1.693333 -8.737595,1.693333 z"
style="fill:#d94455;fill-opacity:1"
id="path1549" />
<path
d="m 86.544497,20.067894 v -50.122641 h 10.634128 v 18.355724 q 1.896532,-2.235199 4.741335,-3.589865 2.91253,-1.354666 6.09599,-1.354666 6.096,0 9.27946,3.725331 3.18347,3.7253317 3.18347,10.9050614 V 20.067894 H 109.57382 V -1.1326287 q 0,-6.57013 -5.55413,-6.3669301 -2.8448,0 -4.741333,1.7610658 -1.896532,1.6933324 -1.896532,4.2671978 V 20.067894 Z"
style="fill:#d94455;fill-opacity:1"
id="path1551" />
<path
d="m 138.59755,20.677494 q -4.53813,0 -8.12799,-2.370666 -3.52214,-2.438399 -5.62187,-6.637863 -2.09973,-4.267198 -2.09973,-9.6181286 0,-5.4863973 2.09973,-9.6858618 2.09973,-4.1994646 5.6896,-6.5701296 3.6576,-2.438399 8.39893,-2.438399 3.52213,0 6.23146,1.422399 2.70933,1.422399 4.4704,3.657598 v -4.334931 h 10.76959 v 35.966382 h -10.97279 v -4.334931 q -1.8288,2.235199 -4.6736,3.589865 -2.77706,1.354666 -6.16373,1.354666 z m 2.98027,-9.143996 q 3.72533,0 5.96053,-2.5738651 2.2352,-2.5738654 2.2352,-6.9087965 0,-4.3349312 -2.2352,-6.9087965 -2.2352,-2.6415987 -5.96053,-2.6415987 -3.6576,0 -5.8928,2.6415987 -2.16747,2.5738653 -2.16747,6.9087965 0,4.3349311 2.16747,6.9087965 2.2352,2.5738651 5.8928,2.5738651 z"
style="fill:#d94455;fill-opacity:1"
id="path1553" />
<path
d="m 165.72476,20.067894 v -35.966382 h 10.29547 l 0.2032,4.334931 q 1.89653,-2.235199 4.80906,-3.657598 2.91253,-1.422399 6.16373,-1.422399 6.096,0 9.27946,3.725331 3.18347,3.7253317 3.18347,10.9050614 V 20.067894 H 188.75409 V -1.1326287 q 0,-6.57013 -5.55413,-6.3669301 -2.8448,0 -4.74134,1.7610658 -1.89653,1.6933324 -1.89653,4.2671978 V 20.067894 Z"
style="fill:#d94455;fill-opacity:1"
id="path1555" />
<path
d="m 208.36291,20.81296 q -2.77707,0 -4.33494,-1.557866 -1.49013,-1.557865 -1.49013,-4.470397 0,-2.709332 1.6256,-4.402665 1.6256,-1.6933323 4.19947,-1.6933323 2.77706,0 4.33493,1.6255993 1.55786,1.557866 1.55786,4.470398 0,2.641598 -1.6256,4.334931 -1.6256,1.693332 -4.26719,1.693332 z"
style="fill:#708090;fill-opacity:1"
id="path1557" />
<path
d="m 234.60955,20.745227 q -5.62186,0 -10.02453,-2.370665 -4.33493,-2.438399 -6.90879,-6.637864 -2.50614,-4.2671977 -2.50614,-9.6858616 0,-5.418664 2.50614,-9.6181285 2.57386,-4.1994649 6.90879,-6.6378629 4.40267,-2.438399 10.02453,-2.438399 5.55413,0 9.88906,2.438399 4.40267,2.438398 6.9088,6.6378629 2.57386,4.1994645 2.57386,9.6181285 0,5.4186639 -2.57386,9.6858616 -2.50613,4.199465 -6.9088,6.637864 -4.33493,2.370665 -9.88906,2.370665 z m 0,-9.347195 q 3.6576,0 6.02826,-2.641599 2.37067,-2.6415987 2.30294,-6.7055966 0.0677,-4.1317313 -2.30294,-6.7733299 -2.37066,-2.6415987 -6.02826,-2.6415987 -3.6576,0 -6.096,2.709332 -2.37066,2.6415986 -2.30293,6.7055966 -0.0677,4.0639979 2.30293,6.7055966 2.4384,2.641599 6.096,2.641599 z"
style="fill:#708090;fill-opacity:1"
id="path1559" />
<path
d="m 256.85999,20.067894 v -35.966382 h 10.29546 l 0.2032,5.486397 q 1.8288,-2.777065 4.60586,-4.470397 2.8448,-1.761066 6.02827,-1.761066 1.2192,0 2.2352,0.2032 1.08373,0.2032 1.96426,0.474133 l -2.98026,11.9887937 q -0.74507,-0.474133 -2.032,-0.7450662 -1.2192,-0.3386665 -2.57387,-0.3386665 -2.98026,0 -4.94453,1.9642656 -1.89653,1.9642657 -1.89653,5.1477308 V 20.067894 Z"
style="fill:#708090;fill-opacity:1"
id="path1561" />
<path
d="m 298.88853,35.646553 q -4.40266,0 -8.80533,-1.286933 -4.33493,-1.286933 -7.04426,-3.318932 l 3.79306,-7.586129 q 2.16747,1.490133 4.8768,2.302932 2.77707,0.880533 5.75733,0.880533 5.08,0 7.5184,-2.302932 2.4384,-2.235199 2.4384,-6.97653 V 15.46203 q -1.76107,1.896532 -4.60587,3.115731 -2.77706,1.2192 -5.8928,1.2192 -4.94453,0 -8.80532,-2.235199 -3.79307,-2.302932 -6.02827,-6.299197 -2.16746,-4.0639979 -2.16746,-9.3471952 0,-5.418664 2.16746,-9.5503952 2.16747,-4.1994646 5.96053,-6.5701296 3.79307,-2.438399 8.5344,-2.438399 3.52213,0 6.5024,1.354666 2.98026,1.286932 4.74133,3.251198 l 0.2032,-3.860798 h 10.29546 v 33.05385 q 0,8.805329 -5.21547,13.614393 -5.14773,4.876798 -14.22399,4.876798 z m 0.27093,-24.248521 q 3.92854,0 6.23147,-2.5061324 2.37066,-2.5738654 2.37066,-6.9087965 0,-4.3349312 -2.37066,-6.9087965 -2.30293,-2.5738654 -6.23147,-2.5738654 -3.86079,0 -6.16373,2.6415987 -2.30293,2.5738653 -2.30293,6.8410632 0,4.2671978 2.30293,6.8410632 2.30294,2.5738657 6.16373,2.5738657 z"
style="fill:#708090;fill-opacity:1"
id="path1563" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.8 KiB

File diff suppressed because one or more lines are too long

@ -0,0 +1,34 @@
{ lib, ... }: {
# This file was populated at runtime with the networking
# details gathered from the active system.
networking = {
nameservers = [ "8.8.8.8"
];
defaultGateway = "146.190.144.1";
defaultGateway6 = {
address = "";
interface = "eth0";
};
dhcpcd.enable = false;
usePredictableInterfaceNames = lib.mkForce false;
interfaces = {
eth0 = {
ipv4.addresses = [
{ address="146.190.153.94"; prefixLength=20; }
{ address="10.48.0.5"; prefixLength=16; }
];
ipv6.addresses = [
{ address="fe80::20db:d1ff:fe51:4175"; prefixLength=64; }
];
ipv4.routes = [ { address = "146.190.144.1"; prefixLength = 32; } ];
# adding route /128... 'ip route add /128 dev eth0' failed: Error: any valid prefix is expected rather than "/128".
#ipv6.routes = [ { address = ""; prefixLength = 128; } ];
};
};
};
services.udev.extraRules = ''
ATTR{address}=="22:db:d1:51:41:75", NAME="eth0"
ATTR{address}=="82:4e:3d:d2:3a:9a", NAME="eth1"
'';
}

@ -0,0 +1,80 @@
{ inputs, config, pkgs, user, ... }:
let
theme = import ../modules/theme;
in
{
imports = [
./apps.nix
../modules/bash
../modules/emacs
../modules/fcitx5
../modules/firefox
../modules/git
../modules/i3
../modules/neovim
../modules/picom
../modules/polybar
../modules/ranger
../modules/rofi
../modules/startpage
../modules/terminal
../modules/todo-txt
../modules/fantasia-archive
];
home.file."./.background-image".source = theme.wallpaper;
programs.home-manager.enable = true;
xdg = {
userDirs = rec {
enable = true;
desktop = "${config.home.homeDirectory}"; # weird hack for disabling desktop in nautilus
documents = null;
music = null;
pictures = "${publicShare}/Pictures";
templates = null;
publicShare = "${config.home.homeDirectory}/Nextcloud";
};
mimeApps = {
enable = true;
defaultApplications = {
# Make sure directories are opened in nautilus
# .desktop files can be found in /etc/profiles/per-user/elnu/share/applications
# mimetypes can be found with the mimetype command:
# nix-shell -p perl536Packages.FileMimeInfo
"inode/directory" = "org.gnome.Nautilus.desktop";
"application/zip" = "org.gnome.FileRoller.desktop";
"application/octet-stream" = "org.gnome.GHex.desktop";
};
};
};
programs.direnv.enable = true;
gtk = {
enable = true;
iconTheme = theme.gtkIconTheme pkgs;
theme = theme.gtkTheme pkgs;
gtk3 = {
bookmarks = let
home = "file://${config.home.homeDirectory}/";
in [
"${home}Nextcloud"
"${home}Projects"
"${home}nix-config Config"
"sftp://elnu@elnuhub elnuhub"
];
# Remove minimize, maximize, and close buttons
extraConfig.gtk-decoration-layout = "appmenu:none";
};
gtk4.extraConfig.gtk-decoration-layout = "appmenu:none";
};
qt = {
enable = true;
platformTheme = "gtk";
};
}

@ -1,82 +1,6 @@
{ inputs, config, pkgs, user, ... }:
{ user, ... }:
let
theme = import ../modules/theme;
in
{
imports = [
./apps.nix
../modules/emacs
../modules/fcitx5
../modules/firefox
../modules/git
../modules/i3
../modules/neovim
../modules/picom
../modules/polybar
../modules/ranger
../modules/rofi
../modules/startpage
../modules/terminal
../modules/todo-txt
../modules/fantasia-archive
];
home.file."./.background-image".source = theme.wallpaper;
programs.home-manager.enable = true;
xdg = {
userDirs = rec {
enable = true;
desktop = "${config.home.homeDirectory}"; # weird hack for disabling desktop in nautilus
documents = null;
music = null;
pictures = "${publicShare}/Pictures";
templates = null;
publicShare = "${config.home.homeDirectory}/Nextcloud";
};
mimeApps = {
enable = true;
defaultApplications = {
# Make sure directories are opened in nautilus
# .desktop files can be found in /etc/profiles/per-user/elnu/share/applications
# mimetypes can be found with the mimetype command:
# nix-shell -p perl536Packages.FileMimeInfo
"inode/directory" = "org.gnome.Nautilus.desktop";
"application/zip" = "org.gnome.FileRoller.desktop";
"application/octet-stream" = "org.gnome.GHex.desktop";
};
};
};
programs.direnv.enable = true;
gtk = {
enable = true;
iconTheme = theme.gtkIconTheme pkgs;
theme = theme.gtkTheme pkgs;
gtk3 = {
bookmarks = let
home = "file://${config.home.homeDirectory}/";
in [
"${home}Nextcloud"
"${home}Projects"
"${home}nix-config Config"
"sftp://elnu@elnuhub elnuhub"
];
# Remove minimize, maximize, and close buttons
extraConfig.gtk-decoration-layout = "appmenu:none";
};
gtk4.extraConfig.gtk-decoration-layout = "appmenu:none";
};
qt = {
enable = true;
platformTheme = "gtk";
};
home = {
username = "${user}";
homeDirectory = "/home/${user}";
@ -86,78 +10,4 @@ in
stateVersion = "22.05";
};
programs.bash = {
enable = true;
shellAliases = {
g = "git";
ga = "g add";
gc = "g commit -m ";
gu = "ga . && gc";
gs = "g status";
gi = "g init";
gp = "g push";
gf = "g pull";
gC = "g clone";
goops = "g reset --soft HEAD^";
r = "ranger";
rm = "trash-put";
emacs = "emacsclient -nw";
# Make clear command clear scrollback
# https://github.com/kovidgoyal/kitty/issues/268#issuecomment-355765686
clear = "printf '\\E[H\\E[3J'";
};
bashrcExtra = ''
function v {
if [[ $# -eq 0 ]]; then
nvim ~/UNTITLED.md
else
nvim $1
fi
}
# Modify killall for wrapped applications, e.g. firefox
# killall firefox -> killall firefox || killall .firefox-wrapped
function killall {
`which killall` $1 || `which killall` .''${1}-wrapped
}
# pandoc macro
# pandoc document.md -> pandoc document.md -o document.pdf ...
function pdf {
pandoc $1 -o ''${1%.*}.pdf --pdf-engine=xelatex -V mainfont="mplus-1c-medium" -V colorlinks=true -V linkcolor=blue
}
# Change to directory when exiting ranger with Q
# https://github.com/ranger/ranger/issues/1554#issuecomment-491650123
function ranger {
local IFS=$'\t\n'
local tempfile="$(mktemp -t tmp.XXXXXX)"
local ranger_cmd=(
command
ranger
--cmd="map Q chain shell echo %d > "$tempfile"; quitall"
)
''${ranger_cmd[@]} "$@"
if [[ -f "$tempfile" ]] && [[ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]]; then
cd -- "$(cat "$tempfile")" || return
fi
command rm -f -- "$tempfile" 2>/dev/null
}
if [ -z $TERMINAL_STARTED ] && [ -z $IN_NIX_SHELL ]; then
pfetch
while true; do
f=`fortune`
if [ ''${#f} -lt 128 ]; then
echo "''${f}"
break
fi
done
TERMINAL_STARTED=1
fi
'';
};
}
}

@ -0,0 +1,52 @@
{
bashrcExtra = ''
function v {
if [[ $# -eq 0 ]]; then
nvim ~/UNTITLED.md
else
nvim $1
fi
}
# Modify killall for wrapped applications, e.g. firefox
# killall firefox -> killall firefox || killall .firefox-wrapped
function killall {
`which killall` $1 || `which killall` .''${1}-wrapped
}
# pandoc macro
# pandoc document.md -> pandoc document.md -o document.pdf ...
function pdf {
pandoc $1 -o ''${1%.*}.pdf --pdf-engine=xelatex -V mainfont="mplus-1c-medium" -V colorlinks=true -V linkcolor=blue
}
# Change to directory when exiting ranger with Q
# https://github.com/ranger/ranger/issues/1554#issuecomment-491650123
function ranger {
local IFS=$'\t\n'
local tempfile="$(mktemp -t tmp.XXXXXX)"
local ranger_cmd=(
command
ranger
--cmd="map Q chain shell echo %d > "$tempfile"; quitall"
)
''${ranger_cmd[@]} "$@"
if [[ -f "$tempfile" ]] && [[ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]]; then
cd -- "$(cat "$tempfile")" || return
fi
command rm -f -- "$tempfile" 2>/dev/null
}
'';
greeter = ''
pfetch
while true; do
f=`fortune`
if [ ''${#f} -lt 128 ]; then
echo "''${f}"
break
fi
done
TERMINAL_STARTED=1
'';
}

@ -0,0 +1,34 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [ pfetch fortune ];
programs.bash = {
enable = true;
shellAliases = {
g = "git";
ga = "g add";
gc = "g commit -m ";
gu = "ga . && gc";
gs = "g status";
gi = "g init";
gp = "g push";
gf = "g pull";
gC = "g clone";
goops = "g reset --soft HEAD^";
r = "ranger";
rm = "trash-put";
emacs = "emacsclient -nw";
# Make clear command clear scrollback
# https://github.com/kovidgoyal/kitty/issues/268#issuecomment-355765686
clear = "printf '\\E[H\\E[3J'";
};
bashrcExtra = with import ./bashrc.nix; ''
${bashrcExtra}
if [ -z $TERMINAL_STARTED ] && [ -z $IN_NIX_SHELL ]; then
${greeter}
fi
'';
};
}
Loading…
Cancel
Save