From f28d3ea99d8b9f0bf56f8f27360470f7d015bdb6 Mon Sep 17 00:00:00 2001 From: caandt Date: Sun, 22 Dec 2024 23:46:42 -0500 Subject: [PATCH] add options --- system/audio.nix | 7 +- system/configuration.nix | 4 +- system/default.nix | 26 ++++++- system/display.nix | 8 +- system/locale.nix | 24 +++--- system/plasma.nix | 8 +- system/virt.nix | 12 +-- user/autostart.nix | 5 +- user/default.nix | 2 + user/fhs.nix | 18 +++++ user/options.nix | 17 +++++ user/packages.nix | 150 ++++++++++++++----------------------- user/prog.nix | 32 ++++++++ user/share/nsxiv-rifle.nix | 7 +- user/theme.nix | 4 +- user/xdg.nix | 4 +- 16 files changed, 209 insertions(+), 119 deletions(-) create mode 100644 user/fhs.nix create mode 100644 user/prog.nix diff --git a/system/audio.nix b/system/audio.nix index 84ce705..9672dab 100644 --- a/system/audio.nix +++ b/system/audio.nix @@ -1,4 +1,9 @@ -{...}: { +{ + config, + lib, + ... +}: +lib.mkIf config.u.has.graphical { services.pipewire = { enable = true; alsa.enable = true; diff --git a/system/configuration.nix b/system/configuration.nix index 1e09b3a..30cf9d7 100644 --- a/system/configuration.nix +++ b/system/configuration.nix @@ -12,7 +12,6 @@ environment.pathsToLink = ["/libexec"]; environment.localBinInPath = true; - services.globalprotect.enable = true; boot.tmp.useTmpfs = true; @@ -33,9 +32,10 @@ documentation.dev.enable = true; xdg.terminal-exec = { - enable = true; + enable = config.u.has.graphical; settings.default = ["Alacritty.desktop"]; }; + services.globalprotect.enable = config.u.has.graphical; environment.etc."ssh/ssh_config".text = lib.mkAfter "Include /home/*/.local/ssh/config"; diff --git a/system/default.nix b/system/default.nix index eaff0a2..a150792 100644 --- a/system/default.nix +++ b/system/default.nix @@ -1,4 +1,4 @@ -{...}: { +{lib, ...}: { imports = [ ./audio.nix ./bash.nix @@ -10,4 +10,28 @@ ./security.nix ./virt.nix ]; + options.u = { + has = { + graphical = lib.mkOption { + type = lib.types.bool; + description = "enable graphical settings"; + default = true; + }; + wine = lib.mkOption { + type = lib.types.bool; + description = "enable wine settings"; + default = true; + }; + virt = lib.mkOption { + type = lib.types.bool; + description = "enable virt settings"; + default = true; + }; + container = lib.mkOption { + type = lib.types.bool; + description = "enable container settings"; + default = true; + }; + }; + }; } diff --git a/system/display.nix b/system/display.nix index 557093a..3a7e7fd 100644 --- a/system/display.nix +++ b/system/display.nix @@ -1,4 +1,10 @@ -{pkgs, ...}: { +{ + config, + lib, + pkgs, + ... +}: +lib.mkIf config.u.has.graphical { services.xserver = { enable = true; autorun = false; diff --git a/system/locale.nix b/system/locale.nix index 23a3e5c..6c27e32 100644 --- a/system/locale.nix +++ b/system/locale.nix @@ -1,10 +1,15 @@ -{pkgs, ...}: { +{ + config, + lib, + pkgs, + ... +}: { i18n.defaultLocale = "en_US.UTF-8"; i18n.supportedLocales = [ "en_US.UTF-8/UTF-8" "ja_JP.UTF-8/UTF-8" ]; - i18n.inputMethod = { + i18n.inputMethod = lib.mkIf config.u.has.graphical { enable = true; type = "fcitx5"; fcitx5.addons = with pkgs; [ @@ -12,11 +17,12 @@ fcitx5-gtk ]; }; - fonts.packages = with pkgs; [ - noto-fonts - noto-fonts-cjk-sans - source-han-sans - source-han-serif - nerd-fonts.jetbrains-mono - ]; + fonts.packages = with pkgs; + lib.optionals config.u.has.graphical [ + noto-fonts + noto-fonts-cjk-sans + source-han-sans + source-han-serif + nerd-fonts.jetbrains-mono + ]; } diff --git a/system/plasma.nix b/system/plasma.nix index 52f8c4d..732e0fd 100644 --- a/system/plasma.nix +++ b/system/plasma.nix @@ -1,4 +1,10 @@ -{pkgs, ...}: { +{ + config, + lib, + pkgs, + ... +}: +lib.mkIf config.u.has.graphical { programs.partition-manager = { enable = true; package = pkgs.libsForQt5.partitionmanager; diff --git a/system/virt.nix b/system/virt.nix index 146ae0e..caa7f19 100644 --- a/system/virt.nix +++ b/system/virt.nix @@ -1,14 +1,14 @@ -{...}: { - virtualisation.containers.enable = true; +{config, ...}: { + virtualisation.containers.enable = config.u.has.container; virtualisation = { podman = { - enable = true; + enable = config.u.has.container; dockerCompat = true; defaultNetwork.settings.dns_enabled = true; }; }; - virtualisation.libvirtd.enable = true; - programs.virt-manager.enable = true; + virtualisation.libvirtd.enable = config.u.has.virt; + programs.virt-manager.enable = config.u.has.graphical && config.u.has.virt; programs.nix-ld.enable = true; - hardware.graphics.enable32Bit = true; + hardware.graphics.enable32Bit = config.u.has.graphical && config.u.has.wine; } diff --git a/user/autostart.nix b/user/autostart.nix index bf408b4..71afe48 100644 --- a/user/autostart.nix +++ b/user/autostart.nix @@ -1,8 +1,11 @@ { + config, + lib, pkgs, pkgs-stable, ... -}: { +}: +lib.mkIf config.u.has.graphical { systemd.user.targets.autostart = { Unit = { Wants = [ diff --git a/user/default.nix b/user/default.nix index 5f53999..ad98dbf 100644 --- a/user/default.nix +++ b/user/default.nix @@ -7,8 +7,10 @@ ./autostart.nix ./bin ./config + ./fhs.nix ./options.nix ./packages.nix + ./prog.nix ./share ./theme.nix ./xdg.nix diff --git a/user/fhs.nix b/user/fhs.nix new file mode 100644 index 0000000..0e262f7 --- /dev/null +++ b/user/fhs.nix @@ -0,0 +1,18 @@ +{pkgs, ...}: let + base = pkgs.appimageTools.defaultFhsEnvArgs; + fhs = { + name = "fhs"; + targetPkgs = pkgs: + (base.targetPkgs pkgs) + ++ [ + pkgs.pkg-config + pkgs.ncurses + ]; + profile = "export FHS=1"; + runScript = "bash"; + extraOutputsToInstall = ["dev"]; + }; + fhsenv = pkgs.buildFHSUserEnv (base // fhs); +in { + home.packages = [fhsenv]; +} diff --git a/user/options.nix b/user/options.nix index 1101035..63dd616 100644 --- a/user/options.nix +++ b/user/options.nix @@ -43,6 +43,23 @@ }); description = "list of file manager bookmarks"; }; + has = { + graphical = lib.mkOption { + type = lib.types.bool; + description = "enable graphical settings"; + default = true; + }; + wine = lib.mkOption { + type = lib.types.bool; + description = "enable wine settings"; + default = true; + }; + prog = lib.mkOption { + type = lib.types.bool; + description = "enable prog settings"; + default = true; + }; + }; lib = lib.mkOption { type = lib.types.attrs; description = "library"; diff --git a/user/packages.nix b/user/packages.nix index 6bd00e6..0b956df 100644 --- a/user/packages.nix +++ b/user/packages.nix @@ -1,101 +1,63 @@ { config, + lib, pkgs, pkgs-stable, ... }: { - home.packages = with pkgs; [ - (config.u.lib.localHome pkgs.firefox-bin "firefox" "bin/firefox") - alacritty - mpv - (config.u.lib.fixXcursor nsxiv) - rofi - sct - (config.u.lib.fixXcursor maim) - xclip - copyq - picom - obs-studio - screenkey - pkgs-stable.safeeyes - snixembed - libsForQt5.kolourpaint - libsForQt5.filelight - papirus-icon-theme - lightly-boehs - pavucontrol - qpwgraph - qbittorrent - xournalpp - adwaita-icon-theme - - lsd - bat - zoxide - fd - ripgrep - fzf - trash-cli - tlrc - speedtest-cli - bluetuith - unixtools.xxd - starship - killall - file - nix-tree - alejandra - ffmpeg - ffsubsync - unzip - unar - - (python312.withPackages (python-pkgs: [ - python-pkgs.pwntools - python-pkgs.requests - python-pkgs.pyjwt - python-pkgs.flask - ])) - nodejs - deno - gnumake - coq - coqPackages.coqide - gcc - sqlitebrowser - globalprotect-openconnect - - tmuxPlugins.vim-tmux-navigator - tmuxPlugins.sessionist - - wine - winetricks - - cage - - gdb - pwndbg - (pkgs-stable.cutter.withPlugins (ps: with ps; [jsdec rz-ghidra sigdb])) - ghidra-bin - pwninit - patchelf - (let - base = pkgs.appimageTools.defaultFhsEnvArgs; - in - pkgs.buildFHSUserEnv (base - // { - name = "fhs"; - targetPkgs = pkgs: - (base.targetPkgs pkgs) - ++ ( - with pkgs; [ - pkg-config - ncurses - ] - ); - profile = "export FHS=1"; - runScript = "bash"; - extraOutputsToInstall = ["dev"]; - })) - ]; + home.packages = with pkgs; + [ + lsd + bat + zoxide + fd + ripgrep + fzf + trash-cli + tlrc + speedtest-cli + unixtools.xxd + starship + killall + file + nix-tree + alejandra + ffmpeg + ffsubsync + unzip + unar + tmuxPlugins.vim-tmux-navigator + tmuxPlugins.sessionist + ] + ++ lib.optionals config.u.has.graphical [ + (config.u.lib.localHome pkgs.firefox-bin "firefox" "bin/firefox") + alacritty + mpv + (config.u.lib.fixXcursor nsxiv) + rofi + sct + (config.u.lib.fixXcursor maim) + xclip + copyq + picom + obs-studio + screenkey + pkgs-stable.safeeyes + snixembed + libsForQt5.kolourpaint + libsForQt5.filelight + papirus-icon-theme + lightly-boehs + pavucontrol + qpwgraph + qbittorrent + xournalpp + adwaita-icon-theme + bluetuith + globalprotect-openconnect + ] + ++ lib.optionals config.u.has.wine [ + wine + winetricks + ]; } diff --git a/user/prog.nix b/user/prog.nix new file mode 100644 index 0000000..a3dc025 --- /dev/null +++ b/user/prog.nix @@ -0,0 +1,32 @@ +{ + config, + lib, + pkgs, + ... +}: +lib.mkIf config.u.has.prog { + home.packages = with pkgs; + [ + (python312.withPackages (python-pkgs: [ + python-pkgs.pwntools + python-pkgs.requests + python-pkgs.pyjwt + python-pkgs.flask + ])) + nodejs + deno + gnumake + coq + coqPackages.coqide + gcc + gdb + pwndbg + pwninit + patchelf + ] + ++ lib.optionals config.u.has.graphical [ + (cutter.withPlugins (ps: with ps; [jsdec rz-ghidra sigdb])) + ghidra-bin + sqlitebrowser + ]; +} diff --git a/user/share/nsxiv-rifle.nix b/user/share/nsxiv-rifle.nix index 7e69e54..fb9188c 100644 --- a/user/share/nsxiv-rifle.nix +++ b/user/share/nsxiv-rifle.nix @@ -1,4 +1,9 @@ -{...}: { +{ + config, + lib, + ... +}: +lib.mkIf config.u.has.graphical { xdg.desktopEntries."nsxiv-rifle" = { exec = "nsxiv-rifle %F"; icon = "nsxiv"; diff --git a/user/theme.nix b/user/theme.nix index 3709d48..c783f87 100644 --- a/user/theme.nix +++ b/user/theme.nix @@ -1,8 +1,10 @@ { config, + lib, pkgs, ... -}: { +}: +lib.mkIf config.u.has.graphical { qt = { enable = true; platformTheme.name = "qtct"; diff --git a/user/xdg.nix b/user/xdg.nix index bec4c71..a624d3a 100644 --- a/user/xdg.nix +++ b/user/xdg.nix @@ -1,8 +1,10 @@ { config, + lib, pkgs, ... -}: { +}: +lib.mkIf config.u.has.graphical { xdg.mimeApps.enable = true; xdg.mimeApps.defaultApplications = let image = "nsxiv-rifle.desktop";