From cde5bc2bc3571ad14ed87ea979e4e9dcc4133e66 Mon Sep 17 00:00:00 2001 From: Corwin Perren Date: Sun, 2 Jun 2024 17:30:00 -0700 Subject: [PATCH] Added initial_setup.sh for setup bootstrapping --- flake.lock | 48 ------- flake.nix | 23 ---- hosts/cap-nr200p/configuration.nix | 138 -------------------- hosts/cap-nr200p/hardware-configuration.nix | 38 ------ initial_setup.sh | 40 ++++++ modules/nixos/hyprland.nix | 55 -------- 6 files changed, 40 insertions(+), 302 deletions(-) delete mode 100644 flake.lock delete mode 100644 flake.nix delete mode 100644 hosts/cap-nr200p/configuration.nix delete mode 100644 hosts/cap-nr200p/hardware-configuration.nix create mode 100755 initial_setup.sh delete mode 100644 modules/nixos/hyprland.nix diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 74e9960..0000000 --- a/flake.lock +++ /dev/null @@ -1,48 +0,0 @@ -{ - "nodes": { - "home-manager": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1715077503, - "narHash": "sha256-AfHQshzLQfUqk/efMtdebHaQHqVntCMjhymQzVFLes0=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "6e277d9566de9976f47228dd8c580b97488734d4", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "home-manager", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1715087517, - "narHash": "sha256-CLU5Tsg24Ke4+7sH8azHWXKd0CFd4mhLWfhYgUiDBpQ=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "b211b392b8486ee79df6cdfb1157ad2133427a29", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "home-manager": "home-manager", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 23ff26e..0000000 --- a/flake.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ - description = "Nixos config flake"; - - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - - home-manager = { - url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - }; - - outputs = { self, nixpkgs, ... }@inputs: { - nixosConfigurations.default = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs;}; - modules = [ - ./hosts/cap-nr200p/configuration.nix - ./modules/nixos/hyprland.nix - inputs.home-manager.nixosModules.default - ]; - }; - }; -} diff --git a/hosts/cap-nr200p/configuration.nix b/hosts/cap-nr200p/configuration.nix deleted file mode 100644 index 0a09c0a..0000000 --- a/hosts/cap-nr200p/configuration.nix +++ /dev/null @@ -1,138 +0,0 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page -# and in the NixOS manual (accessible by running ‘nixos-help’). - -{ config, pkgs, ... }: - -{ - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ]; - - # Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - networking.hostName = "cap-nr200p"; # Define your hostname. #-# - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Enable networking - networking.networkmanager.enable = true; - - # Enable flakes - nix.settings.experimental-features = [ "nix-command" "flakes" ]; #-# - - # Set your time zone. - time.timeZone = "America/Los_Angeles"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - - i18n.extraLocaleSettings = { - LC_ADDRESS = "en_US.UTF-8"; - LC_IDENTIFICATION = "en_US.UTF-8"; - LC_MEASUREMENT = "en_US.UTF-8"; - LC_MONETARY = "en_US.UTF-8"; - LC_NAME = "en_US.UTF-8"; - LC_NUMERIC = "en_US.UTF-8"; - LC_PAPER = "en_US.UTF-8"; - LC_TELEPHONE = "en_US.UTF-8"; - LC_TIME = "en_US.UTF-8"; - }; - - # Enable the X11 windowing system. - # services.xserver.enable = true; - - # Enable the XFCE Desktop Environment. - # services.xserver.displayManager.lightdm.enable = true; - # services.xserver.desktopManager.xfce.enable = true; - - # Configure keymap in X11 - services.xserver = { - layout = "us"; - xkbVariant = ""; - }; - # services.xserver.xkb.layout = "us"; - # services.xserver.xkb.variant = ""; - - # Enable CUPS to print documents. - services.printing.enable = true; - - # Enable sound with pipewire. - sound.enable = true; - hardware.pulseaudio.enable = false; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - # If you want to use JACK applications, uncomment this - #jack.enable = true; - - # use the example session manager (no others are packaged yet so this is enabled by default, - # no need to redefine it in your config for now) - #media-session.enable = true; - }; - - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; - - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.caperren = { - isNormalUser = true; - description = "Corwin Perren"; - extraGroups = [ "networkmanager" "wheel" ]; - packages = with pkgs; [ - # thunderbird - ]; - }; - - # Install firefox. - programs.firefox.enable = true; #-# - - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - # wget - lf - git - ]; - - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; - # programs.gnupg.agent = { - # enable = true; - # enableSSHSupport = true; - # }; - - # List services that you want to enable: - - # Enable the OpenSSH daemon. - services.openssh.enable = true; #-# - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - networking.firewall.enable = false; - - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It‘s perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "23.11"; # Did you read the comment? - -} diff --git a/hosts/cap-nr200p/hardware-configuration.nix b/hosts/cap-nr200p/hardware-configuration.nix deleted file mode 100644 index 41e4caf..0000000 --- a/hosts/cap-nr200p/hardware-configuration.nix +++ /dev/null @@ -1,38 +0,0 @@ -# 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 = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; - - boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-amd" ]; - boot.extraModulePackages = [ ]; - - fileSystems."/" = - { device = "/dev/disk/by-uuid/0ffc75db-278d-4d96-99ee-4d17e6b1a9c2"; - fsType = "ext4"; - }; - - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/5BDD-941D"; - fsType = "vfat"; - options = [ "fmask=0022" "dmask=0022" ]; - }; - - swapDevices = [ ]; - - # 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..useDHCP`. - networking.useDHCP = lib.mkDefault true; - # networking.interfaces.enp6s0.useDHCP = lib.mkDefault true; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; -} diff --git a/initial_setup.sh b/initial_setup.sh new file mode 100755 index 0000000..d3fcce6 --- /dev/null +++ b/initial_setup.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# To set up a fresh system, run the following: +# curl -sSL https://raw.githubusercontent.com/caperren/nixos-configs/main/initial_setup.sh | bash +set -e + +SCRIPT_DIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") + +GIT_REPO_NAME="nixos-configs" +GIT_RELEASE_BRANCH="playground" +GIT_REPO_URL="git@github.com:caperren/$GIT_REPO_NAME.git" + +NIXOS_REPO_CONFIG_PARENT_PATH="/opt" +NIXOS_REPO_CONFIG_PATH="$NIXOS_REPO_CONFIG_PARENT_PATH/$GIT_REPO_NAME" +HOST_CONFIG_PATH="$NIXOS_REPO_CONFIG_PATH/hosts/$(hostname)" + +# If the config repo doesn't exist, clone it +if [ ! -d "$NIXOS_REPO_CONFIG_PATH" ]; then + TEMP_CLONE_DIR="/home/$USER/$GIT_REPO_NAME" + + if [[ ! -d "$NIXOS_REPO_CONFIG_PARENT_PATH" ]]; then + sudo mkdir -p "$NIXOS_REPO_CONFIG_PARENT_PATH" + fi + + git clone "$GIT_REPO_URL" "$TEMP_CLONE_DIR" || true + + sudo mv "$TEMP_CLONE_DIR" "$NIXOS_REPO_CONFIG_PARENT_PATH/." + cd "$NIXOS_REPO_CONFIG_PATH" + + git checkout "$GIT_RELEASE_BRANCH" + + sudo chown -R $USER:users "$NIXOS_REPO_CONFIG_PATH" +fi + +# If we're not running from the repo directory, this script launch is a setup bootstrap +# Exec the same script in the config repo, which should be the right one for the release branch +# we want +if [[ "$SCRIPT_DIR" != "$NIXOS_REPO_CONFIG_PATH" ]]; then + exec "$NIXOS_REPO_CONFIG_PATH/initial_setup.sh" + exit +fi diff --git a/modules/nixos/hyprland.nix b/modules/nixos/hyprland.nix deleted file mode 100644 index be9896d..0000000 --- a/modules/nixos/hyprland.nix +++ /dev/null @@ -1,55 +0,0 @@ -{ pkgs, config, ... }: { - programs.hyprland = { - enable = true; - xwayland.enable = true; - }; - - environment.sessionVariables = { - # If your cursor becomes invisible - # WLR_NO_HARDWARE_CURSORS = "1"; - # Hint electron apps to use wayland - NIXOS_OZONE_WL = "1"; - }; - - services.xserver = { - enable = true; - videoDrivers = [ "nvidia" ]; - displayManager.gdm = { - enable = true; - wayland = true; - }; - }; - - hardware.opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - }; - - hardware.nvidia = { - # Enable modesetting for Wayland compositors (hyprland) - modesetting.enable = true; - # Use the open source version of the kernel module (for driver 515.43.04+) - # open = true; - # Enable the Nvidia settings menu - nvidiaSettings = true; - # Select the appropriate driver version for your specific GPU - package = config.boot.kernelPackages.nvidiaPackages.stable; - }; - environment.systemPackages = [ - pkgs.hyprland - pkgs.kitty - pkgs.waybar - pkgs.dunst - pkgs.libnotify - pkgs.rofi-wayland - - #(pkgs.waybar.overrideAttrs (oldAttrs: { - # mesonFlags = oldAttrs.mesonFlags ++ [ "-Dexperimental=true" ]; - # }) - #) - ]; - - xdg.portal.enable = true; - xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; -}