diff --git a/.gitignore b/.gitignore index 33dfa97..65fc6b5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ # .nfs files are created when an open file is removed but is still being accessed .nfs* *.swp +result +*.qcow2 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3198520 --- /dev/null +++ b/flake.lock @@ -0,0 +1,66 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1694465129, + "narHash": "sha256-8BQiuobMrCfCbGM7w6Snx+OBYdtTIm0+cGVaKwQ5BFg=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "9787dffff5d315c9593d3f9fb0f9bf2097e1b57b", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-23.05", + "repo": "home-manager", + "type": "github" + } + }, + "nixos-hardware": { + "locked": { + "lastModified": 1694710316, + "narHash": "sha256-uRh46iIC86D8BD1wCDA5gRrt+hslUXiD0kx/UjnjBcs=", + "owner": "NixOS", + "repo": "nixos-hardware", + "rev": "570256327eb6ca6f7bebe8d93af49459092a0c43", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixos-hardware", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1694422566, + "narHash": "sha256-lHJ+A9esOz9vln/3CJG23FV6Wd2OoOFbDeEs4cMGMqc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3a2786eea085f040a66ecde1bc3ddc7099f6dbeb", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixos-hardware": "nixos-hardware", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..cef0869 --- /dev/null +++ b/flake.nix @@ -0,0 +1,72 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + home-manager = { + url = "github:nix-community/home-manager/release-23.05"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = inputs: { + nixosConfigurations = let + workstation = { + system = "x86_64-linux"; + modules = [ + ./workstation + inputs.home-manager.nixosModules.home-manager + ./home + ]; + }; + in { + loki = inputs.nixpkgs.lib.nixosSystem { + modules = workstation.modules ++ [ + { + networking.hostName = "loki"; + } + ./wm/sway + ./hosts/loki/hardware-configuration.nix + ]; + }; + smaug = inputs.nixpkgs.lib.nixosSystem { + modules = workstation.modules ++ [ + { + networking.hostName = "smaug"; + } + inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x260 + ./wm/sway + ./hosts/smaug/hardware-configuration.nix + ]; + }; + dragon = inputs.nixpkgs.lib.nixosSystem { + modules = workstation.modules ++ [ + { + networking.hostName = "dragon"; + } + inputs.nixos-hardware.nixosModules. google-pixelbook + ./wm/sway + ./hosts/dragon/hardware-configuration.nix + ]; + }; + eve = inputs.nixpkgs.lib.nixosSystem { + modules = workstation.modules ++ [ + { + networking.hostName = "eve"; + } + inputs.nixos-hardware.nixosModules. google-pixelbook + ./wm/sway + ./hosts/eve/hardware-configuration.nix + ]; + }; + vm2 = inputs.nixpkgs.lib.nixosSystem { + modules = workstation.modules ++ [ + { + services.getty.autologinUser = "don"; + networking.hostName = "vm2"; + } + ./wm/sway + ]; + }; + }; + }; +} diff --git a/home/default.nix b/home/default.nix index 51950a5..b41bed5 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,16 +1,21 @@ { config, pkgs, ... }: { - imports = [ - ./packages-cli.nix - ./packages-gui.nix - ./services.nix - ]; - home = { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.don = { + imports = [ + ./packages-cli.nix + ./packages-gui.nix + ./services.nix + #./systemd.nix # TODO Fix systemd under flake + ]; + home = { username = "don"; homeDirectory = "/home/don"; stateVersion = "23.05"; }; programs.home-manager.enable = true; programs.go.enable = true; + }; } diff --git a/home/packages-cli.nix b/home/packages-cli.nix index 24cd5f0..fe195c1 100644 --- a/home/packages-cli.nix +++ b/home/packages-cli.nix @@ -18,14 +18,13 @@ file fzf gdu - git-crypt - gitFull gitui gh gnumake gnupg gping gtop + htop hugo jq keychain diff --git a/home/packages-gui.nix b/home/packages-gui.nix index 947478c..aa337e3 100644 --- a/home/packages-gui.nix +++ b/home/packages-gui.nix @@ -21,7 +21,6 @@ firefox flameshot font-awesome - fractal-next gnome.gnome-tweaks gnome.simple-scan gnumeric diff --git a/hosts/ace/configuration.nix b/hosts/ace/configuration.nix deleted file mode 100644 index 793d999..0000000 --- a/hosts/ace/configuration.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = - [ - /etc/nixos/hardware-configuration.nix - ../../workstation - ../../wm/sway - ]; - networking.hostName = "ace"; -} diff --git a/hosts/dragon/configuration.nix b/hosts/dragon/configuration.nix deleted file mode 100644 index 528eed1..0000000 --- a/hosts/dragon/configuration.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = - [ - /etc/nixos/hardware-configuration.nix - ../../workstation - ../../wm/sway - ]; - networking.hostName = "dragon"; -} diff --git a/hosts/dragon/hardware-configuration.nix b/hosts/dragon/hardware-configuration.nix index 3e7dcbe..4443fb4 100644 --- a/hosts/dragon/hardware-configuration.nix +++ b/hosts/dragon/hardware-configuration.nix @@ -8,7 +8,7 @@ [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; + boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "sd_mod" "rtsx_pci_sdmmc" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; @@ -33,7 +33,9 @@ # with explicit per-interface declarations with `networking.interfaces..useDHCP`. networking.useDHCP = lib.mkDefault true; # networking.interfaces.enp0s25.useDHCP = lib.mkDefault true; + # networking.interfaces.tailscale0.useDHCP = lib.mkDefault true; # networking.interfaces.wlo1.useDHCP = lib.mkDefault true; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/hosts/eve/configuration.nix b/hosts/eve/configuration.nix deleted file mode 100644 index 5748248..0000000 --- a/hosts/eve/configuration.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = - [ - - /etc/nixos/hardware-configuration.nix - ../../workstation - ../../wm/sway - ]; - networking.hostName = "eve"; -} diff --git a/hosts/eve/hardware-configuration.nix b/hosts/eve/hardware-configuration.nix index 759302a..a1e83b6 100644 --- a/hosts/eve/hardware-configuration.nix +++ b/hosts/eve/hardware-configuration.nix @@ -35,5 +35,6 @@ # networking.interfaces.wlp1s0.useDHCP = lib.mkDefault true; powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/hosts/loki/configuration.nix b/hosts/loki/configuration.nix deleted file mode 100644 index a513560..0000000 --- a/hosts/loki/configuration.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = - [ - - /etc/nixos/hardware-configuration.nix - ../../workstation - ../../wm/sway - ]; - networking.hostName = "loki"; -} diff --git a/hosts/loki/hardware-configuration.nix b/hosts/loki/hardware-configuration.nix new file mode 100644 index 0000000..30c55f3 --- /dev/null +++ b/hosts/loki/hardware-configuration.nix @@ -0,0 +1,41 @@ +# 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 = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "usbhid" "sd_mod" "rtsx_pci_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/3d7cbefa-d25f-4502-bb8e-f6cfca8bc682"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/5547-270C"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/e5906bd1-ea2b-4e96-9393-3d5da127e0ac"; } + ]; + + # 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.enp60s0u1u3u4.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true; + + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/pocket2/configuration.nix b/hosts/pocket2/configuration.nix deleted file mode 100644 index 7457911..0000000 --- a/hosts/pocket2/configuration.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = - [ - /etc/nixos/hardware-configuration.nix - ../../workstation - ../../wm/sway - ]; - networking.hostName = "pocket2"; -} diff --git a/hosts/smaug/configuration.nix b/hosts/smaug/configuration.nix deleted file mode 100644 index 3052395..0000000 --- a/hosts/smaug/configuration.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = - [ - - /etc/nixos/hardware-configuration.nix - ../../workstation - ../../wm/sway - ]; - networking.hostName = "smaug"; -} diff --git a/hosts/smaug/hardware-configuration.nix b/hosts/smaug/hardware-configuration.nix new file mode 100644 index 0000000..fe56a8f --- /dev/null +++ b/hosts/smaug/hardware-configuration.nix @@ -0,0 +1,42 @@ +# 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 = [ "xhci_pci" "ahci" "uas" "sd_mod" "rtsx_pci_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + + fileSystems."/" = + { device = "/dev/sda2"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/sda1"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/sda3"; } + ]; + + # 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.enp0s31f6.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/vm1/configuration.nix b/hosts/vm1/configuration.nix deleted file mode 100644 index 87b6d17..0000000 --- a/hosts/vm1/configuration.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = - [ - /etc/nixos/hardware-configuration.nix - ../../server/configuration.nix - ]; - networking.hostName = "vm1"; -} diff --git a/makefile b/makefile new file mode 100644 index 0000000..62180c4 --- /dev/null +++ b/makefile @@ -0,0 +1,6 @@ +all: + doas nixos-rebuild switch --flake .#$${HOSTNAME_SHORT} + +vm: + doas nixos-rebuild switch --flake .#vm2 && result/bin/run-*-vm + diff --git a/wm/sway/default.nix b/wm/sway/default.nix index 91b42b6..eda1a62 100644 --- a/wm/sway/default.nix +++ b/wm/sway/default.nix @@ -1,30 +1,15 @@ { 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"; @@ -38,8 +23,6 @@ let gsettings set $gnome_schema gtk-theme 'Dracula' ''; }; - - in { environment.systemPackages = with pkgs; [ @@ -62,28 +45,10 @@ in wayland wl-clipboard ]; - - - # 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"; - } diff --git a/workstation/default.nix b/workstation/default.nix index 9d575b8..5ffbcd2 100644 --- a/workstation/default.nix +++ b/workstation/default.nix @@ -124,7 +124,12 @@ in }; security.rtkit.enable = true; - xdg.portal.enable = true; # only needed if you are not doing Gnome + xdg.portal = { + enable = true; + wlr.enable = true; + extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; + #gtkUsePortal = true; + }; users.users.don = { isNormalUser = true; @@ -149,6 +154,8 @@ in nix-bash-completions btop espeak-classic + git-crypt + gitFull headsetcontrol home-manager hunspell