diff --git a/hosts/configuration.nix b/hosts/configuration.nix index dbbb6ec..d4096ba 100644 --- a/hosts/configuration.nix +++ b/hosts/configuration.nix @@ -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} = { diff --git a/hosts/default.nix b/hosts/default.nix index 1378030..670037b 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -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) + ]; + }; + }; + } + ]; + }; } diff --git a/hosts/desktop.nix b/hosts/desktop.nix index 595a38a..9d51130 100644 --- a/hosts/desktop.nix +++ b/hosts/desktop.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; diff --git a/hosts/elnudrop/default.nix b/hosts/elnudrop/default.nix new file mode 100644 index 0000000..7fea568 --- /dev/null +++ b/hosts/elnudrop/default.nix @@ -0,0 +1,16 @@ +{ 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 + ]; + services.do-agent.enable = true; + services.openssh.enable = true; + users.users.root.openssh.authorizedKeys.keys = keys; + users.users.${user}.openssh.authorizedKeys.keys = keys; +} \ No newline at end of file diff --git a/hosts/elnudrop/hardware-configuration.nix b/hosts/elnudrop/hardware-configuration.nix new file mode 100644 index 0000000..7623409 --- /dev/null +++ b/hosts/elnudrop/hardware-configuration.nix @@ -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"; }; +} \ No newline at end of file diff --git a/hosts/elnudrop/home.nix b/hosts/elnudrop/home.nix new file mode 100644 index 0000000..864b919 --- /dev/null +++ b/hosts/elnudrop/home.nix @@ -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; + }; +} \ No newline at end of file diff --git a/hosts/elnudrop/networking.nix b/hosts/elnudrop/networking.nix new file mode 100644 index 0000000..516c4ae --- /dev/null +++ b/hosts/elnudrop/networking.nix @@ -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" + ''; +} \ No newline at end of file diff --git a/hosts/home-desktop.nix b/hosts/home-desktop.nix new file mode 100644 index 0000000..9857763 --- /dev/null +++ b/hosts/home-desktop.nix @@ -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"; + }; +} diff --git a/hosts/home.nix b/hosts/home.nix index 4493277..4090a4b 100644 --- a/hosts/home.nix +++ b/hosts/home.nix @@ -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 - ''; - }; -} +} \ No newline at end of file diff --git a/modules/bash/bashrc.nix b/modules/bash/bashrc.nix new file mode 100644 index 0000000..fcffe62 --- /dev/null +++ b/modules/bash/bashrc.nix @@ -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 + ''; +} \ No newline at end of file diff --git a/modules/bash/default.nix b/modules/bash/default.nix new file mode 100644 index 0000000..6950a4f --- /dev/null +++ b/modules/bash/default.nix @@ -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 + ''; + }; +} \ No newline at end of file