diff options
| author | Preston Pan <ret2pop@gmail.com> | 2025-09-07 00:37:22 -0700 |
|---|---|---|
| committer | Preston Pan <ret2pop@gmail.com> | 2025-09-07 00:37:22 -0700 |
| commit | 8f4f46e59ad0b7c5662a417d10f3074f17c962c3 (patch) | |
| tree | 0559b33322f902e76498b5864f39d8c663ce45a8 /nix | |
| parent | 262a367c90362403ed5e0b4db41daf20e191538c (diff) | |
big update; fix vps and streamline some stuff
Diffstat (limited to 'nix')
| -rw-r--r-- | nix/disko/vda-simple.nix | 1 | ||||
| -rw-r--r-- | nix/flake.nix | 21 | ||||
| -rw-r--r-- | nix/modules/configuration.nix | 4 | ||||
| -rw-r--r-- | nix/modules/home/default.nix | 34 | ||||
| -rw-r--r-- | nix/modules/home/fcitx.nix | 5 | ||||
| -rw-r--r-- | nix/modules/home/user.nix | 1 | ||||
| -rw-r--r-- | nix/modules/home/zsh.nix | 5 | ||||
| -rw-r--r-- | nix/modules/xserver.nix | 4 | ||||
| -rw-r--r-- | nix/systems/installer/commits.nix | 1 | ||||
| -rw-r--r-- | nix/systems/installer/default.nix | 46 | ||||
| -rw-r--r-- | nix/systems/spontaneity/default.nix | 3 |
11 files changed, 72 insertions, 53 deletions
diff --git a/nix/disko/vda-simple.nix b/nix/disko/vda-simple.nix index 32fa28d..3ae1d34 100644 --- a/nix/disko/vda-simple.nix +++ b/nix/disko/vda-simple.nix @@ -12,6 +12,7 @@ type = "EF02"; }; root = { + label = "disk-main-root"; size = "100%"; content = { type = "filesystem"; diff --git a/nix/flake.nix b/nix/flake.nix index 4b08aa9..021bcce 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -35,6 +35,13 @@ outputs = { self, nixpkgs, home-manager, nur, disko, lanzaboote, sops-nix, nix-topology, nixos-dns, deep-research, ... }@attrs: let + hostnames = [ + "affinity" + "continuity" + "installer" + "spontaneity" + # add hostnames here + ]; system = "x86_64-linux"; pkgs = import nixpkgs { inherit system; }; generate = nixos-dns.utils.generate nixpkgs.legacyPackages."${system}"; @@ -42,8 +49,7 @@ inherit (self) nixosConfigurations; extraConfig = import ./dns/default.nix; }; - mkConfigs = map (hostname: { - name = "${hostname}"; + mkConfigs = map (hostname: {name = "${hostname}"; value = nixpkgs.lib.nixosSystem { inherit system; specialArgs = attrs; @@ -54,7 +60,7 @@ ] else [ { environment.systemPackages = with nixpkgs.lib; [ - deep-research.packages.${system}.deep-research + deep-research.packages."${system}".deep-research ]; } nix-topology.nixosModules.default @@ -65,7 +71,7 @@ nixos-dns.nixosModules.dns { nixpkgs.overlays = [ nur.overlays.default ]; - home-manager.extraSpecialArgs = attrs; + home-manager.extraSpecialArgs = attrs // { systemHostName = "${hostname}"; }; networking.hostName = "${hostname}"; } (./. + "/systems/${hostname}/default.nix") @@ -74,12 +80,7 @@ }); in { # add new systems here - nixosConfigurations = builtins.listToAttrs (mkConfigs [ - "affinity" - "continuity" - "installer" - "spontaneity" - ]); + nixosConfigurations = builtins.listToAttrs (mkConfigs hostnames); topology."${system}" = import nix-topology { pkgs = import nixpkgs { diff --git a/nix/modules/configuration.nix b/nix/modules/configuration.nix index 5439682..caeb1f7 100644 --- a/nix/modules/configuration.nix +++ b/nix/modules/configuration.nix @@ -78,7 +78,7 @@ loader = { systemd-boot.enable = lib.mkForce (! config.monorepo.profiles.grub.enable); - efi.canTouchEfiVariables = lib.mkDefault (! config.monorepo.profiles.grub.enable); + efi.canTouchEfiVariables = lib.mkForce (! config.monorepo.profiles.grub.enable); }; kernelModules = [ @@ -273,7 +273,7 @@ auditd.enable = true; audit.enable = true; - chromiumSuidSandbox.enable = true; + chromiumSuidSandbox.enable = (! config.monorepo.profiles.ttyonly.enable); sudo.enable = true; }; diff --git a/nix/modules/home/default.nix b/nix/modules/home/default.nix index 614373b..52174a9 100644 --- a/nix/modules/home/default.nix +++ b/nix/modules/home/default.nix @@ -175,26 +175,26 @@ monorepo.profiles = { enable = lib.mkDefault true; - music.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - hyprland.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - email.enable = lib.mkDefault (true && config.monorepo.profiles.enable); + music.enable = lib.mkDefault config.monorepo.profiles.enable; + hyprland.enable = lib.mkDefault config.monorepo.profiles.enable; + email.enable = lib.mkDefault config.monorepo.profiles.enable; # Programming - graphics.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - lang-c.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - lang-rust.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - lang-python.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - lang-sol.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - lang-sh.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - lang-openscad.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - lang-js.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - lang-nix.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - lang-coq.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - lang-haskell.enable = lib.mkDefault (true && config.monorepo.profiles.enable); + graphics.enable = lib.mkDefault config.monorepo.profiles.enable; + lang-c.enable = lib.mkDefault config.monorepo.profiles.enable; + lang-rust.enable = lib.mkDefault config.monorepo.profiles.enable; + lang-python.enable = lib.mkDefault config.monorepo.profiles.enable; + lang-sol.enable = lib.mkDefault config.monorepo.profiles.enable; + lang-sh.enable = lib.mkDefault config.monorepo.profiles.enable; + lang-openscad.enable = lib.mkDefault config.monorepo.profiles.enable; + lang-js.enable = lib.mkDefault config.monorepo.profiles.enable; + lang-nix.enable = lib.mkDefault config.monorepo.profiles.enable; + lang-coq.enable = lib.mkDefault config.monorepo.profiles.enable; + lang-haskell.enable = lib.mkDefault config.monorepo.profiles.enable; - crypto.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - art.enable = lib.mkDefault (true && config.monorepo.profiles.enable); - workstation.enable = lib.mkDefault (true && config.monorepo.profiles.enable); + crypto.enable = lib.mkDefault config.monorepo.profiles.enable; + art.enable = lib.mkDefault config.monorepo.profiles.enable; + workstation.enable = lib.mkDefault config.monorepo.profiles.enable; }; }; } diff --git a/nix/modules/home/fcitx.nix b/nix/modules/home/fcitx.nix index 05dd8f7..bedfdf2 100644 --- a/nix/modules/home/fcitx.nix +++ b/nix/modules/home/fcitx.nix @@ -1,7 +1,8 @@ -{ pkgs, ... }: +{ config, pkgs, lib, ... }: { i18n.inputMethod = { - enabled = "fcitx5"; + type = "fcitx5"; + enable = lib.mkDefault config.monorepo.profiles.graphics.enable; fcitx5.addons = with pkgs; [ fcitx5-gtk fcitx5-chinese-addons diff --git a/nix/modules/home/user.nix b/nix/modules/home/user.nix index 0864baf..1e88b75 100644 --- a/nix/modules/home/user.nix +++ b/nix/modules/home/user.nix @@ -104,5 +104,4 @@ nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos- }; fonts.fontconfig.enable = true; - nixpkgs.config.cudaSupport = lib.mkDefault config.monorepo.profiles.cuda.enable; } diff --git a/nix/modules/home/zsh.nix b/nix/modules/home/zsh.nix index 31c7680..9f848bc 100644 --- a/nix/modules/home/zsh.nix +++ b/nix/modules/home/zsh.nix @@ -1,4 +1,4 @@ -{ lib, config, pkgs, ... }: +{ lib, config, pkgs, systemHostName, ... }: { programs.zsh = { enable = true; @@ -25,8 +25,7 @@ g = "git"; v = "vim"; py = "python3"; - rb = "sudo nixos-rebuild switch --flake .#continuity"; - rba = "sudo nixos-rebuild switch --flake .#affinity"; + rb = "sudo nixos-rebuild switch --flake .#${systemHostName}"; nfu = "cd ~/monorepo/nix && git add . && git commit -m \"new flake lock\" && nix flake update"; usync = "rsync -azvP --chmod=\"Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r\" ~/website_html/ root@${config.monorepo.vars.remoteHost}:/var/www/ret2pop-website/"; usite diff --git a/nix/modules/xserver.nix b/nix/modules/xserver.nix index aab138d..0d5b29c 100644 --- a/nix/modules/xserver.nix +++ b/nix/modules/xserver.nix @@ -1,9 +1,9 @@ { lib, config, pkgs, ... }: { services.xserver = { - enable = lib.mkDefault true; + enable = (! config.monorepo.profiles.ttyonly.enable); displayManager = { - startx.enable = true; + startx.enable = (! config.monorepo.profiles.ttyonly.enable); }; windowManager = { diff --git a/nix/systems/installer/commits.nix b/nix/systems/installer/commits.nix index cf5d66c..bf865a3 100644 --- a/nix/systems/installer/commits.nix +++ b/nix/systems/installer/commits.nix @@ -1,4 +1,5 @@ { diskoCommitHash = "a5c4f2ab72e3d1ab43e3e65aa421c6f2bd2e12a1"; monorepoCommitHash = "af3c15c43c65fd77aab441f4c657aeaa74cc67d5"; + monorepoUrl = "https://github.com/ret2pop/monorepo"; } diff --git a/nix/systems/installer/default.nix b/nix/systems/installer/default.nix index 5541ecb..75f0b81 100644 --- a/nix/systems/installer/default.nix +++ b/nix/systems/installer/default.nix @@ -50,12 +50,21 @@ if [ "$(id -u)" -eq 0 ]; then exit 1 fi -if [ -z "$SYSTEM" ]; then - SYSTEM=continuity +gum style --border normal --margin "1" --padding "1 2" "Choose a system to install or select `new` in order to create a new system." + +SYSTEM="$(gum choose "$(find "$HOME/monorepo/nix/systems" -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | grep -v -E 'installer'; printf "New")")" + +if [[ "$SYSTEM" == "New" ]]; then + gum style --border normal --margin "1" --padding "1 2" "Choose a system name" + SYSTEM="$(gum input --placeholder "system name")" fi -if [ -z "$DRIVE" ]; then - DRIVE=sda-simple +gum style --border normal --margin "1" --padding "1 2" "Select a drive file or create a new drive file." +DRIVE="$(gum choose "$(find "$HOME/monorepo/nix/disko" -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | printf "New")")" + +if [[ "$DRIVE" == "New" ]]; then + gum style --border normal --margin "1" --padding "1 2" "Choose a name to call your drive file." + SYSTEM="$(gum input --placeholder "drive file name (ex: my_sda.nix)")" fi ping -q -c1 google.com &>/dev/null && echo "online! Proceeding with the installation..." || nmtui @@ -63,9 +72,10 @@ ping -q -c1 google.com &>/dev/null && echo "online! Proceeding with the installa cd "$HOME" if [ ! -d "$HOME/monorepo/" ]; then - git clone https://git.nullring.xyz/monorepo.git - cd monorepo + git clone ${commits.monorepoUrl} + cd "$HOME/monorepo" git checkout "${commits.monorepoCommitHash}" + cd "$HOME" fi @@ -77,7 +87,7 @@ if [ ! -d "$HOME/monorepo/nix/systems/$SYSTEM" ]; then { imports = [ ../../modules/default.nix - ../../disko/$DRIVE.nix + ../../disko/$DRIVE ../home.nix ]; } @@ -87,17 +97,21 @@ EOF gum input --placeholder "Press Enter to continue" >/dev/null vim "$HOME/monorepo/nix/systems/$SYSTEM/default.nix" - sed -i "/mkConfigs \[/,/\]/ s/^\(\s*\)\]/\1 \"$SYSTEM\"\n\1]/" "$HOME/monorepo/nix/flake.nix" -fi + sed -i "/hostnames = \[/,/];/ { /];/i \ \"your-hostname-$SYSTEM\" }" "$HOME/monorepo/nix/flake.nix" -if [ ! -f "$HOME/monorepo/nix/disko/$DRIVE.nix" ]; then - cp "$HOME/monorepo/nix/disko/sda-simple.nix" "$HOME/monorepo/nix/disko/$DRIVE.nix" - gum style --border normal --margin "1" --padding "1 2" "Edit the drive file with your preferred partitioning scheme." - gum input --placeholder "Press Enter to continue" >/dev/null - vim "$HOME/monorepo/nix/disko/$DRIVE.nix" + if [ ! -f "$HOME/monorepo/nix/disko/$DRIVE" ]; then + cp "$HOME/monorepo/nix/disko/sda-simple.nix" "$HOME/monorepo/nix/disko/$DRIVE" + gum style --border normal --margin "1" --padding "1 2" "Edit the drive file with your preferred partitioning scheme." + gum input --placeholder "Press Enter to continue" >/dev/null + vim "$HOME/monorepo/nix/disko/$DRIVE" + fi + cd "$HOME/monorepo" && git add . && cd "$HOME" fi -cd "$HOME/monorepo" && git add . && cd "$HOME" +if [ ! -f "$HOME/monorepo/nix/disko/$DRIVE" ]; then + echo "error: you should create a new system if you use a drive file that is not in the repo." + exit 1 +fi gum style --border normal --margin "1" --padding "1 2" "Formatting the drive is destructive!" if gum confirm "Are you sure you want to continue?"; then @@ -107,7 +121,7 @@ else exit 1 fi -sudo nix --experimental-features "nix-command flakes" run "github:nix-community/disko/${commits.diskoCommitHash}" -- --mode destroy,format,mount "$HOME/monorepo/nix/disko/$DRIVE.nix" +sudo nix --experimental-features "nix-command flakes" run "github:nix-community/disko/${commits.diskoCommitHash}" -- --mode destroy,format,mount "$HOME/monorepo/nix/disko/$DRIVE" cd /mnt sudo nixos-install --flake "$HOME/monorepo/nix#$SYSTEM" diff --git a/nix/systems/spontaneity/default.nix b/nix/systems/spontaneity/default.nix index 776149d..3aa0a39 100644 --- a/nix/systems/spontaneity/default.nix +++ b/nix/systems/spontaneity/default.nix @@ -15,6 +15,8 @@ grub.enable = true; }; }; + + boot.loader.grub.device = "nodev"; networking = { firewall.allowedTCPPorts = [ 80 @@ -44,6 +46,7 @@ "mail.${config.monorepo.vars.remoteHost}" = {}; "nullring.xyz" = {}; + "git.nullring.xyz" = {}; "matrix.nullring.xyz" = {}; "talk.nullring.xyz" = {}; "mail.nullring.xyz" = {}; |
