From 0444229bb02ecdddc653d13c420a17c084a8a0b4 Mon Sep 17 00:00:00 2001 From: Kristian Krsnik Date: Sat, 26 Aug 2023 18:35:30 +0200 Subject: [PATCH] changed structure --- flake.nix | 5 +- home/bash.nix | 15 ++-- home/default.nix | 57 ++++++---------- home/direnv.nix | 11 +-- home/firefox.nix | 33 +++++---- home/git.nix | 15 ++-- home/gnome.nix | 155 ++++++++++++++++++++++++------------------ home/nvim/default.nix | 61 ++++++++--------- home/packages.nix | 61 ++++++++--------- home/thunderbird.nix | 11 +-- home/vscode.nix | 121 +++++++++++++++++---------------- 11 files changed, 278 insertions(+), 267 deletions(-) diff --git a/flake.nix b/flake.nix index 96b5bf8..c0caa64 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,7 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs-master.url = "github:nixos/nixpkgs/master"; + home-manager = { url = "github:nix-community/home-manager/release-23.05"; inputs.nixpkgs.follows = "nixpkgs"; @@ -33,7 +34,7 @@ system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; in { - formatter.${system} = nixpkgs.legacyPackages.${system}.alejandra; + formatter.${system} = pkgs.alejandra; homeConfigurations = { kristian = home-manager.lib.homeManagerConfiguration { @@ -49,7 +50,7 @@ { nixpkgs.overlays = [ - zig.overlays.default # Adds zig + zig.overlays.default # Add zig ( # https://github.com/nix-community/home-manager/issues/1538#issuecomment-706627100 final: prev: { unstable = import nixpkgs-unstable { diff --git a/home/bash.nix b/home/bash.nix index a83fde4..16d8131 100644 --- a/home/bash.nix +++ b/home/bash.nix @@ -1,8 +1,11 @@ -{enable}: { - inherit enable; - shellAliases = { - ll = "ls -lh"; - la = "ls -lah"; - ".." = "cd .."; +{...}: { + config.programs.bash = { + enable = true; + + shellAliases = { + ll = "ls -lh"; + la = "ls -lah"; + ".." = "cd .."; + }; }; } diff --git a/home/default.nix b/home/default.nix index 17005ea..1e41159 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,11 +1,9 @@ { config, - pkgs, lib, options, specialArgs, modulesPath, - wallpaper, }: { nixpkgs.config.allowUnfreePredicate = _: true; @@ -18,19 +16,23 @@ NIXOS_OZONE_WL = 1; }; - # TODO: Change for Laptop + # Keyboard Layout + home.keyboard.layout = "at"; + + # TODO Change for Laptop targets.genericLinux.enable = false; # Enable on non-nixos ditros - # Keyboard Layout - home.keyboard.layout = "at"; # NOTE: Set by Hyprland config - - # Programs (additional programs) - home.packages = import ./packages.nix {inherit pkgs;}; - - # Services - services = { - copyq.enable = true; - }; + imports = [ + ./bash.nix + ./direnv.nix + ./firefox.nix + ./git.nix + ./gnome.nix + ./nvim + ./packages.nix + ./thunderbird.nix + ./vscode.nix + ]; # Programs programs = { @@ -38,29 +40,16 @@ mpv.enable = true; obs-studio.enable = true; yt-dlp.enable = true; + }; - bash = import ./bash.nix {enable = true;}; - vscode = import ./vscode.nix { - enable = true; - inherit pkgs; - }; - direnv = import ./direnv.nix {enable = true;}; - git = import ./git.nix {enable = true;}; - thunderbird = import ./thunderbird.nix {enable = true;}; - - neovim = import ./nvim { - enable = true; - inherit pkgs; - }; - - firefox = import ./firefox.nix { - enable = true; - nur = config.nur; - }; + # Services + services = { + copyq.enable = true; }; xdg.mimeApps = { enable = true; + defaultApplications = { "image/png" = ["org.gnome.eog.desktop"]; "image/jpeg" = ["org.gnome.eog.desktop"]; @@ -68,10 +57,4 @@ "application/pdf" = ["org.gnome.Evince.desktop"]; }; }; - - # Gnome settings - dconf.settings = import ./gnome.nix { - inherit lib; - inherit wallpaper; - }; } diff --git a/home/direnv.nix b/home/direnv.nix index 701e9fc..186d69e 100644 --- a/home/direnv.nix +++ b/home/direnv.nix @@ -1,5 +1,8 @@ -{enable}: { - inherit enable; - nix-direnv.enable = enable; - enableBashIntegration = true; +{...}: { + config.programs.direnv = { + enable = true; + + nix-direnv.enable = true; + enableBashIntegration = true; + }; } diff --git a/home/firefox.nix b/home/firefox.nix index e170b97..60e8ab5 100644 --- a/home/firefox.nix +++ b/home/firefox.nix @@ -1,24 +1,23 @@ -{ - nur, - enable, -}: { - inherit enable; - profiles.kristian = { - isDefault = true; - search.default = "DuckDuckGo"; - search.force = true; - extensions = builtins.attrValues { - inherit - (nur.repos.rycee.firefox-addons) +{config, ...}: { + config.programs.firefox = { + enable = true; + + profiles.kristian = { + isDefault = true; + search.default = "DuckDuckGo"; + search.force = true; + + extensions = with config.nur.repos.rycee.firefox-addons; [ ublock-origin umatrix sponsorblock sidebery - ; - }; - settings = { - "extensions.pocket.enabled" = false; - "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + ]; + + settings = { + "extensions.pocket.enabled" = false; + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + }; }; }; } diff --git a/home/git.nix b/home/git.nix index 0a67db8..9993c7e 100644 --- a/home/git.nix +++ b/home/git.nix @@ -1,6 +1,11 @@ -{enable}: { - inherit enable; - userName = "Kristian Krsnik"; - userEmail = "git@krsnik.at"; - extraConfig = {init.defaultBranch = "main";}; +{...}: { + config.programs.git = { + enable = true; + + userName = "Kristian Krsnik"; + userEmail = "git@krsnik.at"; + extraConfig = { + init.defaultBranch = "main"; + }; + }; } diff --git a/home/gnome.nix b/home/gnome.nix index d9abf3b..778cf6c 100644 --- a/home/gnome.nix +++ b/home/gnome.nix @@ -1,72 +1,95 @@ { - lib, + pkgs, wallpaper, + ... }: { - # Use `dconf watch /` to track stateful changes you are doing, then set them here. - "org/gnome/desktop/interface" = { - color-scheme = "prefer-dark"; - gtk-theme = "Adwaita-dark"; - }; - "org/gnome/desktop/background" = let - width = 3840; - height = 2160; - in { - picture-uri = "file://${wallpaper.override { - preset = "nord-snow-aurora"; - inherit width; - inherit height; - }}/share/wallpapers/nixos-wallpaper.png"; - picture-uri-dark = "file://${wallpaper.override { - preset = "nord-night-aurora"; - inherit width; - inherit height; - }}/share/wallpapers/nixos-wallpaper.png"; - }; - "org/gnome/desktop/wm/keybindings" = { - switch-to-workspace-left = ["1"]; - switch-to-workspace-right = ["2"]; - move-to-workspace-left = ["1"]; - move-to-workspace-right = ["2"]; - }; - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = { - binding = "a"; - command = "kgx"; - name = "Console"; - }; - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1" = { - binding = "f"; - command = "nautilus"; - name = "File Manager"; - }; - "org/gnome/settings-daemon/plugins/media-keys" = { - custom-keybindings = [ - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/" - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/" - ]; - }; - "org/gnome/settings-daemon/plugins/power" = { - sleep-inactive-ac-type = "nothing"; # Automatic suspend/hibernation creates a suspend/hibernation loop - power-button-action = "suspend"; - }; - "org/gnome/mutter" = { - edge-tiling = true; - dynamic-workspaces = true; - }; - "org/gnome/Console" = { - theme = "auto"; - }; - "org/gnome/simple-scan" = { - text-dpi = 300; - }; - "org/gnome/shell" = { - disable-user-extensions = false; - enabled-extensions = [ - "quick-settings-audio-panel@rayzeq.github.io" - "places-menu@gnome-shell-extensions.gcampax.github.com" - "launch-new-instance@gnome-shell-extensions.gcampax.github.com" - "trayIconsReloaded@selfmade.pl" - "espresso@coadmunkee.github.com" - "pano@elhan.io" + config = { + home.packages = with pkgs.gnomeExtensions; [ + quick-settings-audio-panel + tray-icons-reloaded + espresso + pano ]; + + dconf.settings = { + # Use `dconf watch /` to track stateful changes you are doing, then set them here. + "org/gnome/shell" = { + disable-user-extensions = false; + enabled-extensions = [ + "quick-settings-audio-panel@rayzeq.github.io" + "places-menu@gnome-shell-extensions.gcampax.github.com" + "launch-new-instance@gnome-shell-extensions.gcampax.github.com" + "trayIconsReloaded@selfmade.pl" + "espresso@coadmunkee.github.com" + "pano@elhan.io" + ]; + }; + + "org/gnome/desktop/interface" = { + color-scheme = "prefer-dark"; + gtk-theme = "Adwaita-dark"; + }; + + "org/gnome/desktop/background" = let + width = 3840; + height = 2160; + in { + picture-uri = "file://${wallpaper.override { + preset = "nord-snow-aurora"; + inherit width; + inherit height; + }}/share/wallpapers/nixos-wallpaper.png"; + + picture-uri-dark = "file://${wallpaper.override { + preset = "nord-night-aurora"; + inherit width; + inherit height; + }}/share/wallpapers/nixos-wallpaper.png"; + }; + + "org/gnome/desktop/wm/keybindings" = { + switch-to-workspace-left = ["1"]; + switch-to-workspace-right = ["2"]; + move-to-workspace-left = ["1"]; + move-to-workspace-right = ["2"]; + }; + + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = { + binding = "a"; + command = "kgx"; + name = "Console"; + }; + + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1" = { + binding = "f"; + command = "nautilus"; + name = "File Manager"; + }; + + "org/gnome/settings-daemon/plugins/media-keys" = { + custom-keybindings = [ + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/" + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/" + ]; + }; + + "org/gnome/settings-daemon/plugins/power" = { + sleep-inactive-ac-type = "nothing"; # Automatic suspend/hibernation creates a suspend/hibernation loop + power-button-action = "suspend"; + }; + + "org/gnome/mutter" = { + edge-tiling = true; + dynamic-workspaces = true; + }; + + "org/gnome/Console" = { + theme = "auto"; + }; + + "org/gnome/simple-scan" = { + text-dpi = 300; + }; + }; }; } diff --git a/home/nvim/default.nix b/home/nvim/default.nix index d71ae05..dfbef75 100644 --- a/home/nvim/default.nix +++ b/home/nvim/default.nix @@ -1,34 +1,28 @@ -{ - pkgs, - enable, -}: { - inherit enable; - defaultEditor = true; - viAlias = true; - vimAlias = true; - vimdiffAlias = true; +{pkgs, ...}: { + config.programs.neovim = { + enable = true; - plugins = builtins.attrValues ({ - inherit - (pkgs.vimPlugins) + defaultEditor = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + + plugins = with pkgs.vimPlugins; + [ telescope-nvim # fuzzy finder tokyonight-nvim # theme undotree # undotree vim-fugitive # git integration nvim-treesitter # syntax highlighting - + # Autocomplete and LSP - nvim-lspconfig nvim-cmp cmp-nvim-lsp luasnip - ; - } - // { - # Parsers for syntax highlighting - inherit - (pkgs.vimPlugins.nvim-treesitter-parsers) + ] + ++ (with pkgs.vimPlugins.nvim-treesitter-parsers; [ + # Parsers for syntax highlighting nix zig python @@ -43,17 +37,18 @@ c glsl bash - ; - }); - extraPackages = [pkgs.nodePackages.pyright]; - extraLuaConfig = - builtins.readFile ./keybinds.lua - + builtins.readFile ./colors.lua - + builtins.readFile ./undotree.lua - + builtins.readFile ./fugitive.lua - + builtins.readFile ./treesitter.lua - + builtins.readFile ./telescope.lua - + builtins.readFile ./cmp.lua - + builtins.readFile ./lspconfig.lua; - extraConfig = "set number relativenumber"; + ]); + + extraPackages = [pkgs.nodePackages.pyright]; + extraLuaConfig = + builtins.readFile ./keybinds.lua + + builtins.readFile ./colors.lua + + builtins.readFile ./undotree.lua + + builtins.readFile ./fugitive.lua + + builtins.readFile ./treesitter.lua + + builtins.readFile ./telescope.lua + + builtins.readFile ./cmp.lua + + builtins.readFile ./lspconfig.lua; + extraConfig = "set number relativenumber"; + }; } diff --git a/home/packages.nix b/home/packages.nix index 384cb9f..74551f8 100644 --- a/home/packages.nix +++ b/home/packages.nix @@ -1,39 +1,32 @@ -{pkgs}: -with pkgs; [ - # Basic utils - unzip - magic-wormhole +{pkgs, ...}: { + config.home.packages = with pkgs; [ + # Basic utils + unzip + magic-wormhole - # Important graphical applications - keepassxc - logseq - xournalpp - onlyoffice-bin + # Important graphical applications + keepassxc + logseq + xournalpp + onlyoffice-bin - # Communication - webcord - telegram-desktop - signal-desktop - element-desktop + # Communication + webcord + telegram-desktop + signal-desktop + element-desktop - # image editor - gimp - davinci-resolve + # Creative software + gimp + davinci-resolve - # games - osu-lazer + # Games + osu-lazer - # Misc - nerdfonts # Font with glyphs for status bar - comma # Run any binary from the repos with a comma `, cowsay neato` - - # Gnome extension - gnomeExtensions.quick-settings-audio-panel - gnomeExtensions.tray-icons-reloaded - gnomeExtensions.espresso - gnomeExtensions.pano - - gnome-decoder - - tor-browser-bundle-bin -] + # Misc + nerdfonts # Font with glyphs for status bar + comma # Run any binary from the repos with a comma `, cowsay neato` + gnome-decoder + tor-browser-bundle-bin + ]; +} diff --git a/home/thunderbird.nix b/home/thunderbird.nix index a7b1fba..063262f 100644 --- a/home/thunderbird.nix +++ b/home/thunderbird.nix @@ -1,6 +1,9 @@ -{enable}: { - inherit enable; - profiles.kristian = { - isDefault = true; +{...}: { + config.programs.thunderbird = { + enable = true; + + profiles.kristian = { + isDefault = true; + }; }; } diff --git a/home/vscode.nix b/home/vscode.nix index 6e3e081..fc4d65c 100644 --- a/home/vscode.nix +++ b/home/vscode.nix @@ -1,64 +1,67 @@ -{ - enable, - pkgs, -}: { - inherit enable; - enableUpdateCheck = false; - enableExtensionUpdateCheck = false; - keybindings = [ - { - key = "alt+a"; - command = "editor.action.commentLine"; - when = "editorTextFocus && !editorReadonly"; - } - ]; - extensions = with pkgs.vscode-extensions; [ - jnoortheen.nix-ide - arrterian.nix-env-selector - mkhl.direnv - ms-python.python - ms-python.vscode-pylance - james-yu.latex-workshop - github.copilot - davidanson.vscode-markdownlint - tamasfe.even-better-toml - asciidoctor.asciidoctor-vscode - ]; - userSettings = { - "window.menuBarVisibility" = "hidden"; - "[nix]" = { - "editor.formatOnSave" = true; - "editor.formatOnSaveMode" = "file"; # modificationsIfAvailable does not work - }; - "[python]" = { - "editor.formatOnSave" = true; - "editor.formatOnSaveMode" = "modificationsIfAvailable"; - }; - "[latex]" = { - "editor.formatOnSave" = true; - "editor.formatOnSaveMode" = "file"; # modificationsIfAvailable does not work - }; - "[toml]" = { - "editor.formatOnSave" = true; - "editor.modificationsIfAvailable" = "file"; - }; - "python.formatting.autopep8Path" = "${pkgs.python311Packages.autopep8}/bin/autopep8"; - "nix.enableLanguageServer" = true; - "nix.serverPath" = "${pkgs.nil}/bin/nil"; - "nix.serverSettings" = { - nil = { - formatting = {command = ["${pkgs.alejandra}/bin/alejandra"];}; - }; - }; - "direnv.path.executable" = "${pkgs.direnv}/bin/direnv"; - "latex-workshop.latex.outDir" = "%DIR%/out"; +{pkgs, ...}: { + config.programs.vscode = { + enable = true; - "terminal.integrated.profiles.linux" = { - "bash" = { - "path" = "${pkgs.bashInteractive}/bin/bash"; - "args" = []; + enableUpdateCheck = false; + enableExtensionUpdateCheck = false; + + keybindings = [ + { + key = "alt+a"; + command = "editor.action.commentLine"; + when = "editorTextFocus && !editorReadonly"; + } + ]; + + extensions = with pkgs.vscode-extensions; [ + jnoortheen.nix-ide + arrterian.nix-env-selector + mkhl.direnv + ms-python.python + ms-python.vscode-pylance + james-yu.latex-workshop + github.copilot + davidanson.vscode-markdownlint + tamasfe.even-better-toml + asciidoctor.asciidoctor-vscode + ]; + + userSettings = { + "window.menuBarVisibility" = "hidden"; + "[nix]" = { + "editor.formatOnSave" = true; + "editor.formatOnSaveMode" = "file"; # modificationsIfAvailable does not work }; + "[python]" = { + "editor.formatOnSave" = true; + "editor.formatOnSaveMode" = "modificationsIfAvailable"; + }; + "[latex]" = { + "editor.formatOnSave" = true; + "editor.formatOnSaveMode" = "file"; # modificationsIfAvailable does not work + }; + "[toml]" = { + "editor.formatOnSave" = true; + "editor.modificationsIfAvailable" = "file"; + }; + "python.formatting.autopep8Path" = "${pkgs.python311Packages.autopep8}/bin/autopep8"; + "nix.enableLanguageServer" = true; + "nix.serverPath" = "${pkgs.nil}/bin/nil"; + "nix.serverSettings" = { + nil = { + formatting = {command = ["${pkgs.alejandra}/bin/alejandra"];}; + }; + }; + "direnv.path.executable" = "${pkgs.direnv}/bin/direnv"; + "latex-workshop.latex.outDir" = "%DIR%/out"; + + "terminal.integrated.profiles.linux" = { + "bash" = { + "path" = "${pkgs.bashInteractive}/bin/bash"; + "args" = []; + }; + }; + "terminal.integrated.defaultProfile.linux" = "bash"; }; - "terminal.integrated.defaultProfile.linux" = "bash"; }; }