diff options
author | Preston Pan <ret2pop@gmail.com> | 2025-02-05 03:38:52 -0800 |
---|---|---|
committer | Preston Pan <ret2pop@gmail.com> | 2025-02-05 03:38:52 -0800 |
commit | 56faa5e9caf4408c2c4d6df50287c3b1c9e6c1b4 (patch) | |
tree | 188362e97ecfd0f935b1ac1efc1c3cfb00ef616e /nix | |
parent | 990134fdcefe5a520b09ac6dfcaf97066fde6685 (diff) |
Finish automation of spontaneity cloud deployments
Diffstat (limited to 'nix')
-rw-r--r-- | nix/flake.nix | 1 | ||||
-rw-r--r-- | nix/modules/configuration.nix | 4 | ||||
-rw-r--r-- | nix/modules/default.nix | 4 | ||||
-rw-r--r-- | nix/modules/home/default.nix | 312 | ||||
-rw-r--r-- | nix/modules/home/emacs.nix | 2 | ||||
-rw-r--r-- | nix/modules/home/firefox.nix | 2 | ||||
-rw-r--r-- | nix/modules/home/gammastep.nix | 2 | ||||
-rw-r--r-- | nix/modules/home/git.nix | 2 | ||||
-rw-r--r-- | nix/modules/home/kitty.nix | 2 | ||||
-rw-r--r-- | nix/modules/home/mako.nix | 2 | ||||
-rw-r--r-- | nix/modules/home/mpv.nix | 2 | ||||
-rw-r--r-- | nix/modules/home/user.nix | 25 | ||||
-rw-r--r-- | nix/modules/home/wofi.nix | 2 | ||||
-rw-r--r-- | nix/modules/home/yt-dlp.nix | 2 | ||||
-rw-r--r-- | nix/modules/vda-simple.nix | 16 | ||||
-rw-r--r-- | nix/systems/spontaneity/default.nix | 1 | ||||
-rw-r--r-- | nix/systems/spontaneity/hardware-configuration.nix | 23 | ||||
-rw-r--r-- | nix/systems/spontaneity/home.nix | 1 |
18 files changed, 219 insertions, 186 deletions
diff --git a/nix/flake.nix b/nix/flake.nix index 39606b4..4c703cd 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -79,6 +79,7 @@ sops-nix.nixosModules.sops { nixpkgs.overlays = [ nur.overlays.default ]; } { home-manager.extraSpecialArgs = attrs; } + ./systems/spontaneity/hardware-configuration.nix ./systems/spontaneity/default.nix ]; }; diff --git a/nix/modules/configuration.nix b/nix/modules/configuration.nix index 62b02f6..36a1702 100644 --- a/nix/modules/configuration.nix +++ b/nix/modules/configuration.nix @@ -71,8 +71,8 @@ }; loader = { - systemd-boot.enable = lib.mkForce (! config.monorepo.profiles.secureBoot.enable); - efi.canTouchEfiVariables = true; + systemd-boot.enable = lib.mkForce (! config.monorepo.profiles.grub.enable); + efi.canTouchEfiVariables = lib.mkDefault (! config.monorepo.profiles.grub.enable); }; kernelModules = [ diff --git a/nix/modules/default.nix b/nix/modules/default.nix index f520d3b..50e5a1b 100644 --- a/nix/modules/default.nix +++ b/nix/modules/default.nix @@ -16,6 +16,7 @@ home.enable = lib.mkEnableOption "Enables home user"; server.enable = lib.mkEnableOption "Enables server services"; ttyonly.enable = lib.mkEnableOption "TTY only, no xserver"; + grub.enable = lib.mkEnableOption "Enables grub instead of systemd-boot"; }; }; }; @@ -26,6 +27,9 @@ man-pages man-pages-posix ]); + boot.loader.grub = lib.mkIf config.monorepo.profiles.grub.enable { + enable = true; + }; monorepo = { profiles = { diff --git a/nix/modules/home/default.nix b/nix/modules/home/default.nix index edefc9e..45b0890 100644 --- a/nix/modules/home/default.nix +++ b/nix/modules/home/default.nix @@ -24,172 +24,174 @@ options = { monorepo.profiles = { - enable = lib.mkEnableOption "Enables home manager desktop configuration"; - # Programs - lang-c.enable = lib.mkEnableOption "Enables C language support"; - lang-sh.enable = lib.mkEnableOption "Enables sh language support"; - lang-rust.enable = lib.mkEnableOption "Enables Rust language support"; - lang-python.enable = lib.mkEnableOption "Enables python language support"; - lang-sol.enable = lib.mkEnableOption "Enables solidity language support"; - lang-openscad.enable = lib.mkEnableOption "Enables openscad language support"; - lang-js.enable = lib.mkEnableOption "Enables javascript language support"; - lang-nix.enable = lib.mkEnableOption "Enables nix language support"; - lang-coq.enable = lib.mkEnableOption "Enables coq language support"; + enable = lib.mkEnableOption "Enables home manager desktop configuration"; + # Programs + graphics.enable = lib.mkEnableOption "Enables graphical programs for user"; + lang-c.enable = lib.mkEnableOption "Enables C language support"; + lang-sh.enable = lib.mkEnableOption "Enables sh language support"; + lang-rust.enable = lib.mkEnableOption "Enables Rust language support"; + lang-python.enable = lib.mkEnableOption "Enables python language support"; + lang-sol.enable = lib.mkEnableOption "Enables solidity language support"; + lang-openscad.enable = lib.mkEnableOption "Enables openscad language support"; + lang-js.enable = lib.mkEnableOption "Enables javascript language support"; + lang-nix.enable = lib.mkEnableOption "Enables nix language support"; + lang-coq.enable = lib.mkEnableOption "Enables coq language support"; - crypto.enable = lib.mkEnableOption "Enables various cryptocurrency wallets"; - art.enable = lib.mkEnableOption "Enables various art programs"; - music.enable = lib.mkEnableOption "Enables mpd"; - workstation.enable = lib.mkEnableOption "Enables workstation packages (music production and others)"; - cuda.enable = lib.mkEnableOption "Enables CUDA user package builds"; + crypto.enable = lib.mkEnableOption "Enables various cryptocurrency wallets"; + art.enable = lib.mkEnableOption "Enables various art programs"; + music.enable = lib.mkEnableOption "Enables mpd"; + workstation.enable = lib.mkEnableOption "Enables workstation packages (music production and others)"; + cuda.enable = lib.mkEnableOption "Enables CUDA user package builds"; - hyprland = { - enable = lib.mkEnableOption "Enables hyprland"; - monitors = lib.mkOption { - type = lib.types.listOf lib.types.str; - default = [ - "HDMI-A-1" - "eDP-1" - "DP-2" - "DP-3" - "LVDS-1" - "DP-4" - ]; - example = []; - description = "Hyprland monitors"; - }; - }; - email = { - email = lib.mkOption { - type = lib.types.str; - default = "ret2pop@gmail.com"; - example = "john@example.com"; - description = "Email address and imaps/smtps account"; - }; - imapsServer = lib.mkOption { - type = lib.types.str; - default = "imap.gmail.com"; - example = "imap.example.com"; - description = "imaps server address"; - }; - smtpsServer = lib.mkOption { - type = lib.types.str; - default = "smtp.gmail.com"; - example = "smtp.example.com"; - description = "smtp server address"; - }; - enable = lib.mkEnableOption "Enables email"; - }; + hyprland = { + enable = lib.mkEnableOption "Enables hyprland"; + monitors = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ + "HDMI-A-1" + "eDP-1" + "DP-2" + "DP-3" + "LVDS-1" + "DP-4" + ]; + example = []; + description = "Hyprland monitors"; + }; + }; + email = { + email = lib.mkOption { + type = lib.types.str; + default = "ret2pop@gmail.com"; + example = "john@example.com"; + description = "Email address and imaps/smtps account"; + }; + imapsServer = lib.mkOption { + type = lib.types.str; + default = "imap.gmail.com"; + example = "imap.example.com"; + description = "imaps server address"; + }; + smtpsServer = lib.mkOption { + type = lib.types.str; + default = "smtp.gmail.com"; + example = "smtp.example.com"; + description = "smtp server address"; + }; + enable = lib.mkEnableOption "Enables email"; + }; }; }; config = { home.packages = (if config.monorepo.profiles.email.enable then [ pkgs.mu ] else []) - ++ - (if config.monorepo.profiles.lang-c.enable then (with pkgs; [ - autobuild - clang - gdb - gnumake - bear - clang-tools - ]) else []) - ++ - (if config.monorepo.profiles.lang-js.enable then (with pkgs; [ - nodejs - bun - yarn - typescript - vscode-langservers-extracted - ]) else []) - ++ - (if config.monorepo.profiles.lang-rust.enable then (with pkgs; [ - cargo - rust-analyzer - rustfmt - ]) else []) - ++ - (if config.monorepo.profiles.lang-python.enable then (with pkgs; [ - poetry - python3 - python312Packages.jedi - ]) else []) - ++ - (if config.monorepo.profiles.lang-sol.enable then (with pkgs; [ - solc - ]) else []) - ++ - (if config.monorepo.profiles.lang-openscad.enable then (with pkgs; [ - openscad - openscad-lsp - ]) else []) - ++ - (if config.monorepo.profiles.lang-sh.enable then (with pkgs; [ - bash-language-server - ]) else []) - ++ - (if config.monorepo.profiles.lang-coq.enable then (with pkgs; [ - coq - ]) else []) - ++ - (if config.monorepo.profiles.lang-nix.enable then (with pkgs; [ - nil - nixd - nixfmt-rfc-style - ]) else []) - ++ - (if config.monorepo.profiles.crypto.enable then (with pkgs; [ - bitcoin - electrum - monero-cli - monero-gui - ]) else []) - ++ - (if config.monorepo.profiles.art.enable then (with pkgs; [ - inkscape - krita - ]) else []) - ++ - (if config.monorepo.profiles.music.enable then (with pkgs; [ - mpc-cli - sox - ]) else []) - ++ - (if config.monorepo.profiles.workstation.enable then (with pkgs; [ - alsa-utils - alsa-scarlett-gui - ardour - audacity - blender - fluidsynth - qjackctl - qsynth - qpwgraph - imagemagick - inkscape - kdenlive - kicad - ]) else []); + ++ + (if config.monorepo.profiles.lang-c.enable then (with pkgs; [ + autobuild + clang + gdb + gnumake + bear + clang-tools + ]) else []) + ++ + (if config.monorepo.profiles.lang-js.enable then (with pkgs; [ + nodejs + bun + yarn + typescript + vscode-langservers-extracted + ]) else []) + ++ + (if config.monorepo.profiles.lang-rust.enable then (with pkgs; [ + cargo + rust-analyzer + rustfmt + ]) else []) + ++ + (if config.monorepo.profiles.lang-python.enable then (with pkgs; [ + poetry + python3 + python312Packages.jedi + ]) else []) + ++ + (if config.monorepo.profiles.lang-sol.enable then (with pkgs; [ + solc + ]) else []) + ++ + (if config.monorepo.profiles.lang-openscad.enable then (with pkgs; [ + openscad + openscad-lsp + ]) else []) + ++ + (if config.monorepo.profiles.lang-sh.enable then (with pkgs; [ + bash-language-server + ]) else []) + ++ + (if config.monorepo.profiles.lang-coq.enable then (with pkgs; [ + coq + ]) else []) + ++ + (if config.monorepo.profiles.lang-nix.enable then (with pkgs; [ + nil + nixd + nixfmt-rfc-style + ]) else []) + ++ + (if config.monorepo.profiles.crypto.enable then (with pkgs; [ + bitcoin + electrum + monero-cli + monero-gui + ]) else []) + ++ + (if config.monorepo.profiles.art.enable then (with pkgs; [ + inkscape + krita + ]) else []) + ++ + (if config.monorepo.profiles.music.enable then (with pkgs; [ + mpc-cli + sox + ]) else []) + ++ + (if config.monorepo.profiles.workstation.enable then (with pkgs; [ + alsa-utils + alsa-scarlett-gui + ardour + audacity + blender + fluidsynth + qjackctl + qsynth + qpwgraph + imagemagick + inkscape + kdenlive + kicad + ]) else []); monorepo.profiles = { - enable = lib.mkDefault true; - music.enable = lib.mkDefault true; - hyprland.enable = lib.mkDefault true; - email.enable = lib.mkDefault true; + 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); - # Programming - lang-c.enable = lib.mkDefault true; - lang-rust.enable = lib.mkDefault true; - lang-python.enable = lib.mkDefault true; - lang-sol.enable = lib.mkDefault true; - lang-sh.enable = lib.mkDefault true; - lang-openscad.enable = lib.mkDefault true; - lang-js.enable = lib.mkDefault true; - lang-nix.enable = lib.mkDefault true; - lang-coq.enable = lib.mkDefault true; + # 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); - crypto.enable = lib.mkDefault true; - art.enable = lib.mkDefault true; - workstation.enable = lib.mkDefault true; + 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); }; }; } diff --git a/nix/modules/home/emacs.nix b/nix/modules/home/emacs.nix index 5e3d6aa..5f39e87 100644 --- a/nix/modules/home/emacs.nix +++ b/nix/modules/home/emacs.nix @@ -2,7 +2,7 @@ { programs.emacs = { - enable = true; + enable = lib.mkDefault config.monorepo.profiles.graphics.enable; package = pkgs.emacs29-pgtk; extraConfig = '' (setq debug-on-error t) diff --git a/nix/modules/home/firefox.nix b/nix/modules/home/firefox.nix index 118e150..986fccf 100644 --- a/nix/modules/home/firefox.nix +++ b/nix/modules/home/firefox.nix @@ -1,7 +1,7 @@ { lib, config, pkgs, ... }: { programs.firefox = { - enable = true; + enable = lib.mkDefault config.monorepo.profiles.graphics.enable; policies = { EnableTrackingProtection = true; OfferToSaveLogins = false; diff --git a/nix/modules/home/gammastep.nix b/nix/modules/home/gammastep.nix index ae9d111..208dda7 100644 --- a/nix/modules/home/gammastep.nix +++ b/nix/modules/home/gammastep.nix @@ -1,7 +1,7 @@ { lib, config, ... }: { services.gammastep = { - enable = true; + enable = lib.mkDefault config.monorepo.profiles.graphics.enable; provider = "manual"; latitude = 49.282730; longitude = -123.120735; diff --git a/nix/modules/home/git.nix b/nix/modules/home/git.nix index d019ddb..9c15aac 100644 --- a/nix/modules/home/git.nix +++ b/nix/modules/home/git.nix @@ -1,7 +1,7 @@ { lib, config, ... }: { programs.git = { - enable = true; + enable = lib.mkDefault config.monorepo.profiles.graphics.enable; userName = config.monorepo.vars.fullName; userEmail = config.monorepo.profiles.email.email; signing = { diff --git a/nix/modules/home/kitty.nix b/nix/modules/home/kitty.nix index 973581a..b99736e 100644 --- a/nix/modules/home/kitty.nix +++ b/nix/modules/home/kitty.nix @@ -1,7 +1,7 @@ { lib, config, ... }: { programs.kitty = { - enable = lib.mkDefault config.monorepo.profiles.hyprland.enable; + enable = lib.mkDefault (config.monorepo.profiles.hyprland.enable && config.monorepo.profiles.graphics.enable); settings = { enable_audio_bell = false; font_family = "Iosevka Nerd Font"; diff --git a/nix/modules/home/mako.nix b/nix/modules/home/mako.nix index eb70eee..d9a4610 100644 --- a/nix/modules/home/mako.nix +++ b/nix/modules/home/mako.nix @@ -1,7 +1,7 @@ { lib, config, sounds, ... }: { services.mako = { - enable = true; + enable = lib.mkDefault config.monorepo.profiles.graphics.enable; backgroundColor = "#11111bf8"; textColor = "#cdd6f4"; borderColor = "#89b4faff"; diff --git a/nix/modules/home/mpv.nix b/nix/modules/home/mpv.nix index 42f5687..6dd7f4d 100644 --- a/nix/modules/home/mpv.nix +++ b/nix/modules/home/mpv.nix @@ -1,7 +1,7 @@ { lib, config, ... }: { programs.mpv = { - enable = true; + enable = lib.mkDefault config.monorepo.profiles.graphics.enable; config = { profile = "gpu-hq"; force-window = true; diff --git a/nix/modules/home/user.nix b/nix/modules/home/user.nix index 7c470aa..882041b 100644 --- a/nix/modules/home/user.nix +++ b/nix/modules/home/user.nix @@ -23,7 +23,7 @@ homeDirectory = "/home/${config.monorepo.vars.userName}"; stateVersion = "24.11"; - packages = with pkgs; [ + packages = with pkgs; (if config.monorepo.profiles.graphics.enable then [ # wikipedia kiwix kiwix-tools @@ -49,11 +49,7 @@ torsocks tor-browser # fonts - noto-fonts - noto-fonts-cjk-sans - noto-fonts-emoji - fira-code - font-awesome_6 + noto-fonts noto-fonts-cjk-sans noto-fonts-emoji fira-code font-awesome_6 (aspellWithDicts (dicts: with dicts; [ en en-computers en-science ])) (nerdfonts.override { fonts = [ "Iosevka" ]; }) @@ -66,7 +62,20 @@ pfetch libnotify htop - ]; + (writeShellScriptBin "install_vps" + '' +#!/bin/bash +nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config ./systems/spontaneity/hardware-configuration.nix --flake .#spontaneity --target-host "$1" + '' + ) + ] else [ + pfetch + + # net + curl + torsocks + rsync + ]); }; services = { @@ -83,7 +92,7 @@ programs.bash.enable = true; gtk = { - enable = true; + enable = lib.mkDefault config.monorepo.profiles.graphics.enable; theme = null; iconTheme = null; }; diff --git a/nix/modules/home/wofi.nix b/nix/modules/home/wofi.nix index f6c4179..ec2e3bc 100644 --- a/nix/modules/home/wofi.nix +++ b/nix/modules/home/wofi.nix @@ -1,7 +1,7 @@ { lib, config, ... }: { programs.wofi = { - enable = true; + enable = lib.mkDefault config.monorepo.profiles.graphics.enable; settings = { location = "bottom-right"; allow_markup = true; diff --git a/nix/modules/home/yt-dlp.nix b/nix/modules/home/yt-dlp.nix index 5ed35f5..b9dd8e0 100644 --- a/nix/modules/home/yt-dlp.nix +++ b/nix/modules/home/yt-dlp.nix @@ -1,7 +1,7 @@ { lib, config, ... }: { programs.yt-dlp = { - enable = true; + enable = lib.mkDefault config.monorepo.profiles.graphics.enable; settings = { embed-thumbnail = true; embed-subs = true; diff --git a/nix/modules/vda-simple.nix b/nix/modules/vda-simple.nix index f18b1c3..32fa28d 100644 --- a/nix/modules/vda-simple.nix +++ b/nix/modules/vda-simple.nix @@ -1,26 +1,18 @@ { disko.devices = { disk = { - my-disk = { + main = { device = "/dev/vda"; type = "disk"; content = { type = "gpt"; partitions = { - ESP = { - type = "EF00"; - size = "500M"; - priority = 1; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; + boot = { + size = "1M"; + type = "EF02"; }; root = { size = "100%"; - priority = 2; content = { type = "filesystem"; format = "ext4"; diff --git a/nix/systems/spontaneity/default.nix b/nix/systems/spontaneity/default.nix index 5f79855..ae79429 100644 --- a/nix/systems/spontaneity/default.nix +++ b/nix/systems/spontaneity/default.nix @@ -10,6 +10,7 @@ profiles = { server.enable = true; ttyonly.enable = true; + grub.enable = true; }; vars.hostName = "spontaneity"; }; diff --git a/nix/systems/spontaneity/hardware-configuration.nix b/nix/systems/spontaneity/hardware-configuration.nix new file mode 100644 index 0000000..050ed23 --- /dev/null +++ b/nix/systems/spontaneity/hardware-configuration.nix @@ -0,0 +1,23 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "sr_mod" "virtio_blk" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.ens3.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + virtualisation.hypervGuest.enable = true; +} diff --git a/nix/systems/spontaneity/home.nix b/nix/systems/spontaneity/home.nix index 276ba52..cc93b5d 100644 --- a/nix/systems/spontaneity/home.nix +++ b/nix/systems/spontaneity/home.nix @@ -3,4 +3,5 @@ imports = [ ../../modules/home/default.nix ]; + config.monorepo.profiles.enable = false; } |