diff --git a/hosts/PABU/applications.nix b/hosts/PABU/applications.nix new file mode 100644 index 0000000..f7aa030 --- /dev/null +++ b/hosts/PABU/applications.nix @@ -0,0 +1,35 @@ +{ pkgs, ... }@inputs: { + + # welcome to nix + programs.nix-ld = { enable = true; }; + + environment.systemPackages = with pkgs; [ + # bare essentials + git + neovim + tmux + eza + expect + fzf + gum + # mason needs stuff + gcc + clang-tools + cargo + nodejs_24 + jdk + tree-sitter + python3 + go + # mason needs stuff + unzip + # telescope + fzf + ripgrep + # stuff + nixd + nixfmt-rfc-style + inputs.agenix.packages.x86_64-linux.default + ]; + +} diff --git a/hosts/PABU/default.nix b/hosts/PABU/default.nix index f31015d..3c076fa 100644 --- a/hosts/PABU/default.nix +++ b/hosts/PABU/default.nix @@ -1,71 +1,9 @@ -{ lib, pkgs, modulesPath, ... }@inputs: { - imports = [ (modulesPath + "/profiles/minimal.nix") ]; - - # Installing a new system within the nspawn means that the /sbin/init script - # just needs to be updated, as there is no bootloader. - system.build.installBootLoader = pkgs.writeScript "install-sbin-init.sh" '' - #!${pkgs.runtimeShell} - ${pkgs.coreutils}/bin/ln -fs "$1/init" /sbin/init - ''; - - system.activationScripts.installInitScript = lib.mkForce '' - ${pkgs.coreutils}/bin/ln -fs $systemConfig/init /sbin/init - ''; - - boot.isContainer = true; - networking.hostName = "PABU"; - - nix = { - settings = { - experimental-features = [ "nix-command" "flakes" ]; - auto-optimise-store = true; - }; - }; - - users.groups.gandalf = { gid = 1000; }; - - users.users.gandalf = { - isNormalUser = true; - home = "/home/gandalf"; - createHome = true; - group = "gandalf"; - extraGroups = [ "wheel" ]; - }; - - security.sudo.wheelNeedsPassword = false; - - # welcome to nix - programs.nix-ld = { enable = true; }; - - environment.systemPackages = with pkgs; [ - - # bare essentials - git - neovim - - # mason needs stuff - gcc - clang-tools - cargo - nodejs_24 - jdk - tree-sitter - python3 - go - - # mason needs stuff - unzip - - # telescope - fzf - ripgrep - - # stuff - nixfmt-rfc-style - - inputs.agenix.packages.x86_64-linux.default - +{ modulesPath, ... }: { + imports = [ + (modulesPath + "/profiles/minimal.nix") + ./applications.nix + ./network.nix + ./system.nix + ./user.nix ]; - - system.stateVersion = "24.05"; } diff --git a/hosts/PABU/network.nix b/hosts/PABU/network.nix new file mode 100644 index 0000000..99cb915 --- /dev/null +++ b/hosts/PABU/network.nix @@ -0,0 +1 @@ +{ networking.hostName = "PABU"; } diff --git a/hosts/PABU/system.nix b/hosts/PABU/system.nix new file mode 100644 index 0000000..23b07a6 --- /dev/null +++ b/hosts/PABU/system.nix @@ -0,0 +1,27 @@ +{ lib, pkgs, ... }: { + + # Installing a new system within the nspawn means that the /sbin/init script + # just needs to be updated, as there is no bootloader. + system.build.installBootLoader = pkgs.writeScript "install-sbin-init.sh" '' + #!${pkgs.runtimeShell} + ${pkgs.coreutils}/bin/ln -fs "$1/init" /sbin/init + ''; + + system.activationScripts.installInitScript = lib.mkForce '' + ${pkgs.coreutils}/bin/ln -fs $systemConfig/init /sbin/init + ''; + + boot.isContainer = true; + + nix = { + settings = { + experimental-features = [ "nix-command" "flakes" ]; + auto-optimise-store = true; + }; + }; + + security.sudo.wheelNeedsPassword = false; + + system.stateVersion = "24.05"; + +} diff --git a/hosts/PABU/user.nix b/hosts/PABU/user.nix new file mode 100644 index 0000000..f72828f --- /dev/null +++ b/hosts/PABU/user.nix @@ -0,0 +1,70 @@ +{ lib, pkgs, ... }: { + + users.groups.gandalf = { gid = 1000; }; + + users.users.gandalf = { + isNormalUser = true; + home = "/home/gandalf"; + createHome = true; + group = "gandalf"; + extraGroups = [ "wheel" ]; + shell = pkgs.zsh; + }; + + programs.zsh = { + enable = true; + ohMyZsh = { + enable = true; + theme = "half-life"; + }; + syntaxHighlighting.enable = true; + enableCompletion = true; + autosuggestions.enable = true; + shellAliases = { + ls = "${pkgs.eza}/bin/eza --group-directories-first --hyperlink --icons"; + la = + "${pkgs.eza}/bin/eza --group-directories-first --hyperlink --icons -la"; + ll = + "${pkgs.expect}/bin/unbuffer ${pkgs.eza}/bin/eza --group-directories-first --hyperlink --icons -la | ${pkgs.less}/bin/less -r"; + lt = + "${pkgs.eza}/bin/eza --group-directories-first --hyperlink --icons -la --tree"; + llt = + "${pkgs.expect}/bin/unbuffer ${pkgs.eza}/bin/eza --group-directories-first --hyperlink --icons -la --tree | ${pkgs.less}/bin/less -r"; + }; + }; + + environment.systemPackages = [ + (pkgs.writeShellScriptBin "n" '' + set -euo pipefail + action=$(${pkgs.gum}/bin/gum choose switch test clean) + target=$(${pkgs.gum}/bin/gum choose PABU APPA MOMO) + case "$action" in + "clean") + case "$target" in + "PABU") + gum log -t kitchen -l info "Running: sudo nix-collect-garbage -d && nix store gc && nix-store --optimise" + sudo nix-collect-garbage -d && nix store gc && nix-store --optimise + ;; + *) + gum log -t kitchen -l info "Running: ssh $target \"nix-collect-garbage -d && nix store gc && nix-store --optimise\"" + ssh $target "nix-collect-garbage -d && nix store gc && nix-store --optimise" + ;; + esac + ;; + *) + case "$target" in + "PABU") + gum log -t kitchen -l info "Running: sudo nixos-rebuild $action --option sandbox false --flake .#PABU" + sudo nixos-rebuild $action --option sandbox false --flake .#PABU + ;; + *) + gum log -t kitchen -l info "Running: nixos-rebuild $action --build-host $target --target-host $target --flake .#$target" + nixos-rebuild $action --build-host $target --target-host $target --flake .#$target + ;; + esac + ;; + esac + '') + ]; + +}