From fa8f769068f39943e8df29a2a59ddd0bcb0ea35a Mon Sep 17 00:00:00 2001 From: Superredstone Date: Mon, 5 May 2025 21:53:36 +0200 Subject: [PATCH] Working config (until now) --- Makefile | 7 +++ configuration.nix | 21 ++++--- flake.lock | 32 +++++------ flake.nix | 17 ++++-- home/fish.nix | 2 + home/nvim/cmp.nix | 1 + home/nvim/keymaps.nix | 36 ++++++++++++ home/nvim/lsp.nix | 9 ++- home/nvim/plugins/dap.nix | 66 ++++++++++++++++++++++ home/nvim/plugins/default.nix | 3 +- lib/mksystem.nix | 100 ++++++++++++++++++++++++++++++++++ machines/katana.nix | 4 ++ modules/boot.nix | 2 +- modules/default.nix | 8 +++ modules/services.nix | 24 +++++++- modules/styling.nix | 34 ------------ 16 files changed, 297 insertions(+), 69 deletions(-) create mode 100644 Makefile create mode 100644 home/nvim/plugins/dap.nix create mode 100644 lib/mksystem.nix create mode 100644 machines/katana.nix create mode 100644 modules/default.nix delete mode 100644 modules/styling.nix diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0350a7a --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +HOSTNAME ?= $(hostname) + +switch: + sudo nixos-rebuild switch --flake ".#${HOSTNAME}" + +test: + sudo nixos-rebuild test --flake ".#${HOSTNAME}" diff --git a/configuration.nix b/configuration.nix index 299e109..6f47152 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,11 +1,9 @@ -{ pkgs, zen-browser, ... }: +{ pkgs, ... }: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ./modules/boot.nix - ./modules/nvidia.nix - ./modules/services.nix + ./modules ]; nix.gc = { @@ -49,7 +47,8 @@ }; environment.sessionVariables = { - NIXOS_OZONE_WL = "1"; # Use Wayland when possible + NIXOS_OZONE_WL = "1"; # Use Wayland when possible (this does not seem to work) + ELECTRON_OZONE_PLATFORM_HINT = "wayland"; GOPATH = "$HOME/.go"; }; @@ -84,6 +83,7 @@ fish fzf git + gnumake htop jq killall @@ -124,19 +124,22 @@ brave kdePackages.xdg-desktop-portal-kde kitty - libreoffice + libresprite mpv + nextcloud-client spotube telegram-desktop - xdg-desktop-portal - xdg-desktop-portal-gtk ]; programs.steam.enable = true; programs.steam.remotePlay.openFirewall = true; virtualisation.podman.enable = true; virtualisation.podman.dockerCompat = true; - # virtualisation.vmware.host.enable = true; + + programs.virt-manager.enable = true; + users.groups.libvirtd.members = ["r3ddy"]; + virtualisation.libvirtd.enable = true; + virtualisation.spiceUSBRedirection.enable = true; system.stateVersion = "24.05"; # Did you read the comment? } diff --git a/flake.lock b/flake.lock index bb79889..2006f03 100644 --- a/flake.lock +++ b/flake.lock @@ -46,11 +46,11 @@ ] }, "locked": { - "lastModified": 1744380363, - "narHash": "sha256-cXjAUuAfQDPSLSsckZuTioQ986iqSPTzx8D7dLAcC+Q=", + "lastModified": 1746317522, + "narHash": "sha256-/jZ4Wd4HHUEWPSlNj48k1E4Mh+1fUbwI/vSlPPIMG3U=", "owner": "nix-community", "repo": "home-manager", - "rev": "e43c6bcb101ba3301522439c459288c4a248f624", + "rev": "621986fed37c5d0cb8df010ed8369694dc47c09b", "type": "github" }, "original": { @@ -73,27 +73,27 @@ ] }, "locked": { - "lastModified": 1729958008, - "narHash": "sha256-EiOq8jF4Z/zQe0QYVc3+qSKxRK//CFHMB84aYrYGwEs=", + "lastModified": 1737371634, + "narHash": "sha256-fTVAWzT1UMm1lT+YxHuVPtH+DATrhYfea3B0MxG/cGw=", "owner": "NuschtOS", "repo": "ixx", - "rev": "9fd01aad037f345350eab2cd45e1946cc66da4eb", + "rev": "a1176e2a10ce745ff8f63e4af124ece8fe0b1648", "type": "github" }, "original": { "owner": "NuschtOS", - "ref": "v0.0.6", + "ref": "v0.0.7", "repo": "ixx", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1744232761, - "narHash": "sha256-gbl9hE39nQRpZaLjhWKmEu5ejtQsgI5TWYrIVVJn30U=", + "lastModified": 1746232882, + "narHash": "sha256-MHmBH2rS8KkRRdoU/feC/dKbdlMkcNkB5mwkuipVHeQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f675531bc7e6657c10a18b565cfebd8aa9e24c14", + "rev": "7a2622e2c0dbad5c4493cb268aba12896e28b008", "type": "github" }, "original": { @@ -112,11 +112,11 @@ "nuschtosSearch": "nuschtosSearch" }, "locked": { - "lastModified": 1744383153, - "narHash": "sha256-We4ePUixXnMOIqA9IRMWXGEW6efZRTGwTVCv5/yCvcU=", + "lastModified": 1746309817, + "narHash": "sha256-oqOpTyjdeY+LP+WiU9LxGdZ/bZ9YK7MNzNMDUw98kPM=", "owner": "nix-community", "repo": "nixvim", - "rev": "e537d4a6b4c1c81f8b71dfd916fdf970d0d5c987", + "rev": "c978122396a4208bf1965d346b7456e7256fe70c", "type": "github" }, "original": { @@ -135,11 +135,11 @@ ] }, "locked": { - "lastModified": 1743683223, - "narHash": "sha256-LdXtHFvhEC3S64dphap1pkkzwjErbW65eH1VRerCUT0=", + "lastModified": 1745046075, + "narHash": "sha256-8v4y6k16Ra/fiecb4DxhsoOGtzLKgKlS+9/XJ9z0T2I=", "owner": "NuschtOS", "repo": "search", - "rev": "56a49ffef2908dad1e9a8adef1f18802bc760962", + "rev": "066afe8643274470f4a294442aadd988356a478f", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index b49a8ea..eac8baa 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,4 @@ { - description = "My NixOS"; - inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; home-manager = { @@ -14,10 +12,21 @@ }; outputs = { self, nixpkgs, home-manager, nixvim, ... }@inputs: - let - system = "x86_64-linux"; + let + overlays = []; + personalEmail = "patrickcanal3@gmail.com"; + mkSystem = import ./lib/mksystem.nix { + inherit + overlays + inputs; + }; in { + nixosConfigurations.katana = mkSystem "katana" { + system = "x86_64-linux"; + user = "r3ddy"; + email = personalEmail; + }; nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { modules = [ ./configuration.nix diff --git a/home/fish.nix b/home/fish.nix index 1928574..9e5a2f5 100644 --- a/home/fish.nix +++ b/home/fish.nix @@ -4,6 +4,8 @@ enable = true; interactiveShellInit = '' set fish_greeting # Disable greeting + fish_config theme choose Catppuccin\ Mocha + function weather curl "wttr.in/Bolzano?0?Q?" end diff --git a/home/nvim/cmp.nix b/home/nvim/cmp.nix index 8108efd..58cdcc7 100644 --- a/home/nvim/cmp.nix +++ b/home/nvim/cmp.nix @@ -11,6 +11,7 @@ { name = "nvim_lsp_signature_help"; } { name = "path"; } { name = "buffer"; } + { name = "dap"; } ]; mapping = { "" = "cmp.mapping.select_next_item()"; diff --git a/home/nvim/keymaps.nix b/home/nvim/keymaps.nix index 78a772c..9823899 100644 --- a/home/nvim/keymaps.nix +++ b/home/nvim/keymaps.nix @@ -46,6 +46,15 @@ }; mode = "n"; } + { + action = ":lua vim.lsp.buf.format()"; + key = ""; + options = { + silent = true; + desc = "Format buffer"; + }; + mode = "n"; + } { action = ":q"; key = ""; @@ -129,5 +138,32 @@ }; mode = "n"; } + # Dap + { + action.__raw = '' + function() + require("dap").toggle_breakpoint() + end + ''; + key = "b"; + mode = "n"; + options = { + silent = true; + desc = "Toggle breakpoint"; + }; + } + { + action.__raw = '' + function() + require("dapui").toggle() + end + ''; + key = "y"; + mode = "n"; + options = { + silent = true; + desc = "Toggle debugger"; + }; + } ]; } diff --git a/home/nvim/lsp.nix b/home/nvim/lsp.nix index 91a4949..f433171 100644 --- a/home/nvim/lsp.nix +++ b/home/nvim/lsp.nix @@ -10,15 +10,18 @@ lua_ls.enable = true; rust_analyzer = { enable = true; - installCargo = true; - installRustc = true; - installRustfmt = true; + installCargo = false; + installRustc = false; + installRustfmt = false; }; zls.enable = true; nim_langserver.enable = true; pyright.enable = true; emmet_language_server.enable = true; ts_ls.enable = true; + docker_compose_language_service.enable = true; + jsonls.enable = true; + phpactor.enable = true; }; keymaps = { lspBuf = { diff --git a/home/nvim/plugins/dap.nix b/home/nvim/plugins/dap.nix new file mode 100644 index 0000000..6f87764 --- /dev/null +++ b/home/nvim/plugins/dap.nix @@ -0,0 +1,66 @@ +{ pkgs, ... }: +{ + programs.nixvim.plugins = { + dap = { + enable = true; + adapters = { + executables = { + gdb = { + command = "gdb"; + args = [ + "-i" + "dap" + ]; + }; + lldb = { + command = "lldb"; + }; + }; + servers = { + codelldb = { + port = 13000; + executable = { + command = "${pkgs.vscode-extensions.vadimcn.vscode-lldb}/share/vscode/extensions/vadimcn.vscode-lldb/adapter/codelldb"; + args = [ + "--port" + "13000" + ]; + }; + }; + }; + }; + configurations = { + cpp = [ + { + name = "Launch GDB"; + type = "gdb"; + request = "launch"; + program.__raw = '' + function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end''; + } + { + name = "Launch LLDB"; + type = "lldb"; + request = "launch"; + program.__raw = '' + function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end''; + } + { + name = "Launch CodeLLDB"; + type = "codelldb"; + request = "launch"; + program.__raw = '' + function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end''; + } + ]; + }; + }; + dap-ui.enable = true; + }; +} diff --git a/home/nvim/plugins/default.nix b/home/nvim/plugins/default.nix index a21f592..63e5917 100644 --- a/home/nvim/plugins/default.nix +++ b/home/nvim/plugins/default.nix @@ -1,4 +1,4 @@ -{ ... }: +{ pkgs, ... }: { imports = [ ./telescope.nix @@ -7,6 +7,7 @@ ./lualine.nix ./dashboard.nix ./neotree.nix + ./dap.nix ]; programs.nixvim.plugins = { diff --git a/lib/mksystem.nix b/lib/mksystem.nix new file mode 100644 index 0000000..880b94f --- /dev/null +++ b/lib/mksystem.nix @@ -0,0 +1,100 @@ +# This file comes from https://github.com/kahlstrm/nixos-config/blob/main/lib/mksystem.nix +{ + overlays, + inputs, +}: +name: +{ + system, + user, + email, + wsl ? false, + stable ? false, +}: +let + # True if this is a WSL system. + isWSL = wsl; + # resolves NixOS vs nix-darwin and stable vs unstable functions + inherit + (import ./resolve-inputs.nix { + inherit + system + stable + inputs + ; + }) + isDarwin + lib + systemFunc + nixpkgs-stable + home-manager + ; + # The config files for this system. + nixConfig = ../modules/nix-config/default.nix; + machineConfig = ../machines/${name}.nix; + OSConfig = ../modules/${if isDarwin then "darwin" else "nixos"}.nix; + HMConfig = ../modules/home-manager.nix; + systemPackages = ../modules/packages.nix; + # TODO: make this cleaner + nix-homebrew = lib.optionalAttrs isDarwin inputs.nix-homebrew.darwinModules.nix-homebrew; + nix-homebrew-config = lib.optionalAttrs isDarwin { + nix-homebrew = { + enable = true; + inherit user; + # Detect and automatically migrate existing Homebrew installations + autoMigrate = true; + # With mutableTaps disabled, taps can no longer be added imperatively with `brew tap`. + #mutableTaps = false; + }; + }; + specialArgs = { + pkgs-stable = import nixpkgs-stable { + inherit system; + config.allowUnfree = true; + }; + pkgs-unstable = import inputs.nixpkgs-unstable { + inherit system; + config.allowUnfree = true; + }; + currentSystem = system; + currentSystemName = name; + currentSystemUser = user; + currentSystemEmail = email; + isWSL = isWSL; + isDarwin = isDarwin; + inputs = inputs; + }; +in +assert isWSL -> !isDarwin; +systemFunc { + inherit system specialArgs; + # We expose some extra arguments so that our modules can parameterize + # better based on these values. + modules = [ + # Apply our overlays. Overlays are keyed by system type so we have + # to go through and apply our system type. We do this first so + # the overlays are available globally. + { nixpkgs.overlays = overlays; } + + # Allow unfree packages. + { nixpkgs.config.allowUnfree = true; } + + # Bring in WSL if this is a WSL build + (if isWSL then inputs.nixos-wsl.nixosModules.wsl else { }) + nixConfig + nix-homebrew + nix-homebrew-config + systemPackages + OSConfig + # TODO: make user config & home-manager optional + home-manager.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.${user} = import HMConfig; + home-manager.extraSpecialArgs = specialArgs; + } + machineConfig + ]; +} + diff --git a/machines/katana.nix b/machines/katana.nix new file mode 100644 index 0000000..facb35d --- /dev/null +++ b/machines/katana.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + +} diff --git a/modules/boot.nix b/modules/boot.nix index 87a18c4..3ad2680 100644 --- a/modules/boot.nix +++ b/modules/boot.nix @@ -4,5 +4,5 @@ boot.loader.efi.canTouchEfiVariables = true; boot.loader.systemd-boot.configurationLimit = 10; boot.initrd.luks.devices."luks-332a07bd-65fb-4d91-91ba-fe3f594063b1".device = "/dev/disk/by-uuid/332a07bd-65fb-4d91-91ba-fe3f594063b1"; - boot.kernelPackages = pkgs.linuxPackages_zen; + boot.kernelPackages = pkgs.linuxPackages_latest; } diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..d530c55 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,8 @@ +{ ... }: +{ + imports = [ + ./boot.nix + ./nvidia.nix + ./services.nix + ]; +} diff --git a/modules/services.nix b/modules/services.nix index 5608502..5b0f37c 100644 --- a/modules/services.nix +++ b/modules/services.nix @@ -1,11 +1,33 @@ { pkgs, ... }: { + services.flatpak.enable = true; services.xserver.videoDrivers = ["nvidia"]; services.xserver.enable = true; - services.flatpak.enable = true; services.displayManager.sddm.enable = true; services.desktopManager.plasma6.enable = true; + services.displayManager.sddm.wayland.enable = true; + + # services.xserver.displayManager.gdm.enable = true; + # services.xserver.desktopManager.gnome.enable = true; + # environment.gnome.excludePackages = (with pkgs; [ + # atomix # puzzle game + # cheese # webcam tool + # epiphany # web browser + # evince # document viewer + # geary # email reader + # gedit # text editor + # gnome-characters + # gnome-music + # gnome-photos + # gnome-terminal + # gnome-tour + # hitori # sudoku game + # iagno # go game + # tali # poker game + # totem # video player + # ]); + # Configure keymap in X11 services.xserver.xkb = { diff --git a/modules/styling.nix b/modules/styling.nix deleted file mode 100644 index ebd1fc7..0000000 --- a/modules/styling.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ pkgs, config, ... }: -{ - # Currently trying to get rid of stylix - # stylix.enable = false; - # stylix.image = pkgs.fetchurl { - # url = "https://wallpaperaccess.com/full/4268145.jpg"; - # sha256 = "06c8jmm7m0n4xlfki8sx6msdjjjbyydpyxs4k71d1lxn20ga2zph"; - # }; - # stylix.base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml"; - # stylix.cursor.package = pkgs.bibata-cursors; - # stylix.cursor.name = "Bibata-Modern-Classic"; - # stylix.cursor.size = 24; - # stylix.fonts = { - # monospace = { - # package = pkgs.nerd-fonts.jetbrains-mono; - # name = "JetBrainsMono Nerd Font"; - # }; - # sansSerif = { - # package = pkgs.dejavu_fonts; - # name = "DejaVu Sans"; - # }; - # serif = { - # package = pkgs.dejavu_fonts; - # name = "DejaVu Serif"; - # }; - # sizes = { - # terminal = 16; - # desktop = 10; - # popups = 10; - # applications = 10; - # }; - # }; - # stylix.polarity = "dark"; -}