From 390d23083905e9cd26ea44393422630ffe99c9a5 Mon Sep 17 00:00:00 2001 From: stefan Date: Mon, 3 Mar 2025 21:34:53 -0500 Subject: getting started with multi-system support --- flake.lock | 36 ++++---- flake.nix | 27 ++++-- form/configuration.nix | 109 +++++++++++++++++++++++++ form/hardware-configuration.nix | 41 ++++++++++ form/home.nix | 33 ++++++++ modules/default.nix | 2 +- modules/global.nix | 9 +- modules/neovide.nix | 3 +- modules/neovim/nvim/lua/config/colorscheme.lua | 1 - modules/neovim/nvim/lua/config/lsp.lua | 5 +- modules/qutebrowser/default.nix | 13 --- modules/sway/default.nix | 11 ++- modules/zsh.nix | 27 ++++++ 13 files changed, 265 insertions(+), 52 deletions(-) create mode 100644 form/configuration.nix create mode 100644 form/hardware-configuration.nix create mode 100644 form/home.nix delete mode 100644 modules/qutebrowser/default.nix create mode 100644 modules/zsh.nix diff --git a/flake.lock b/flake.lock index a5e139f..ade5f0c 100644 --- a/flake.lock +++ b/flake.lock @@ -40,11 +40,11 @@ ] }, "locked": { - "lastModified": 1738453229, - "narHash": "sha256-7H9XgNiGLKN1G1CgRh0vUL4AheZSYzPm+zmZ7vxbJdo=", + "lastModified": 1740872218, + "narHash": "sha256-ZaMw0pdoUKigLpv9HiNDH2Pjnosg7NBYMJlHTIsHEUo=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "32ea77a06711b758da0ad9bd6a844c5740a87abd", + "rev": "3876f6b87db82f33775b1ef5ea343986105db764", "type": "github" }, "original": { @@ -99,11 +99,11 @@ ] }, "locked": { - "lastModified": 1737465171, - "narHash": "sha256-R10v2hoJRLq8jcL4syVFag7nIGE7m13qO48wRIukWNg=", + "lastModified": 1740870877, + "narHash": "sha256-LWDIJvKWMW0tiih1jTcAK0ncTi3S9IF3gOhpCT1ydik=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "9364dc02281ce2d37a1f55b6e51f7c0f65a75f17", + "rev": "25d4946dfc2021584f5bde1fbd2aa97353384a95", "type": "github" }, "original": { @@ -163,11 +163,11 @@ ] }, "locked": { - "lastModified": 1740283128, - "narHash": "sha256-R61wtNknWWejnl+K0l4sxu/wnLNFbNe44tNM2zbj5yE=", + "lastModified": 1740845322, + "narHash": "sha256-AXEgFj3C0YJhu9k1OhbRhiA6FnDr81dQZ65U3DhaWpw=", "owner": "nix-community", "repo": "home-manager", - "rev": "ed030a787938cae01d693ebaad52bbb672a4a69d", + "rev": "fcac3d6d88302a5e64f6cb8014ac785e08874c8d", "type": "github" }, "original": { @@ -189,11 +189,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1740500764, - "narHash": "sha256-AQF6DKdiKeTe5VWs5faEVmvVKtMBe5Tmjy6+Ak9lD8c=", + "lastModified": 1740874225, + "narHash": "sha256-sdBT6Njf1MDVnb4kLbGhCpXQ2P7E+50TRW1mIdujFEE=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "9709774a9967bad9f7ddd1d4eaa4d6e0399bd6d0", + "rev": "ee3854351ae89ad79eb148d4253263aeaa936913", "type": "github" }, "original": { @@ -205,11 +205,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1740432889, - "narHash": "sha256-0cWyvDni1m5pgYF6pSNRoCSezaxpb95kvt5jYCdZmfk=", + "lastModified": 1740870130, + "narHash": "sha256-nrKnJhmplq4QMcenY/bpD6SHOsiN3VS2toUtsO9NfII=", "owner": "neovim", "repo": "neovim", - "rev": "614c9322d50052c76fb3e6e1be7536a972ff0902", + "rev": "13513835798c732554de277229d4c6744df11502", "type": "github" }, "original": { @@ -241,11 +241,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1739866667, - "narHash": "sha256-EO1ygNKZlsAC9avfcwHkKGMsmipUk1Uc0TbrEZpkn64=", + "lastModified": 1741010256, + "narHash": "sha256-WZNlK/KX7Sni0RyqLSqLPbK8k08Kq7H7RijPJbq9KHM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "73cf49b8ad837ade2de76f87eb53fc85ed5d4680", + "rev": "ba487dbc9d04e0634c64e3b1f0d25839a0a68246", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index dca8221..8d7a3fd 100644 --- a/flake.nix +++ b/flake.nix @@ -39,15 +39,26 @@ }; inherit (pkgs) lib; in { - packages.${system}.default = home-manager.defaultPackage.${system}; - homeConfigurations = { - inherit inputs system pkgs; - "stefan" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - extraSpecialArgs = { - inherit system inputs pkgs; + nixosConfigurations = { + form = nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = { + inherit inputs; }; - modules = [ ./home.nix ]; + modules = [ + ./form/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager = { + users.stefan = import ./form/home.nix; + useGlobalPkgs = true; + useUserPackages = true; + extraSpecialArgs = { + inherit system inputs pkgs; + }; + }; + } + ]; }; }; }; diff --git a/form/configuration.nix b/form/configuration.nix new file mode 100644 index 0000000..d78bcd9 --- /dev/null +++ b/form/configuration.nix @@ -0,0 +1,109 @@ +{ config, lib, pkgs, inputs, ... }: + +{ + imports = + [ + ./hardware-configuration.nix + ]; + + boot.loader.systemd-boot.enable = true; + boot.loader.systemd-boot.consoleMode = "max"; + boot.loader.efi.canTouchEfiVariables = true; + + nixpkgs.config.allowUnfree = true; + + networking.hostName = "form"; + + networking.networkmanager.enable = true; + + time.timeZone = "America/New_York"; + + console = { + useXkbConfig = true; # use xkb.options in tty. + }; + + services.xserver.xkb.layout = "us"; + services.xserver.xkb.variant = "colemak_dh"; + + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + wireplumber.enable = true; + pulse.enable = true; + }; + + services.libinput.enable = true; + + programs.zsh = { + enable = true; + ohMyZsh = { + enable = true; + }; + }; + + users.users.stefan = { + isNormalUser = true; + extraGroups = [ "wheel" "networkmanager" ]; # Enable ‘sudo’ for the user. + packages = with pkgs; [ + tree + ]; + shell = pkgs.zsh; + }; + + #programs.firefox.enable = true; + programs.foot.enable = true; + programs.sway.enable = true; + security.polkit.enable = true; + + services.greetd = { + enable = true; + settings = { + default_session = { + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd 'sway --unsupported-gpu'"; + user = "greeter"; + }; + }; + }; + + environment.systemPackages = with pkgs; [ + zsh + neovim + wl-clipboard + wmenu + ]; + + environment.pathsToLink = [ "/share/zsh" ]; + + # 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; + + # Copy the NixOS configuration file and link it from the resulting system + # (/run/current-system/configuration.nix). This is useful in case you + # accidentally delete configuration.nix. + # system.copySystemConfiguration = true; + + hardware.graphics.enable = true; + services.xserver.videoDrivers = ["nvidia"]; + hardware.nvidia = { + modesetting.enable = true; + open = true; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.latest; + }; + + nix = { + settings.experimental-features = [ "nix-command" "flakes" ]; + }; + + system.stateVersion = "24.11"; +} + diff --git a/form/hardware-configuration.nix b/form/hardware-configuration.nix new file mode 100644 index 0000000..64f00e2 --- /dev/null +++ b/form/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 = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/1e39c424-417d-4218-8655-de4bb9ad57b3"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/F50B-956E"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/6fa8f3f6-f884-4879-9c11-90340ff6b3c2"; } + ]; + + # 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.enp9s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp8s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/form/home.nix b/form/home.nix new file mode 100644 index 0000000..c141011 --- /dev/null +++ b/form/home.nix @@ -0,0 +1,33 @@ +{ inputs, config, lib, pkgs, ... }: +{ + imports = [ + ../modules/global.nix + ../modules + ]; + + config.modules = { + global = { + wayland = true; + + extraPackages = with pkgs; [ + wmenu + cmatrix + ]; + }; + + foot.enable = true; + + neovim = { + enable = true; + }; + + sway = { + enable = true; + terminal = "foot"; + }; + + mako.enable = true; + neovide.enable = true; + zsh.enable = true; + }; +} diff --git a/modules/default.nix b/modules/default.nix index dc6912b..9341547 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -4,8 +4,8 @@ ./foot.nix ./mako.nix ./neovide.nix + ./zsh.nix ./sway ./neovim - ./qutebrowser ]; } diff --git a/modules/global.nix b/modules/global.nix index 76177e3..ff39759 100644 --- a/modules/global.nix +++ b/modules/global.nix @@ -28,6 +28,9 @@ in sway = { wrapWithNixGL = cfg.notNixOS; }; + # qutebrowser = { + # wrapWithNixGL = cfg.notNixOS; + # }; }; nixGL = lib.mkIf cfg.notNixOS { @@ -35,9 +38,9 @@ in defaultWrapper = "mesa"; }; - programs = { - home-manager.enable = true; - }; + # programs = { + # home-manager.enable = true; + # }; targets.genericLinux.enable = cfg.notNixOS; diff --git a/modules/neovide.nix b/modules/neovide.nix index 14a7aa4..b7694e4 100644 --- a/modules/neovide.nix +++ b/modules/neovide.nix @@ -5,12 +5,13 @@ in { options.modules.neovide = { enable = lib.mkEnableOption "neovide"; + wrapWithNixGL = lib.mkEnableOption "NixGL wrapper"; }; config = { programs.neovide = lib.mkIf cfg.enable { enable = true; - package = config.lib.nixGL.wrap pkgs.neovide; + package = if cfg.wrapWithNixGL then config.lib.nixGL.wrap pkgs.neovide else pkgs.neovide; settings = { title-hidden = true; font = { diff --git a/modules/neovim/nvim/lua/config/colorscheme.lua b/modules/neovim/nvim/lua/config/colorscheme.lua index 026c0ed..0636088 100644 --- a/modules/neovim/nvim/lua/config/colorscheme.lua +++ b/modules/neovim/nvim/lua/config/colorscheme.lua @@ -7,7 +7,6 @@ vim.cmd[[ hi FloatBorder guifg=#4c4c4c hi Pmenu guibg=#0d0d0d hi BlinkCmpMenuBorder guifg=#4c4c4c - hi BlinkCmpDocBorder guifg=#4c4c4c hi PmenuSel guibg=#191919 guifg=#cacaca hi WinBar guifg=#4c4c4c hi WinSeparator guifg=#191919 diff --git a/modules/neovim/nvim/lua/config/lsp.lua b/modules/neovim/nvim/lua/config/lsp.lua index 5effdc9..f895a8b 100644 --- a/modules/neovim/nvim/lua/config/lsp.lua +++ b/modules/neovim/nvim/lua/config/lsp.lua @@ -1,5 +1,3 @@ -local methods = vim.lsp.protocol.Methods - local servers = { clangd = {}, zls = {} @@ -13,7 +11,7 @@ require('blink.cmp').setup({ }, completion = { list = { - selection = { preselect = true, auto_insert = true }, + selection = { preselect = true, auto_insert = false }, }, menu = { border = "rounded", @@ -22,6 +20,7 @@ require('blink.cmp').setup({ documentation = { window = { border = 'rounded' } }, }, signature = { window = { border = 'rounded' } }, + fuzzy = { implementation = "prefer_rust" } }) vim.diagnostic.config({ diff --git a/modules/qutebrowser/default.nix b/modules/qutebrowser/default.nix deleted file mode 100644 index 283ea80..0000000 --- a/modules/qutebrowser/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ config, lib, pkgs, inputs, ... }: -let - cfg = config.modules.qutebrowser; -in -{ - config = { - programs.qutebrowser = { - enable = true; - package = config.lib.nixGL.wrap pkgs.qutebrowser; - loadAutoconfig = true; - }; - }; -} diff --git a/modules/sway/default.nix b/modules/sway/default.nix index fb8efa0..55ef601 100644 --- a/modules/sway/default.nix +++ b/modules/sway/default.nix @@ -65,6 +65,9 @@ in mode = "2880x1920@120.00Hz"; scale = "2.0"; }; + "DP-2" = { + mode = "1920x1080@239.761Hz"; + }; }; colors = { @@ -236,10 +239,10 @@ in startup = [ { command = "foot -s"; } { command = "wayneko --layer bottom --follow-pointer true --background-colour 0xcacaca --outline-colour 0x0f0f0f"; } - { command = "pipewire"; always = true; } # TODO need to fix this instead of running a new session every time - { command = "mpd"; } - { command = "mpdscribble"; } - { command = "avizo-service"; } # disable if on nixos or systemd +# { command = "pipewire"; always = true; } # TODO need to fix this instead of running a new session every time +# { command = "mpd"; } +# { command = "mpdscribble"; } +# { command = "avizo-service"; } # disable if on nixos or systemd ]; seat = { diff --git a/modules/zsh.nix b/modules/zsh.nix new file mode 100644 index 0000000..5085263 --- /dev/null +++ b/modules/zsh.nix @@ -0,0 +1,27 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.modules.zsh; +in +{ + options.modules.zsh = { + enable = lib.mkEnableOption "zsh"; + }; + + config = { + home.packages = with pkgs; [ + zsh + oh-my-zsh + zsh-autosuggestions + ]; + + programs.zsh = lib.mkIf cfg.enable { + enable = true; + enableCompletion = true; + autosuggestion.enable = true; + oh-my-zsh = { + enable = true; + theme = "lambda"; + }; + }; + }; +} -- cgit v1.2.3