diff --git a/.gitignore b/.gitignore index 714ca05..d3d2003 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ +# Autogenerated hardware-configuration.nix + +# Symlink create by `nix build` result + +# IDEs +.idea diff --git a/README.md b/README.md index 9564cb4..6622c0e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ # NixOS Configurations -WIP! - +My NixOS configurations for my desktop diff --git a/audio.nix b/audio.nix index 0e60d5a..12b2997 100644 --- a/audio.nix +++ b/audio.nix @@ -9,6 +9,7 @@ wireplumber playerctl # Interaction with audioplayers and browsers pavucontrol # GUI + spotify ]; hardware.pulseaudio.enable = false; # Use Pipewire, the modern sound subsystem diff --git a/configuration.nix b/configuration.nix index 515d9cd..6b69faa 100644 --- a/configuration.nix +++ b/configuration.nix @@ -14,22 +14,14 @@ ./terminal ./hyprland ./audio.nix + ./networking.nix + ./development.nix ]; # Bootloader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - networking.hostName = "nixos"; # Define your hostname. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Enable networking - networking.networkmanager.enable = true; - # Set your time zone. time.timeZone = "Europe/Oslo"; @@ -80,43 +72,29 @@ environment.systemPackages = with pkgs; [ gnupg wget - git kitty - swaynotificationcenter xdg-utils xdg-desktop-portal-gtk xdg-desktop-portal-hyprland hyprpolkitagent - rofi-wayland kdePackages.dolphin kdePackages.qtwayland kdePackages.qtsvg kdePackages.qt6ct - spotify protonmail-desktop adw-gtk3 glib adwaita-icon-theme - jetbrains.rust-rover - jetbrains.webstorm - vscodium stremio - docker - rustup - nodejs - pnpm fastfetch freetube - nixd nextcloud-client ]; - nix = { - settings.experimental-features = [ - "nix-command" - "flakes" - ]; - }; + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; # Some programs need SUID wrappers, can be configured further or are # started in user sessions. @@ -130,14 +108,7 @@ gnupg.agent.enable = true; - hyprland = { - enable = true; - xwayland.enable = true; - }; - - kdeconnect = { - enable = true; - }; + kdeconnect.enable = true; steam = { enable = true; @@ -155,7 +126,6 @@ security = { # Adds Swaylock to /etc/pam.d pam.services.swaylock = { }; - rtkit.enable = true; }; services = { @@ -172,10 +142,6 @@ pcscd.enable = true; - tailscale = { - enable = true; - }; - xserver = { enable = true; # Load Nvidia driver for Xorg and Wayland @@ -201,27 +167,12 @@ }; }; - virtualisation.docker = { - enable = true; - storageDriver = "btrfs"; - rootless = { - enable = true; - setSocketVariable = true; - }; - }; - qt = { enable = true; #platformTheme = "gnome"; #style = "adwaita-dark"; }; - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - # Enable OpenGL hardware.graphics = { enable = true; diff --git a/development.nix b/development.nix new file mode 100644 index 0000000..572875a --- /dev/null +++ b/development.nix @@ -0,0 +1,26 @@ +{ pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + # IDEs + jetbrains.rust-rover + jetbrains.webstorm + vscodium # TODO set up extensions + # Tools + git + rustup + nodejs + pnpm + # Formatters + nixd + ]; + + virtualisation.docker = { + enable = true; + storageDriver = "btrfs"; + rootless = { + enable = true; + setSocketVariable = true; + }; + }; +} diff --git a/flake.nix b/flake.nix index ff46389..96a6001 100644 --- a/flake.nix +++ b/flake.nix @@ -37,7 +37,7 @@ home-manager.useUserPackages = true; # Passes inputs as an argument to home-manager home-manager.extraSpecialArgs = { inherit inputs; }; - home-manager.users.martin = import ./home.nix; + home-manager.users.martin = import ./home; } stylix.nixosModules.stylix ]; diff --git a/fmt b/fmt new file mode 100755 index 0000000..daf5825 --- /dev/null +++ b/fmt @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +# Format all .nix files using the new default nix formatter + +nix fmt ./**.nix diff --git a/home.nix b/home.nix deleted file mode 100644 index 4d88572..0000000 --- a/home.nix +++ /dev/null @@ -1,148 +0,0 @@ -{ pkgs, inputs, ... }: - -{ - imports = [ - inputs.nixvim.homeManagerModules.nixvim - ]; - - # Home Manager needs a bit of information about you and the - # paths it should manage. - home = { - username = "martin"; - homeDirectory = "/home/martin"; - - file = { - ".config/wlogout/hibernate.svg".source = ./home/wlogout/hibernate.svg; - ".config/wlogout/lock.svg".source = ./home/wlogout/lock.svg; - ".config/wlogout/logout.svg".source = ./home/wlogout/logout.svg; - ".config/wlogout/reboot.svg".source = ./home/wlogout/reboot.svg; - ".config/wlogout/shutdown.svg".source = ./home/wlogout/shutdown.svg; - ".config/wlogout/suspend.svg".source = ./home/wlogout/suspend.svg; - }; - # You can update Home Manager without changing this value. See - # the Home Manager release notes for a list of state version - # changes in each release. - stateVersion = "24.11"; - }; - - programs = { - git = { - enable = true; - userName = "Martin Berg Alstad"; - userEmail = "git@martials.no"; - }; - - # Let Home Manager install and manage itself. - home-manager.enable = true; - - kitty.enable = true; - - nixvim = { - enable = true; - - clipboard.providers.wl-copy.enable = true; - - opts = { - number = true; # Show line numbers - relativenumber = true; # Show relative line numbers - - shiftwidth = 2; # Tab width should be 2 - }; - - plugins = { - bufferline.enable = true; - - conform-nvim = { - enable = true; - # TODO use nix fmt on save - settings = { }; - }; - - lsp = { - enable = true; - servers = { - nixd.enable = true; - }; - }; - - lualine.enable = true; - luasnip.enable = true; - - cmp = { - enable = true; - - autoEnableSources = true; - - settings = { - sources = [ - { name = "nvim-lsp"; } - { name = "path"; } - { name = "buffer"; } - ]; - }; - }; - - treesitter.enable = true; - - web-devicons.enable = true; - }; - }; - starship = { - enable = true; - settings = (with builtins; fromTOML (readFile ./starship.toml)) // { }; - }; - - # Lock desktop - swaylock.enable = true; - # Log out and shutdown menu - wlogout = { - enable = true; - layout = [ - { - label = "lock"; - action = "sh -c '(sleep 0.5s; swaylock)' & disown"; - text = "Lock"; - keybind = "l"; - } - { - label = "hibernate"; - action = "systemctl hibernate"; - text = "Hibernate"; - keybind = "h"; - } - { - label = "logout"; - action = "loginctl terminate-user $USER"; - text = "Logout"; - keybind = "e"; - } - { - label = "shutdown"; - action = "systemctl poweroff"; - text = "Shutdown"; - keybind = "s"; - } - { - label = "suspend"; - action = "systemctl suspend"; - text = "Suspend"; - keybind = "u"; - } - { - label = "reboot"; - action = "systemctl reboot"; - text = "Reboot"; - keybind = "r"; - } - ]; - style = ./home/wlogout/style.css; - }; - }; - - services = { - gpg-agent = { - enable = true; - pinentryPackage = pkgs.pinentry-curses; - }; - }; -} diff --git a/home/default.nix b/home/default.nix new file mode 100644 index 0000000..bb0a50c --- /dev/null +++ b/home/default.nix @@ -0,0 +1,53 @@ +{ + pkgs, + inputs, + ... +}: + +{ + imports = [ + inputs.nixvim.homeManagerModules.nixvim + ./nixvim + ./rofi + ./wlogout + ]; + + # Home Manager needs a bit of information about you and the + # paths it should manage. + home = { + username = "martin"; + homeDirectory = "/home/martin"; + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + stateVersion = "24.11"; + }; + + programs = { + git = { + enable = true; + userName = "Martin Berg Alstad"; + userEmail = "git@martials.no"; + }; + + # Let Home Manager install and manage itself. + home-manager.enable = true; + + kitty.enable = true; + + starship = { + enable = true; + settings = (with builtins; fromTOML (readFile ./starship.toml)) // { }; + }; + + # Lock desktop + swaylock.enable = true; + }; + + services = { + gpg-agent = { + enable = true; + pinentryPackage = pkgs.pinentry-curses; + }; + }; +} diff --git a/home/nixvim/default.nix b/home/nixvim/default.nix new file mode 100644 index 0000000..396a270 --- /dev/null +++ b/home/nixvim/default.nix @@ -0,0 +1,58 @@ +# Neovim configuration for Nix +{ ... }: + +{ + programs.nixvim = { + enable = true; + + clipboard.providers.wl-copy.enable = true; + + opts = { + number = true; # Show line numbers + relativenumber = true; # Show relative line numbers + + shiftwidth = 2; # Tab width should be 2 + }; + + plugins = { + bufferline.enable = true; + + # Formatters + conform-nvim = { + enable = true; + # TODO use nix fmt on save + settings = { }; + }; + + lsp = { + enable = true; + servers = { + nixd.enable = true; + }; + }; + + lualine.enable = true; + luasnip.enable = true; + + # Completions + cmp = { + enable = true; + + autoEnableSources = true; + + # TODO complete on + settings = { + sources = [ + { name = "nvim-lsp"; } + { name = "path"; } + { name = "buffer"; } + ]; + }; + }; + + treesitter.enable = true; + + web-devicons.enable = true; + }; + }; +} diff --git a/home/rofi/catppuccin-mocha.rasi b/home/rofi/catppuccin-mocha.rasi new file mode 100644 index 0000000..38c0b80 --- /dev/null +++ b/home/rofi/catppuccin-mocha.rasi @@ -0,0 +1,111 @@ +* { + bg-col: #1e1e2e; + bg-col-light: #1e1e2e; + border-col: #1e1e2e; + selected-col: #1e1e2e; + blue: #89b4fa; + fg-col: #cdd6f4; + fg-col2: #f38ba8; + grey: #6c7086; + + width: 600; + font: "JetBrainsMono Nerd Font 14"; +} + +element-text, element-icon , mode-switcher { + background-color: inherit; + text-color: inherit; +} + +window { + height: 360px; + border: 3px; + border-color: @border-col; + background-color: @bg-col; +} + +mainbox { + background-color: @bg-col; +} + +inputbar { + children: [prompt,entry]; + background-color: @bg-col; + border-radius: 5px; + padding: 2px; +} + +prompt { + background-color: @blue; + padding: 6px; + text-color: @bg-col; + border-radius: 3px; + margin: 20px 0px 0px 20px; +} + +textbox-prompt-colon { + expand: false; + str: ":"; +} + +entry { + padding: 6px; + margin: 20px 0px 0px 10px; + text-color: @fg-col; + background-color: @bg-col; +} + +listview { + border: 0px 0px 0px; + padding: 6px 0px 0px; + margin: 10px 0px 0px 20px; + columns: 2; + lines: 5; + background-color: @bg-col; +} + +element { + padding: 5px; + background-color: @bg-col; + text-color: @fg-col ; +} + +element-icon { + size: 25px; +} + +element selected { + background-color: @selected-col ; + text-color: @fg-col2 ; +} + +mode-switcher { + spacing: 0; + } + +button { + padding: 10px; + background-color: @bg-col-light; + text-color: @grey; + vertical-align: 0.5; + horizontal-align: 0.5; +} + +button selected { + background-color: @bg-col; + text-color: @blue; +} + +message { + background-color: @bg-col-light; + margin: 2px; + padding: 2px; + border-radius: 5px; +} + +textbox { + padding: 6px; + margin: 20px 0px 0px 20px; + text-color: @blue; + background-color: @bg-col-light; +} diff --git a/home/rofi/default.nix b/home/rofi/default.nix new file mode 100644 index 0000000..636f426 --- /dev/null +++ b/home/rofi/default.nix @@ -0,0 +1,24 @@ +# App runner +{ ... }: + +{ + programs.rofi = { + enable = true; + # TODO get theme to work + # theme = lib.mkDefault ./catppuccin-mocha.rasi; + extraConfig = { + modi = "run,drun,window"; + icon-theme = "Oranchelo"; + show-icons = true; + terminal = "kitty"; + drun-display-format = "{icon} {name}"; + disable-history = false; + hide-scrollbar = true; + display-drun = "  Apps "; + display-run = "  Run "; + display-window = " 󰕰 Window"; + display-Network = " 󰤨 Network"; + sidebar-mode = true; + }; + }; +} diff --git a/starship.toml b/home/starship.toml similarity index 100% rename from starship.toml rename to home/starship.toml diff --git a/home/wlogout/default.nix b/home/wlogout/default.nix new file mode 100644 index 0000000..4ef4516 --- /dev/null +++ b/home/wlogout/default.nix @@ -0,0 +1,56 @@ +# Log out and shutdown menu +{ ... }: + +{ + home.file = { + ".config/wlogout/hibernate.svg".source = ./hibernate.svg; + ".config/wlogout/lock.svg".source = ./lock.svg; + ".config/wlogout/logout.svg".source = ./logout.svg; + ".config/wlogout/reboot.svg".source = ./reboot.svg; + ".config/wlogout/shutdown.svg".source = ./shutdown.svg; + ".config/wlogout/suspend.svg".source = ./suspend.svg; + }; + + programs.wlogout = { + enable = true; + layout = [ + { + label = "lock"; + action = "sh -c '(sleep 0.5s; swaylock)' & disown"; + text = "Lock"; + keybind = "l"; + } + { + label = "hibernate"; + action = "systemctl hibernate"; + text = "Hibernate"; + keybind = "h"; + } + { + label = "logout"; + action = "loginctl terminate-user $USER"; + text = "Logout"; + keybind = "e"; + } + { + label = "shutdown"; + action = "systemctl poweroff"; + text = "Shutdown"; + keybind = "s"; + } + { + label = "suspend"; + action = "systemctl suspend"; + text = "Suspend"; + keybind = "u"; + } + { + label = "reboot"; + action = "systemctl reboot"; + text = "Reboot"; + keybind = "r"; + } + ]; + style = ./style.css; + }; +} diff --git a/hyprland/default.nix b/hyprland/default.nix index b7dd35f..b4c5e27 100644 --- a/hyprland/default.nix +++ b/hyprland/default.nix @@ -1,8 +1,17 @@ -{ ... }: +{ pkgs, ... }: { imports = [ ./waybar.nix ./wallpaper.nix ]; + + environment.systemPackages = with pkgs; [ + swaynotificationcenter + ]; + + programs.hyprland = { + enable = true; + xwayland.enable = true; + }; } diff --git a/networking.nix b/networking.nix new file mode 100644 index 0000000..e9b6db5 --- /dev/null +++ b/networking.nix @@ -0,0 +1,22 @@ +{ ... }: + +{ + networking = { + networkmanager.enable = true; + hostName = "nixos"; + # wireless.enable = true; # Enables wireless support via wpa_supplicant. + }; + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + services.tailscale = { + enable = true; + }; +} diff --git a/rebuild b/rebuild new file mode 100755 index 0000000..6f7452b --- /dev/null +++ b/rebuild @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +# Rebuild and switch the environment if successful +git add . +sudo nixos-rebuild switch --flake .# diff --git a/result b/result deleted file mode 120000 index 0e49de5..0000000 --- a/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/1q8w6gl1ll0mwfkqc3c2yx005s6wwfrl-hello-2.12.1 \ No newline at end of file