From cb36345d9682111d0404dfe041ec670bc225d6ba Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Tue, 3 Oct 2023 16:26:45 -0500 Subject: [PATCH] Add a dm --- flake.lock | 180 +++++++++++++++++++++++++++++++- flake.nix | 51 ++++++--- home/default.nix | 26 +++++ home/linux.nix | 58 +++++++++- modules/nixos/desktop-usage.nix | 5 +- modules/nixos/hyprland.nix | 3 + modules/nixos/plasma.nix | 5 + modules/nixos/wifi.nix | 1 + nixos/beefcake/default.nix | 5 +- nixos/default.nix | 56 ---------- nixos/musicbox/default.nix | 170 +++--------------------------- nixos/rascal/default.nix | 3 +- readme.md | 11 +- 13 files changed, 341 insertions(+), 233 deletions(-) create mode 100644 modules/nixos/hyprland.nix create mode 100644 modules/nixos/plasma.nix delete mode 100644 nixos/default.nix diff --git a/flake.lock b/flake.lock index 697344a..d9a0cf7 100644 --- a/flake.lock +++ b/flake.lock @@ -19,6 +19,22 @@ "url": "ssh://gitea@git.lyte.dev/lytedev/api.lyte.dev.git" } }, + "base16-schemes": { + "flake": false, + "locked": { + "lastModified": 1689473676, + "narHash": "sha256-L0RhUr9+W5EPWBpLcmkKpUeCEWRs/kLzVMF3Vao2ZU0=", + "owner": "tinted-theming", + "repo": "base16-schemes", + "rev": "d95123ca6377cd849cfdce92c0a24406b0c6a789", + "type": "github" + }, + "original": { + "owner": "tinted-theming", + "repo": "base16-schemes", + "type": "github" + } + }, "crane": { "inputs": { "flake-compat": "flake-compat", @@ -176,6 +192,72 @@ "type": "github" } }, + "hyprland": { + "inputs": { + "hyprland-protocols": "hyprland-protocols", + "nixpkgs": "nixpkgs_5", + "systems": "systems_3", + "wlroots": "wlroots", + "xdph": "xdph" + }, + "locked": { + "lastModified": 1696261738, + "narHash": "sha256-ujhtnd7vCZHJosOxTi4lgIyHA6iblYwXhx+ZS678fxw=", + "owner": "hyprwm", + "repo": "Hyprland", + "rev": "b784931e678f907b1f1e41d04485fefd8a1faaf8", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "Hyprland", + "type": "github" + } + }, + "hyprland-protocols": { + "inputs": { + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1691753796, + "narHash": "sha256-zOEwiWoXk3j3+EoF3ySUJmberFewWlagvewDRuWYAso=", + "owner": "hyprwm", + "repo": "hyprland-protocols", + "rev": "0c2ce70625cb30aef199cb388f99e19a61a6ce03", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-protocols", + "type": "github" + } + }, + "nix-colors": { + "inputs": { + "base16-schemes": "base16-schemes", + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1695388192, + "narHash": "sha256-2jelpE7xK+4M7jZNyWL7QYOYegQLYBDQS5bvdo8XRUQ=", + "owner": "misterio77", + "repo": "nix-colors", + "rev": "37227f274b34a3b51649166deb94ce7fec2c6a4c", + "type": "github" + }, + "original": { + "owner": "misterio77", + "repo": "nix-colors", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1690026219, @@ -192,6 +274,21 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1694911725, + "narHash": "sha256-8YqI+YU1DGclEjHsnrrGfqsQg3Wyga1DfTbJrN3Ud0c=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "819180647f428a3826bfc917a54449da1e532ce0", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nixpkgs-stable": { "locked": { "lastModified": 1696039360, @@ -289,6 +386,22 @@ } }, "nixpkgs_5": { + "locked": { + "lastModified": 1694767346, + "narHash": "sha256-5uH27SiVFUwsTsqC5rs3kS7pBoNhtoy9QfTP9BmknGk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ace5093e36ab1e95cb9463863491bee90d5a4183", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_6": { "locked": { "lastModified": 1694760568, "narHash": "sha256-3G07BiXrp2YQKxdcdms22MUx6spc6A++MSePtatCYuI=", @@ -311,6 +424,8 @@ "hardware": "hardware", "helix": "helix", "home-manager": "home-manager", + "hyprland": "hyprland", + "nix-colors": "nix-colors", "nixpkgs-stable": "nixpkgs-stable", "nixpkgs-unstable": "nixpkgs-unstable", "sops-nix": "sops-nix" @@ -343,7 +458,7 @@ }, "sops-nix": { "inputs": { - "nixpkgs": "nixpkgs_5", + "nixpkgs": "nixpkgs_6", "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { @@ -389,6 +504,69 @@ "repo": "default", "type": "github" } + }, + "systems_3": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + }, + "wlroots": { + "flake": false, + "locked": { + "host": "gitlab.freedesktop.org", + "lastModified": 1696255886, + "narHash": "sha256-0KZfiqqREousitBgG1mkzKmmNX4tjOIWdbBm6MvRCjQ=", + "owner": "wlroots", + "repo": "wlroots", + "rev": "5ef42e8e8adece098848fac53c721b6eb3818fc2", + "type": "gitlab" + }, + "original": { + "host": "gitlab.freedesktop.org", + "owner": "wlroots", + "repo": "wlroots", + "rev": "5ef42e8e8adece098848fac53c721b6eb3818fc2", + "type": "gitlab" + } + }, + "xdph": { + "inputs": { + "hyprland-protocols": [ + "hyprland", + "hyprland-protocols" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1694628480, + "narHash": "sha256-Qg9hstRw0pvjGu5hStkr2UX1D73RYcQ9Ns/KnZMIm9w=", + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "rev": "8f45a6435069b9e24ebd3160eda736d7a391cbf2", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 644513b..1acd1ae 100644 --- a/flake.nix +++ b/flake.nix @@ -16,8 +16,9 @@ hardware.url = "github:nixos/nixos-hardware"; - # TODO: hyprland.url = "github:hyprwm/Hyprland"; - # TODO: nix-colors.url = "github:misterio77/nix-colors"; + hyprland.url = "github:hyprwm/Hyprland"; + + nix-colors.url = "github:misterio77/nix-colors"; }; outputs = { @@ -25,6 +26,7 @@ nixpkgs-stable, nixpkgs-unstable, home-manager, + nix-colors, ... } @ inputs: let inherit (self) outputs; @@ -61,27 +63,44 @@ # NixOS configuration entrypoint # Available through 'nixos-rebuild --flake .#your-hostname' nixosConfigurations = let - # mkNixosSystem = system: modules: - # nixpkgs-stable.lib.nixosSystem { - # system = system; - # specialArgs = { - # inherit inputs outputs system; - # flake = self; - # }; - # modules = [self.nixosModules.common] ++ modules; - # }; - mkNixosUnstableSystem = system: modules: - nixpkgs-unstable.lib.nixosSystem { + mkNixosSystem = cb: system: modules: + cb { system = system; specialArgs = { - inherit inputs outputs system; + inherit inputs outputs system nix-colors; flake = self; }; - modules = [ self.nixosModules.common ] ++ modules; + modules = + [ + inputs.sops-nix.nixosModules.sops + self.nixosModules.common + ] + ++ modules + ++ [ + # all nixos hosts should use our home manager config + # TODO: unify with the module list in outputs.homeConfigurations.daniel + inputs.home-manager.nixosModules.home-manager + { + home-manager = { + extraSpecialArgs = {inherit inputs outputs system nix-colors;}; + users.daniel = { + imports = [./home ./home/linux.nix]; + }; + }; + } + ]; }; + mkNixosStableSystem = mkNixosSystem nixpkgs-stable.lib.nixosSystem; + mkNixosUnstableSystem = mkNixosSystem nixpkgs-unstable.lib.nixosSystem; in { dragon = mkNixosUnstableSystem "x86_64-linux" [./nixos/dragon]; thinker = mkNixosUnstableSystem "x86_64-linux" [./nixos/thinker]; + beefcake = mkNixosStableSystem "x86_64-linux" [ + inputs.api-lyte-dev.nixosModules.x86_64-linux.api-lyte-dev + ./nixos/beefcake + ]; + rascal = mkNixosStableSystem "x86_64-linux" [./nixos/rascal]; + musicbox = mkNixosUnstableSystem "x86_64-linux" [./nixos/musicbox]; }; # Standalone home-manager configuration entrypoint @@ -90,7 +109,7 @@ mkHome = system: modules: home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs-unstable.legacyPackages.${system}; - extraSpecialArgs = {inherit inputs outputs system;}; + extraSpecialArgs = {inherit inputs outputs system nix-colors;}; modules = modules; }; in { diff --git a/home/default.nix b/home/default.nix index e464306..f280409 100644 --- a/home/default.nix +++ b/home/default.nix @@ -3,6 +3,7 @@ lib, system, inputs, + nix-colors, ... }: let email = "daniel@lyte.dev"; @@ -18,6 +19,31 @@ in { # TODO: fonts? right now they are only handled at the nixos-level (desktop-usage module) # TODO: wallpaper? + imports = [ + nix-colors.homeManagerModules.default + ]; + + colorScheme = nix-colors.colorSchemes.catppuccin-mocha; + # copied here for easy lookups: + # https://github.com/tinted-theming/base16-schemes/blob/main/catppuccin-mocha.yaml + + # base00: "1e1e2e" # base + # base01: "181825" # mantle + # base02: "313244" # surface0 + # base03: "45475a" # surface1 + # base04: "585b70" # surface2 + # base05: "cdd6f4" # text + # base06: "f5e0dc" # rosewater + # base07: "b4befe" # lavender + # base08: "f38ba8" # red + # base09: "fab387" # peach + # base0A: "f9e2af" # yellow + # base0B: "a6e3a1" # green + # base0C: "94e2d5" # teal + # base0D: "89b4fa" # blue + # base0E: "cba6f7" # mauve + # base0F: "f2cdcd" # flamingo + home = { username = lib.mkDefault "daniel"; homeDirectory = lib.mkDefault "/home/daniel/.home"; diff --git a/home/linux.nix b/home/linux.nix index 7fd5023..f44f3db 100644 --- a/home/linux.nix +++ b/home/linux.nix @@ -13,7 +13,21 @@ services = { mako = { enable = true; + borderSize = 1; + maxVisible = 5; + defaultTimeout = 15000; + font = "Symbols Nerd Font 12,IosevkaLyteTerm 12"; # TODO: config + + backgroundColor = "#1e1e2e"; + textColor = "#cdd6f4"; + borderColor = "#89b4fa"; + progressColor = "#313244"; + + extraConfig = '' + [urgency=high] + border-color=#fab387 + ''; }; swayidle = { @@ -273,7 +287,44 @@ }; assigns = {}; bars = []; - colors = {}; + colors = with config.colorScheme.colors; { + background = "#1e1e2e"; + focused = { + background = base03; + border = base0C; + childBorder = base0C; + indicator = base0C; + text = base05; + }; + focusedInactive = { + background = base03; + border = base0D; + childBorder = base0D; + indicator = base0D; + text = base05; + }; + placeholder = { + background = base03; + border = base0D; + childBorder = base0D; + indicator = base0D; + text = base05; + }; + unfocused = { + background = base03; + border = base03; + childBorder = base03; + indicator = base03; + text = base05; + }; + urgent = { + background = base03; + border = base0F; + childBorder = base0F; + indicator = base0F; + text = base05; + }; + }; }; }; @@ -298,6 +349,10 @@ ]; programs = { + # TODO: hyprland = { + # enable = true; + # }; + waybar = { enable = true; settings = { @@ -496,6 +551,7 @@ padding: 0 0.75em; background-color: transparent; border-top: solid @sapphire 1px; + transition: none; } #workspaces button:hover { diff --git a/modules/nixos/desktop-usage.nix b/modules/nixos/desktop-usage.nix index dd5f28a..4b4ed16 100644 --- a/modules/nixos/desktop-usage.nix +++ b/modules/nixos/desktop-usage.nix @@ -4,10 +4,13 @@ system, ... }: { - # TODO: add a DE and include either plasma or gnome as a fallback? + # TODO: add a DE? + # and include either plasma or gnome as a fallback? imports = [ ./sway.nix + ./hyprland.nix + ./plasma.nix ./user-installed-applications.nix ]; diff --git a/modules/nixos/hyprland.nix b/modules/nixos/hyprland.nix new file mode 100644 index 0000000..b245c58 --- /dev/null +++ b/modules/nixos/hyprland.nix @@ -0,0 +1,3 @@ +{...}: { + # TODO: programs.hyprland.enable = true; +} diff --git a/modules/nixos/plasma.nix b/modules/nixos/plasma.nix new file mode 100644 index 0000000..574e44a --- /dev/null +++ b/modules/nixos/plasma.nix @@ -0,0 +1,5 @@ +{...}: { + services.xserver.enable = true; + services.xserver.displayManager.sddm.enable = true; + services.xserver.desktopManager.plasma5.enable = true; +} diff --git a/modules/nixos/wifi.nix b/modules/nixos/wifi.nix index 3e47e83..7e88caf 100644 --- a/modules/nixos/wifi.nix +++ b/modules/nixos/wifi.nix @@ -1,5 +1,6 @@ {...}: { networking.networkmanager.enable = true; + systemd.services.NetworkManager-wait-online.enable = false; # iwd? # powersave? diff --git a/nixos/beefcake/default.nix b/nixos/beefcake/default.nix index 62005fa..1ed462d 100644 --- a/nixos/beefcake/default.nix +++ b/nixos/beefcake/default.nix @@ -2,6 +2,7 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running 'nixos-help'). { + outputs, modulesPath, config, pkgs, @@ -9,7 +10,7 @@ }: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") - ../modules/intel.nix + outputs.nixosModules.intel ]; boot.initrd.availableKernelModules = ["ehci_pci" "megaraid_sas" "usbhid" "uas" "sd_mod"]; @@ -54,7 +55,7 @@ systemd.services.api-lyte-dev.environment.LOG_LEVEL = "debug"; sops = { - defaultSopsFile = ../secrets/beefcake/secrets.yml; + defaultSopsFile = ../../secrets/beefcake/secrets.yml; age = { sshKeyPaths = ["/etc/ssh/ssh_host_ed25519_key"]; keyFile = "/var/lib/sops-nix/key.txt"; diff --git a/nixos/default.nix b/nixos/default.nix deleted file mode 100644 index 6d75438..0000000 --- a/nixos/default.nix +++ /dev/null @@ -1,56 +0,0 @@ -inputs @ {self, ...}: let - daniel = system: { - home-manager.users.daniel = { - imports = [./home/user.nix ./home/linux.nix]; - }; - }; - hms = system: [ - inputs.home-manager.nixosModules.home-manager - (daniel system) - ]; - disko = args @ {scheme, ...}: [ - inputs.disko.nixosModules.disko - self.diskoConfigurations.${scheme} - {_module.args = args;} - ]; - nixosSystem = system: modules: (inputs.nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs system;}; - modules = - [ - inputs.sops-nix.nixosModules.sops - ./nixos/common.nix - ] - ++ modules - ++ hms system; - }); -in { - # TODO: disko-fy rascal and beefcake? - - beefcake = nixosSystem "x86_64-linux" [ - ./nixos/beefcake.nix - inputs.api-lyte-dev.nixosModules.x86_64-linux.api-lyte-dev - ]; - - rascal = nixosSystem "x86_64-linux" [./nixos/rascal.nix]; - - musicbox = nixosSystem "x86_64-linux" (disko - { - scheme = "unencrypted"; - disks = ["/dev/sda"]; - } - ++ [./nixos/musicbox.nix]); - - thinker = nixosSystem "x86_64-linux" (disko - { - scheme = "thinker"; - disks = ["/dev/nvme0n1"]; - } - ++ [./nixos/thinker.nix]); - - dragon = nixosSystem "x86_64-linux" (disko - { - scheme = "standard"; - disks = ["/dev/nvme0n1"]; - } - ++ [./nixos/dragon.nix]); -} diff --git a/nixos/musicbox/default.nix b/nixos/musicbox/default.nix index 0852386..a99fb28 100644 --- a/nixos/musicbox/default.nix +++ b/nixos/musicbox/default.nix @@ -1,165 +1,29 @@ -# 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`). { - pkgs, + flake, inputs, + outputs, + # lib, + # config, + # pkgs, ... -}: let - # this is unused because it's referenced by my sway config - dbus-sway-environment = pkgs.writeTextFile { - name = "dbus-sway-environment"; - destination = "/bin/dbus-sway-environment"; - executable = true; +}: { + networking.hostName = "musicbox"; - text = '' - dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway - systemctl --user stop wireplumber xdg-desktop-portal xdg-desktop-portal-wlr - systemctl --user start wireplumber xdg-desktop-portal xdg-desktop-portal-wlr - ''; - }; + imports = + [ + inputs.disko.nixosModules.disko + flake.diskoConfigurations.unencrypted + ] + ++ (with outputs.nixosModules; [ + # If you want to use modules your own flake exports (from modules/nixos): + desktop-usage + wifi + ]); - # this is unused because it's referenced by my 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 'Catppuccin-Mocha' - ''; - }; -in { - # TODO: fonts? right now, I'm just installing to ~/.local/share/fonts - - nix.settings.experimental-features = ["nix-command" "flakes"]; - - boot.loader.grub.devices = ["/dev/sda"]; boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - - nixpkgs.config = { - allowUnfree = true; - packageOverrides = pkgs: { - vaapiIntel = pkgs.vaapiIntel.override {enableHybridCodec = true;}; - }; - }; - hardware.bluetooth.enable = true; - hardware.opengl = { - enable = true; - driSupport32Bit = true; - driSupport = true; - - extraPackages = with pkgs; [ - intel-media-driver # LIBVA_DRIVER_NAME=iHD - vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium) - vaapiVdpau - libvdpau-va-gl - ]; - }; - - xdg.portal = { - enable = true; - wlr.enable = true; - - extraPortals = with pkgs; [ - xdg-desktop-portal-wlr - xdg-desktop-portal-gtk - ]; - }; - - programs.sway = { - enable = true; - wrapperFeatures.gtk = true; - }; - - networking.hostName = "musicbox"; networking.networkmanager.enable = true; - security.polkit.enable = true; - security.rtkit.enable = true; - - programs.fish.enable = true; - users.defaultUserShell = pkgs.fish; - - services.pipewire = { - enable = true; - wireplumber.enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - jack.enable = true; - }; - - time.timeZone = "America/Chicago"; - - i18n.defaultLocale = "en_US.UTF-8"; - console = { - font = "Lat2-Terminus16"; - useXkbConfig = true; - }; - - services.xserver.layout = "us"; - services.xserver.xkbOptions = "ctrl:nocaps"; - - hardware.pulseaudio.support32Bit = true; - - users.users.daniel = { - isNormalUser = true; - home = "/home/daniel/.home"; - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAPLXOjupz3ScYjgrF+ehrbp9OvGAWQLI6fplX6w9Ijb daniel@lyte.dev" - ]; - extraGroups = ["wheel" "video" "docker"]; - packages = []; - }; - - services.dbus.enable = true; - - services.pcscd.enable = true; - services.flatpak.enable = true; - services.gnome.gnome-keyring.enable = true; - programs.gnupg.agent = { - enable = true; - pinentryFlavor = "gnome3"; - enableSSHSupport = true; - }; - - programs.thunar.enable = true; - - services.tailscale = { - enable = true; - useRoutingFeatures = "client"; - }; - - environment.variables = { - EDITOR = "hx"; - }; - - services.openssh = { - enable = true; - settings = { - PasswordAuthentication = false; - }; - listenAddresses = [ - { - addr = "0.0.0.0"; - port = 22; - } - ]; - }; - - networking.firewall = { - enable = true; - allowPing = true; - allowedTCPPorts = []; - allowedUDPPorts = []; - }; - system.stateVersion = "23.05"; } diff --git a/nixos/rascal/default.nix b/nixos/rascal/default.nix index 842bf5f..1b30e50 100644 --- a/nixos/rascal/default.nix +++ b/nixos/rascal/default.nix @@ -1,10 +1,11 @@ { + outputs, config, modulesPath, ... }: { imports = [ - ../modules/amd.nix + outputs.nixosModules.amd (modulesPath + "/installer/scan/not-detected.nix") ]; diff --git a/readme.md b/readme.md index 2eba10f..c983912 100644 --- a/readme.md +++ b/readme.md @@ -14,13 +14,20 @@ You don't have even have to clone this crap yourself. How cool is that! But if you're gonna change stuff you had better setup the pre-commit hook: ```shell_session -ln -s $PWD/pre-commit.bash .git/hooks/pre-commit +$ ln -s $PWD/pre-commit.bash .git/hooks/pre-commit +``` + +If you're deploying anything secrets-related, you will need the proper keys: + +```shell_session +$ mkdir -p ${XDG_CONFIG_HOME:-~/.config}/sops/age +$ pass age-key >> ${XDG_CONFIG_HOME:-~/.config}/sops/age/keys.txt ``` ## NixOS ```shell_session -nixos-rebuild switch --flake git+https://git.lyte.dev/lytedev/nix +$ nixos-rebuild switch --flake git+https://git.lyte.dev/lytedev/nix ``` ## Not NixOS