From 814b04553c16e635678441000484db0f390450a1 Mon Sep 17 00:00:00 2001 From: Don Harper Date: Sun, 18 Sep 2022 20:12:04 -0500 Subject: [PATCH] added vm1 config --- vm1/configuration.nix | 183 +++++++++++++++++++++++++++++++++ vm1/hardware-configuration.nix | 39 +++++++ vm1/hm.out | 73 +++++++++++++ vm1/result | 1 + vm1/sway.nix | 94 +++++++++++++++++ 5 files changed, 390 insertions(+) create mode 100644 vm1/configuration.nix create mode 100644 vm1/hardware-configuration.nix create mode 100644 vm1/hm.out create mode 120000 vm1/result create mode 100644 vm1/sway.nix diff --git a/vm1/configuration.nix b/vm1/configuration.nix new file mode 100644 index 0000000..9b67888 --- /dev/null +++ b/vm1/configuration.nix @@ -0,0 +1,183 @@ +{ config, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ./sway.nix + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.efi.efiSysMountPoint = "/boot"; + boot.kernelPackages = pkgs.linuxPackages_latest; + + networking.hostName = "vm1"; # Define your hostname. + + # Enable networking + networking.networkmanager.enable = true; + networking.networkmanager.wifi.powersave = true; + networking.useDHCP = false; + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Set your time zone. + time.timeZone = "America/Chicago"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.utf8"; + + # Splash screen + boot.plymouth.enable = false; + boot.plymouth.theme = "breeze"; + + # Enable doas instead of sudo + security.sudo.enable = false; + security.doas.enable = true; + security.doas.extraRules = [{ + users = [ "don" ]; + keepEnv = true; + noPass = true; + }]; + + # Enable the X11 windowing system. + #services.xserver.enable = false; + + # Enable the GNOME Desktop Environment. + #services.xserver.displayManager.gdm.enable = true; + #services.xserver.desktopManager.gnome.enable = false; + + # Configure keymap in X11 + #services.xserver = { + #layout = "us"; + #xkbVariant = ""; + #}; + + # 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; + }; + + xdg.portal.enable = true; # only needed if you are not doing Gnome + services.flatpak.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.don = { + isNormalUser = true; + description = "Don Harper"; + extraGroups = [ "networkmanager" "wheel" ]; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINd8AdVbQQ/Fmw+b9mI8EMYqIoRkwmSwAOtmlte3incL don@loki" + ]; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + #citrix_workspace + firefox + git-crypt + gitFull + gnupg + home-manager + mosh + pulseaudio + python311 + qutebrowser + syncthing + tailscale + tmux + tmuxp + topgrade + vim + wget + zoom-us + ]; + + programs.mtr.enable = true; + + services.tailscale.enable = true; + # create a oneshot job to authenticate to Tailscale + systemd.services.tailscale-autoconnect = { + description = "Automatic connection to Tailscale"; + + # make sure tailscale is running before trying to connect to tailscale + after = [ "network-pre.target" "tailscale.service" ]; + wants = [ "network-pre.target" "tailscale.service" ]; + wantedBy = [ "multi-user.target" ]; + + # set this service as a oneshot job + serviceConfig.Type = "oneshot"; + + # have the job run this shell script + script = with pkgs; '' + # wait for tailscaled to settle + sleep 2 + + # check if we are already authenticated to tailscale + status="$(${tailscale}/bin/tailscale status -json | ${jq}/bin/jq -r .BackendState)" + if [ $status = "Running" ]; then # if so, then do nothing + exit 0 + fi + + # otherwise authenticate with tailscale + ${tailscale}/bin/tailscale up -authkey tskey-kX35vC1CNTRL-ZLmNBp4CQV3bu3SsLGjW56 + ''; + }; + + + # Enable the OpenSSH daemon. + services.openssh = { + enable = true; + passwordAuthentication = false; + kbdInteractiveAuthentication = false; + #permitRootLogin = "yes"; + }; + + # Open ports in the firewall. + networking.firewall = { + enable = true; + # always allow traffic from your Tailscale network + trustedInterfaces = [ "tailscale0" ]; + checkReversePath = "loose"; + + # allow the Tailscale UDP port through the firewall + allowedUDPPorts = [ config.services.tailscale.port ]; + + # allow you to SSH in over the public internet + allowedTCPPorts = [ 22 ]; + }; + + + # 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 leavecatenate(variables, "bootdev", bootdev) + # 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 = "22.05"; # Did you read the comment? + nixpkgs.config.firefox.enableGnomeExtenions = true; + services.gnome.chrome-gnome-shell.enable = true; + +} diff --git a/vm1/hardware-configuration.nix b/vm1/hardware-configuration.nix new file mode 100644 index 0000000..362833c --- /dev/null +++ b/vm1/hardware-configuration.nix @@ -0,0 +1,39 @@ +# 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 + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/d14be520-2b13-4f2a-8873-4c2319cae32d"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/7923-4D98"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/732f3844-d789-4dbc-a581-413fe861ea05"; } + ]; + + # 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.enp1s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/vm1/hm.out b/vm1/hm.out new file mode 100644 index 0000000..1fda1a6 --- /dev/null +++ b/vm1/hm.out @@ -0,0 +1,73 @@ ++ PATH=/nix/store/n95s7s6ilkjc7xwqml93acxzj6k0hsfn-coreutils-9.1/bin:/nix/store/k0kpf3r2k1d8p9h0gmx23msw3qrybkfk-findutils-4.9.0/bin:/nix/store/xh696lkivvygg8bkpvj95vv3qspp2awx-gettext-0.21/bin:/nix/store/5mgbisml783jj5mscxjsr4hlbmn25cyr-gnused-4.8/bin:/nix/store/zx12hry89d798p3qp97rm6mfxx2453hr-less-608/bin:/nix/store/s3apaf0hrvmy6fkg95nlkhi4mlm6gj10-nixos-option/bin:/run/wrappers/bin:/home/don/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:/home/don/.nix-profile/bin:/etc/profiles/per-user/don/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin ++ set -euo pipefail ++ export TEXTDOMAIN=home-manager ++ TEXTDOMAIN=home-manager ++ export TEXTDOMAINDIR=/nix/store/3dfrrvps5p9pflkmrmm2wgky7kgk01r8-home-manager/share/locale ++ TEXTDOMAINDIR=/nix/store/3dfrrvps5p9pflkmrmm2wgky7kgk01r8-home-manager/share/locale ++ source /nix/store/xc42m2j2znv5n2px2fhy0phgraldhlbc-home-manager.sh +++ setupColors +++ normalColor= +++ errorColor= +++ warnColor= +++ noteColor= +++ [[ ! -v NO_COLOR ]] +++ [[ -t 1 ]] ++ readonly NIX_STATE_DIR=/nix/var/nix ++ NIX_STATE_DIR=/nix/var/nix ++ EXTRA_NIX_PATH=() ++ HOME_MANAGER_CONFIG_ATTRIBUTE= ++ PASSTHROUGH_OPTS=() ++ COMMAND= ++ COMMAND_ARGS=() ++ FLAKE_ARG= ++ [[ 1 -gt 0 ]] ++ opt=switch ++ shift ++ case $opt in ++ COMMAND=switch ++ [[ 0 -gt 0 ]] ++ [[ -z switch ]] ++ case $COMMAND in ++ doSwitch ++ setWorkDir ++ [[ ! -v WORK_DIR ]] +++ mktemp --tmpdir -d home-manager-build.XXXXXXXXXX ++ WORK_DIR=/tmp/home-manager-build.qMRWGAwNts ++ trap 'rm -r '\''/tmp/home-manager-build.qMRWGAwNts'\''' EXIT ++ local generation ++ generation=/tmp/home-manager-build.qMRWGAwNts/generation ++ setFlakeAttribute ++ local configFlake=/home/don/.config/nixpkgs/flake.nix ++ [[ -z '' ]] ++ [[ ! -v HOME_MANAGER_CONFIG ]] ++ [[ -e /home/don/.config/nixpkgs/flake.nix ]] ++ [[ -n '' ]] ++ [[ -v FLAKE_CONFIG_URI ]] ++ doBuildAttr --out-link /tmp/home-manager-build.qMRWGAwNts/generation --attr activationPackage ++ setConfigFile ++ [[ -v HOME_MANAGER_CONFIG ]] ++ local defaultConfFile=/home/don/.config/nixpkgs/home.nix ++ local confFile ++ for confFile in "$defaultConfFile" "$HOME/.nixpkgs/home.nix" ++ [[ -e /home/don/.config/nixpkgs/home.nix ]] +++ realpath /home/don/.config/nixpkgs/home.nix ++ HOME_MANAGER_CONFIG=/home/don/.config/nixpkgs/home.nix ++ return ++ setHomeManagerNixPath ++ local path ++ for path in "" "${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home-manager" "$HOME/.nixpkgs/home-manager" ++ [[ -e '' ]] ++ [[ '' =~ ^https?:// ]] ++ for path in "" "${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home-manager" "$HOME/.nixpkgs/home-manager" ++ [[ -e /home/don/.config/nixpkgs/home-manager ]] ++ [[ /home/don/.config/nixpkgs/home-manager =~ ^https?:// ]] ++ for path in "" "${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home-manager" "$HOME/.nixpkgs/home-manager" ++ [[ -e /home/don/.nixpkgs/home-manager ]] ++ [[ /home/don/.nixpkgs/home-manager =~ ^https?:// ]] ++ extraArgs=('--out-link' '/tmp/home-manager-build.qMRWGAwNts/generation' '--attr' 'activationPackage') ++ local extraArgs ++ [[ -v VERBOSE ]] ++ nix-build '' --out-link /tmp/home-manager-build.qMRWGAwNts/generation --attr activationPackage --argstr confPath /home/don/.config/nixpkgs/home.nix --argstr confAttr '' +error: file 'home-manager/home-manager/home-manager.nix' was not found in the Nix search path (add it using $NIX_PATH or -I) ++ return ++ rm -r /tmp/home-manager-build.qMRWGAwNts diff --git a/vm1/result b/vm1/result new file mode 120000 index 0000000..f88a91b --- /dev/null +++ b/vm1/result @@ -0,0 +1 @@ +/nix/store/d780b28md07w3hqniy0px6wp3y6axm1b-nixos-system-vm1-22.11pre409157.da6a05816e7 \ No newline at end of file diff --git a/vm1/sway.nix b/vm1/sway.nix new file mode 100644 index 0000000..4bc2fde --- /dev/null +++ b/vm1/sway.nix @@ -0,0 +1,94 @@ +{ config, pkgs, lib, ... }: + +let + # bash script to let dbus know about important env variables and + # propogate them to relevent services run at the end of sway config + # see + # https://github.com/emersion/xdg-desktop-portal-wlr/wiki/"It-doesn't-work"-Troubleshooting-Checklist + # note: this is pretty much the same as /etc/sway/config.d/nixos.conf but also restarts + # some user services to make sure they have the correct environment variables + dbus-sway-environment = pkgs.writeTextFile { + name = "dbus-sway-environment"; + destination = "/bin/dbus-sway-environment"; + executable = true; + + text = '' + dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway + systemctl --user stop pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr + systemctl --user start pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr + ''; + }; + + # currently, there is some friction between sway and gtk: + # https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland + # the suggested way to set gtk settings is with gsettings + # for gsettings to work, we need to tell it where the schemas are + # using the XDG_DATA_DIR environment variable + # run at the end of sway config + configure-gtk = pkgs.writeTextFile { + name = "configure-gtk"; + destination = "/bin/configure-gtk"; + executable = true; + text = let + schema = pkgs.gsettings-desktop-schemas; + datadir = "${schema}/share/gsettings-schemas/${schema.name}"; + in '' + export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS + gnome_schema=org.gnome.desktop.interface + gsettings set $gnome_schema gtk-theme 'Dracula' + ''; + }; + + +in +{ + environment.systemPackages = with pkgs; [ + alacritty # gpu accelerated terminal + sway + dbus-sway-environment + configure-gtk + wayland + glib # gsettings + dracula-theme # gtk theme + gnome3.adwaita-icon-theme # default gnome cursors + swaylock-effects + swayidle + grim # screenshot functionality + slurp # screenshot functionality + wl-clipboard # wl-copy and wl-paste for copy/paste from stdin / stdout + bemenu # wayland clone of dmenu + mako # notification system developed by swaywm maintainer + waybar + ]; + + + services.pipewire = { + enable = true; + alsa.enable = true; + pulse.enable = true; + }; + + + # xdg-desktop-portal works by exposing a series of D-Bus interfaces + # known as portals under a well-known name + # (org.freedesktop.portal.Desktop) and object path + # (/org/freedesktop/portal/desktop). + # The portal interfaces include APIs for file access, opening URIs, + # printing and others. + services.dbus.enable = true; + xdg.portal = { + enable = true; + wlr.enable = true; + # gtk portal needed to make gtk apps happy + extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; + gtkUsePortal = true; + }; + + # enable sway window manager + programs.sway = { + enable = true; + wrapperFeatures.gtk = true; + }; + services.greetd.package = "greetd.wlgreet"; + +}