From c1283b6ffa13da5fd07ea79347eb92d10380dd6b Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Wed, 20 Jan 2021 16:23:18 +0100 Subject: [PATCH] Add option to disable large packages Fixes #27 This adds the `sbruder.full` option (enabled by default), which disables some otherwise enabled packages/modules when disabled. When setting it to false on a full gui system it reduces the size of the system closure by over 50%. It is intended for systems with low (main) disk space. --- modules/default.nix | 8 ++++ modules/fonts.nix | 6 ++- modules/pulseaudio.nix | 20 ++++----- modules/tools.nix | 4 +- users/simon/default.nix | 1 + users/simon/modules/neovim.nix | 69 ++++++++++++++++---------------- users/simon/modules/programs.nix | 31 +++++++++----- 7 files changed, 82 insertions(+), 57 deletions(-) diff --git a/modules/default.nix b/modules/default.nix index 2bfaea5..8abc53c 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -19,6 +19,14 @@ in { # Options that affect multiple modules options.sbruder = { + full = lib.mkOption { + type = lib.types.bool; + description = '' + Whether to build the full system. If disabled, the system closure will + be smaller, but some features will not be available. + ''; + default = true; + }; gui.enable = lib.mkEnableOption "gui"; games.enable = lib.mkEnableOption "games"; }; diff --git a/modules/fonts.nix b/modules/fonts.nix index 186b247..fdf3ba4 100644 --- a/modules/fonts.nix +++ b/modules/fonts.nix @@ -3,12 +3,14 @@ lib.mkIf config.sbruder.gui.enable { fonts = { fonts = with pkgs; [ + (nerdfonts.override { fonts = [ "Iosevka" ]; }) # default monospace font + ] ++ lib.optionals config.sbruder.full [ google-fonts # google font collection (free) lmodern # Latin Modern for non-latex applications - (nerdfonts.override { fonts = [ "Iosevka" ]; }) - #roboto # standalone roboto has awful kerning source-han-sans source-han-serif # CJK fonts + ] ++ lib.optionals (!config.sbruder.full) [ + roboto # default sans-serif font (normally included in google-fonts) ] ++ lib.optionals config.sbruder.unfree.allowAssets [ corefonts # good ol’ microsoft fonts vistafonts # newer microsoft fonts diff --git a/modules/pulseaudio.nix b/modules/pulseaudio.nix index e4084e9..ff4b5c8 100644 --- a/modules/pulseaudio.nix +++ b/modules/pulseaudio.nix @@ -1,13 +1,11 @@ { config, lib, pkgs, ... }: - +let + bluetoothSupport = config.sbruder.full; +in lib.mkIf config.sbruder.gui.enable { sound.enable = true; hardware.pulseaudio = { enable = true; - package = pkgs.pulseaudioFull; - extraModules = [ - pkgs.pulseaudio-modules-bt # Non-standard codecs for bluetooth - ]; daemon.config = { "default-sample-format" = "s16le"; "default-sample-rate" = "48000"; @@ -15,13 +13,17 @@ lib.mkIf config.sbruder.gui.enable { "resample-method" = "soxr-hq"; "flat-volumes" = "no"; }; + } // lib.optionalAttrs bluetoothSupport { + package = pkgs.pulseaudioFull; + extraModules = [ + pkgs.pulseaudio-modules-bt # Non-standard codecs for bluetooth + ]; }; - # Bluetooth support - hardware.bluetooth.enable = true; - services.blueman.enable = true; - environment.systemPackages = with pkgs; [ pavucontrol ]; + + hardware.bluetooth.enable = lib.mkDefault bluetoothSupport; + services.blueman.enable = lib.mkDefault bluetoothSupport; } diff --git a/modules/tools.nix b/modules/tools.nix index e38e8cb..a50b7b3 100644 --- a/modules/tools.nix +++ b/modules/tools.nix @@ -1,6 +1,8 @@ +{ config, ... }: + { programs = { - adb.enable = builtins.currentSystem == "x86_64-linux"; + adb.enable = builtins.currentSystem == "x86_64-linux" && config.sbruder.full; bandwhich.enable = true; iotop.enable = true; }; diff --git a/users/simon/default.nix b/users/simon/default.nix index 20ddc59..491ee5c 100644 --- a/users/simon/default.nix +++ b/users/simon/default.nix @@ -35,6 +35,7 @@ in home-manager.users.simon = { lib, pkgs, ... }: { options.sbruder = { + full = inheritOption "sbruder.full"; gui.enable = inheritOption "sbruder.gui.enable"; games.enable = inheritOption "sbruder.games.enable"; unfree = { diff --git a/users/simon/modules/neovim.nix b/users/simon/modules/neovim.nix index 21eeb33..07aa010 100644 --- a/users/simon/modules/neovim.nix +++ b/users/simon/modules/neovim.nix @@ -167,39 +167,6 @@ in autocmd Filetype zsh setlocal ts=4 sw=4 sts=4 expandtab ''; plugins = (with pkgs.vimPlugins; [ - { - plugin = LanguageClient-neovim; - config = '' - let g:LanguageClient_serverCommands = { - \ 'rust': ['${pkgs.rls}/bin/rls'], - \ 'go': ['${pkgs.gopls}/bin/gopls'], - \ 'python': ['${pyls}/bin/pyls'], - \ 'typescript': ['${pkgs.nodePackages.javascript-typescript-langserver}/bin/javascript-typescript-stdio'], - \ 'javascript': ['${pkgs.nodePackages.javascript-typescript-langserver}/bin/javascript-typescript-stdio'], - \ 'haskell': ['${pkgs.haskellPackages.haskell-language-server}/bin/haskell-language-server', '--lsp'], - \ 'nix': ['${pkgs.rnix-lsp}/bin/rnix-lsp'], - \ } - - let g:LanguageClient_loggingFile = '${config.xdg.dataHome}/nvim/LanguageClient.log' - let g:LanguageClient_settingsPath = '${languageClientSettings}' - - let g:LanguageClient_selectionUI='fzf' - - function LC_maps() - if has_key(g:LanguageClient_serverCommands, &filetype) - nnoremap :call LanguageClient_contextMenu() - nnoremap K :call LanguageClient#textDocument_hover() - nnoremap gd :call LanguageClient#textDocument_definition() - nnoremap :call LanguageClient#textDocument_rename() - nnoremap f :call LanguageClient#textDocument_formatting() - " disable since it breaks most code - "set formatexpr=LanguageClient#textDocument_rangeFormatting_sync() - endif - endfunction - - autocmd FileType * call LC_maps() - ''; - } { plugin = deoplete-nvim; config = '' @@ -279,7 +246,41 @@ in autocmd BufEnter *.tex syntax sync fromstart ''; } - ]) ++ [ + ] ++ (lib.optionals config.sbruder.full [ + { + plugin = LanguageClient-neovim; + config = '' + let g:LanguageClient_serverCommands = { + \ 'rust': ['${pkgs.rls}/bin/rls'], + \ 'go': ['${pkgs.gopls}/bin/gopls'], + \ 'python': ['${pyls}/bin/pyls'], + \ 'typescript': ['${pkgs.nodePackages.javascript-typescript-langserver}/bin/javascript-typescript-stdio'], + \ 'javascript': ['${pkgs.nodePackages.javascript-typescript-langserver}/bin/javascript-typescript-stdio'], + \ 'haskell': ['${pkgs.haskellPackages.haskell-language-server}/bin/haskell-language-server', '--lsp'], + \ 'nix': ['${pkgs.rnix-lsp}/bin/rnix-lsp'], + \ } + + let g:LanguageClient_loggingFile = '${config.xdg.dataHome}/nvim/LanguageClient.log' + let g:LanguageClient_settingsPath = '${languageClientSettings}' + + let g:LanguageClient_selectionUI='fzf' + + function LC_maps() + if has_key(g:LanguageClient_serverCommands, &filetype) + nnoremap :call LanguageClient_contextMenu() + nnoremap K :call LanguageClient#textDocument_hover() + nnoremap gd :call LanguageClient#textDocument_definition() + nnoremap :call LanguageClient#textDocument_rename() + nnoremap f :call LanguageClient#textDocument_formatting() + " disable since it breaks most code + "set formatexpr=LanguageClient#textDocument_rangeFormatting_sync() + endif + endfunction + + autocmd FileType * call LC_maps() + ''; + } + ])) ++ [ Vim-Jinja2-Syntax nerdtree-git-plugin rainbow_csv diff --git a/users/simon/modules/programs.nix b/users/simon/modules/programs.nix index c5d7966..09c3fe0 100644 --- a/users/simon/modules/programs.nix +++ b/users/simon/modules/programs.nix @@ -168,23 +168,14 @@ in }) ]; })) # VoIP group chat - ungoogled-chromium # useful for exporting pages as pdf # creative/design - blender # 3d animation - darktable # photo development - gimp-with-plugins # bitmap image editor - krita # drawing openscad # parametric/procedural 3d modelling inkscape # vector graphics editor # audio and video wf-recorder # wlroots screen recorder - # audio - audacity # audio editor - picard # musicbrainz tagger - # documents calibre # ebook library @@ -194,9 +185,7 @@ in hunspellDicts.de-de hunspellDicts.en-gb-ise # dictionary gscan2pdf # scanning tool - jameica # application framework (used for hibiscus online banking) libreoffice # office suite - pdfsam-basic # pdf multitool xournalpp # notebook xsane # scanning tool @@ -209,5 +198,25 @@ in wl-clipboard # not really gui, but cli tool to manage wayland clipboard wxhexeditor # hex editor xfce.thunar # graphical file manager + ] ++ lib.optionals config.sbruder.full [ + # communication + ungoogled-chromium # useful for exporting pages as pdf + + # creative/design + blender # 3d animation + darktable # photo development + gimp-with-plugins # bitmap image editor + krita # drawing + + # audio + audacity # audio editor + picard # musicbrainz tagger + + # office + jameica # application framework (used for hibiscus online banking) + pdfsam-basic # pdf multitool + ] ++ lib.optionals (!config.sbruder.full) [ + # creative/design + gimp # without plugins ]; }