From 79a995e19e44b312ff92ee298b254e7200ca24e6 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 21 Jun 2022 01:47:36 +0200 Subject: [PATCH] Move colors and machinevars into modules --- common/colors.nix | 30 ---- flake.nix | 75 +++------ home.nix | 8 +- hosts/common.nix | 107 ++++++++++--- hosts/eisei/configuration.nix | 20 ++- hosts/kasei/configuration.nix | 5 +- hosts/tsuki/configuration.nix | 31 ++-- hosts/tsuki/services/keycloak.nix | 9 ++ hosts/tsuki/services/matrix.nix | 7 +- hosts/tsuki/services/postgres.nix | 17 ++ hosts/tsuki/services/vscode-server.nix | 8 + modules/colors.nix | 72 +++++++++ modules/default.nix | 7 + modules/machineVars.nix | 72 +++++++++ packages.nix | 147 +++++++++--------- pluggables/collections/development.nix | 0 .../collections/extended-terminal-tools.nix | 0 pluggables/collections/games.nix | 0 pluggables/collections/japanese.nix | 0 pluggables/collections/multimedia.nix | 0 pluggables/collections/school.nix | 0 pluggables/server/torrent.nix | 26 ---- pluggables/tools/programming.nix | 41 ----- programs/alacritty.nix | 6 +- programs/xmobar/default.nix | 29 +++- services/stalonetray.nix | 4 +- shellOptions.nix | 10 +- 27 files changed, 456 insertions(+), 275 deletions(-) delete mode 100644 common/colors.nix create mode 100644 hosts/tsuki/services/keycloak.nix create mode 100644 hosts/tsuki/services/postgres.nix create mode 100644 hosts/tsuki/services/vscode-server.nix create mode 100644 modules/colors.nix create mode 100644 modules/default.nix create mode 100644 modules/machineVars.nix delete mode 100644 pluggables/collections/development.nix delete mode 100644 pluggables/collections/extended-terminal-tools.nix delete mode 100644 pluggables/collections/games.nix delete mode 100644 pluggables/collections/japanese.nix delete mode 100644 pluggables/collections/multimedia.nix delete mode 100644 pluggables/collections/school.nix delete mode 100644 pluggables/server/torrent.nix delete mode 100644 pluggables/tools/programming.nix diff --git a/common/colors.nix b/common/colors.nix deleted file mode 100644 index 11edaad..0000000 --- a/common/colors.nix +++ /dev/null @@ -1,30 +0,0 @@ -rec { - monokai = { - foreground = monokai.white; - background = monokai.black; - black = "#272822"; - red = "#f92672"; - green = "#a6e22e"; - yellow = "#f4bf75"; - blue = "#66d9ef"; - magenta = "#ae81ff"; - cyan = "#a1efe4"; - white = "#f8f8f2"; - }; - - paper = { - background = "#f2e3bd"; - foreground = "#2f343f"; - black = "#222222"; - red = "#C30771"; - green = "#10A778"; - yellow = "#A89C14"; - blue = "#008ec4"; - magenta = "#523C79"; - cyan = "#20A5BA"; - white = "#f7f3ee"; - }; - - default = monokai; -} - diff --git a/flake.nix b/flake.nix index f9ff0bc..0c0a2bf 100644 --- a/flake.nix +++ b/flake.nix @@ -25,6 +25,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + vscode-server = { + url = "github:msteen/nixos-vscode-server"; + flake = false; + }; + # Nix expressions and keys (TODO: move keys to another solution like agenix) # which should be kept from the main repo for privacy reasons. # @@ -36,10 +41,11 @@ }; }; - outputs = { + outputs = inputs@{ self, nixpkgs, home-manager, + vscode-server, secrets, fonts, dotfiles, @@ -59,19 +65,6 @@ overlays = [ self.overlays.lib ]; }; - specialArgs = { - secrets = secrets.outputs.default; - colorTheme = import ./common/colors.nix; - inputs = { - inherit self; - inherit home-manager; - inherit dotfiles; - inherit fonts; - inherit website; - inherit secrets; - }; - }; - in { overlays = { lib = import ./overlays/lib; @@ -86,65 +79,45 @@ inherit system; inherit pkgs; - extraSpecialArgs = specialArgs // { - machineVars = { - hostname = "machine"; - headless = false; - screens = 1; - gaming = true; - laptop = false; - }; - }; username = "h7x4"; homeDirectory = "/home/h7x4"; stateVersion = "22.05"; configuration = { - imports = [ ./home.nix + ./modules ]; + + machineVars = { + headless = false; + fixDisplayCommand = "echo 'not available'"; + gaming = true; + development = true; + laptop = false; + }; }; }; }; nixosConfigurations = let - - # String -> AttrSet -> AttrSet - nixSys = name: extraOpts: machineVars: + nixSys = name: nixpkgs.lib.nixosSystem { inherit system; inherit pkgs; inherit (pkgs) lib; - specialArgs = specialArgs // { inherit machineVars; }; modules = [ "${home-manager}/nixos" + ./modules ./hosts/common.nix ./hosts/${name}/configuration.nix + "${vscode-server}/default.nix" + { config._module.args = { inherit inputs; secrets = secrets.outputs.default; }; } ]; - } // extraOpts; - + }; in { - Tsuki = nixSys "tsuki" {} { - hostname = "tsuki"; - headless = true; - gaming = false; - laptop = false; - }; - Eisei = nixSys "eisei" {} { - hostname = "eisei"; - headless = false; - screens = 1; - gaming = false; - laptop = true; - }; - kasei = nixSys "kasei" {} { - hostname = "kasei"; - headless = false; - screens = 2; - gaming = true; - laptop = false; - }; + Tsuki = nixSys "tsuki"; + Eisei = nixSys "eisei"; + kasei = nixSys "kasei"; }; - }; } diff --git a/home.nix b/home.nix index 645f5c3..8e6aed2 100644 --- a/home.nix +++ b/home.nix @@ -1,7 +1,7 @@ -{ pkgs, machineVars, inputs, ... } @ args: let +{ pkgs, config, inputs, ... } @ args: let inherit (pkgs) lib; inherit (pkgs.lib) mkForce mkIf optionals; - graphics = !machineVars.headless; + graphics = !config.machineVars.headless; in { imports = [ ./shellOptions.nix @@ -17,6 +17,8 @@ in { ./programs/tmux.nix ./programs/zsh + ./modules + inputs.secrets.outputs.nixosModule ] ++ optionals graphics [ ./misc/mimetypes.nix @@ -38,6 +40,8 @@ in { ./services/sxhkd.nix ]; + inherit (config) machineVars colors; + home = { stateVersion = "22.05"; username = "h7x4"; diff --git a/hosts/common.nix b/hosts/common.nix index c8d83e9..4f11b34 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -1,14 +1,17 @@ -{ pkgs, config, inputs, specialArgs, ... }: +{ pkgs, config, inputs, secrets, ... }: let inherit (pkgs) lib; + # inherit (specialArgs) machineVars; + inherit (config) machineVars; + has_graphics = !config.machineVars.headless; in { time.timeZone = "Europe/Oslo"; i18n.defaultLocale = "en_US.UTF-8"; - # nixpkgs.config = { - # allowUnfree = true; - # }; + nixpkgs.config = { + allowUnfree = true; + }; console = { font = "Lat2-Terminus16"; @@ -30,7 +33,7 @@ in { builders-use-substitutes = true ''; - distributedBuilds = config.networking.hostname != "Tsuki"; + distributedBuilds = (config.networking.hostName != "Tsuki"); binaryCaches = [ "https://cache.nixos.org/" ]; @@ -58,11 +61,11 @@ in { VISUAL = "nvim"; }; - systemPackages = with pkgs; [ + systemPackages = with pkgs; ([ wget - ] + lib.optionals (!machineVars.headless) [ + ] ++ (lib.optionals (!machineVars.headless) [ haskellPackages.xmobar - ]; + ])); shells = with pkgs; [ bashInteractive @@ -101,6 +104,8 @@ in { fonts = { enableDefaultFonts = true; + fontDir.enable = true; + fonts = with pkgs; [ cm_unicode dejavu_fonts @@ -154,18 +159,19 @@ in { home-manager = { useGlobalPkgs = true; - extraSpecialArgs = specialArgs; + extraSpecialArgs = { inherit inputs; inherit secrets; }; # TODO: figure out why specialArgs isn't accessible from the root home file. users.h7x4 = import ../home.nix { inherit pkgs; - inherit (specialArgs) machineVars inputs; + inherit inputs; + inherit config; }; }; services = { - tumbler.enable = !machineVars.headless; - gnome.gnome-keyring.enable = !machineVars.headless; + tumbler.enable = !config.machineVars.headless; + gnome.gnome-keyring.enable = !config.machineVars.headless; openssh = { # enable = true; @@ -175,7 +181,7 @@ in { }; dbus = { - enable = !machineVars.headless; + # enable = !machineVars.headless; packages = with pkgs; [ gcr dconf @@ -183,7 +189,17 @@ in { }; xserver = { - enable = !machineVars.headless; + # TODO: What is going on here? + # For some reason, this leads to infinite recursion. + # This needs to be fixed! + # Same with `displayManager.lightdm.enable` + # options are defined in each hosts config file for the time being. + # + # I have a hypothesis that there are some asserts within xserver that + # makes it so that other software can not be activated at the same time + # and that those asserts triggers some kind of evaluation chain that + # recurses infinitely. + # enable = !config.machineVars.headless; layout = "us"; xkbOptions = "caps:escape"; @@ -194,7 +210,7 @@ in { desktopManager = { xterm.enable = false; - xfce.enable = true; + xfce.enable = !config.machineVars.headless; }; windowManager.xmonad = { @@ -204,16 +220,16 @@ in { # displayManager.startx.enable = true; # displayManager.gdm.enable = true; - displayManager.lightdm.enable = true; + # displayManager.lightdm.enable = !config.machineVars.headless; displayManager.defaultSession = "none+xmonad"; }; }; programs = { - dconf.enable = !machineVars.headless; + dconf.enable = !config.machineVars.headless; git.enable = true; - light.enable = !machineVars.headless; + light.enable = !config.machineVars.headless; npm.enable = true; tmux.enable = true; @@ -252,12 +268,63 @@ in { }; }; + environment.shellAliases.fixDisplay = let + inherit (config.machineVars) screens headless fixDisplayCommand; + screenToArgs = screen: with screen; + "--output ${name} --mode ${resolution}" + + (lib.optionalString (frequency != null) " --rate ${frequency}"); + screenArgs = lib.concatStringsSep " " (lib.mapAttrsToList screenToArgs screens); + in lib.mkIf (!headless) + (lib.mkMerge [ + "xrandr ${screenArgs}" + (lib.mkIf (fixDisplayCommand != null) fixDisplayCommand) + ]); + + system.extraDependencies = + lib.optionals (config.machineVars.development) (with pkgs; [ + asciidoc + asciidoctor + cabal2nix + clang + dart + dotnet-sdk + dotnet-sdk_3 + dotnet-sdk_5 + dotnetPackages.Nuget + elm2nix + elmPackages.elm + flutter + gcc + ghc + ghcid + haskellPackages.Cabal_3_6_3_0 + maven + nixfmt + nixpkgs-fmt + # nixpkgs-hammering + nodePackages.node2nix + nodePackages.npm + nodePackages.sass + nodePackages.typescript + nodePackages.yarn + nodejs + plantuml + python3 + rustc + rustc + rustup + sqlcheck + sqlint + sqlite + sqlite-web + ]); + sound = { - enable = !machineVars.headless; + enable = !config.machineVars.headless; mediaKeys.enable = true; }; - hardware.pulseaudio.enable = !machineVars.headless; + hardware.pulseaudio.enable = !config.machineVars.headless; security.sudo.extraConfig = '' Defaults lecture = always diff --git a/hosts/eisei/configuration.nix b/hosts/eisei/configuration.nix index c3b3077..964e50b 100644 --- a/hosts/eisei/configuration.nix +++ b/hosts/eisei/configuration.nix @@ -6,9 +6,27 @@ in { imports = [ ./hardware-configuration.nix - ../../pluggables/tools/programming.nix ]; + # TODO: See ../common.nix + services.xserver.enable = true; + services.xserver.displayManager.lightdm.enable = true; + + machineVars = { + gaming = true; + creative = true; + development = true; + + headless = false; + laptop = true; + + screens = { + "eDP-1" = { + resolution = "1920x1080"; + }; + }; + }; + systemd.targets = { sleep.enable = false; suspend.enable = false; diff --git a/hosts/kasei/configuration.nix b/hosts/kasei/configuration.nix index 2765c7b..babae57 100644 --- a/hosts/kasei/configuration.nix +++ b/hosts/kasei/configuration.nix @@ -2,9 +2,12 @@ { imports = [ ./hardware-configuration.nix - ../../pluggables/tools/programming.nix ]; + # TODO: See ../common.nix + services.xserver.enable = true; + services.xserver.displayManager.lightdm.enable = true; + systemd.targets = { sleep.enable = false; suspend.enable = false; diff --git a/hosts/tsuki/configuration.nix b/hosts/tsuki/configuration.nix index 47afb4c..79e0e5a 100644 --- a/hosts/tsuki/configuration.nix +++ b/hosts/tsuki/configuration.nix @@ -1,29 +1,36 @@ { config, lib, pkgs, ... }: { - imports = - [ + imports = [ ./hardware-configuration.nix - ../../pluggables/tools/programming.nix - - ./services/nginx.nix + # ./services/calibre.nix # ./services/dokuwiki.nix + ./services/gitea # ./services/gitlab - ./services/gitea + ./services/grafana.nix + ./services/hydra.nix ./services/jitsi.nix + # ./services/keycloak.nix + # ./services/libvirt.nix + ./services/matrix.nix + ./services/nginx.nix # ./services/openldap.nix - ./services/plex.nix - ./services/hydra.nix - ./services/matrix.nix - # ./services/libvirt.nix - ./services/grafana.nix - # ./services/calibre.nix ./services/openvpn.nix + ./services/plex.nix # ./services/samba.nix ./services/searx.nix # ./services/syncthing.nix + ./services/vscode-server.nix ]; + # TODO: See ../common.nix + services.xserver.enable = false; + services.xserver.displayManager.lightdm.enable = false; + + machineVars = { + headless = true; + }; + systemd.targets = { sleep.enable = false; suspend.enable = false; diff --git a/hosts/tsuki/services/keycloak.nix b/hosts/tsuki/services/keycloak.nix new file mode 100644 index 0000000..df3eaca --- /dev/null +++ b/hosts/tsuki/services/keycloak.nix @@ -0,0 +1,9 @@ +{ }: +{ + services.keycloak = { + enable = true; + database = { + type = "postgresql"; + }; + }; +} diff --git a/hosts/tsuki/services/matrix.nix b/hosts/tsuki/services/matrix.nix index 40ba9cf..6e1b211 100644 --- a/hosts/tsuki/services/matrix.nix +++ b/hosts/tsuki/services/matrix.nix @@ -21,7 +21,10 @@ listeners = [ { port = secrets.ports.matrix.listener; - bind_address = "::1"; + bind_addresses = [ + "0.0.0.0" + "::1" + ]; type = "http"; tls = false; x_forwarded = true; @@ -58,7 +61,7 @@ }; }; - services.redis.enable = true; + # services.redis.enable = true; services.mx-puppet-discord = { enable = true; diff --git a/hosts/tsuki/services/postgres.nix b/hosts/tsuki/services/postgres.nix new file mode 100644 index 0000000..d4e2cea --- /dev/null +++ b/hosts/tsuki/services/postgres.nix @@ -0,0 +1,17 @@ +{ config, pkgs, lib, secrets, ... }: { + + services.postgresql = { + enable = true; + # port = secrets.ports.postgres + # dataDir = + # settings = {}; + }; + + services.pgadmin = { + enable = true; + openFirewall = true; + # port = secrets.ports.pgadmin + # settings = { + # }; + }; +} diff --git a/hosts/tsuki/services/vscode-server.nix b/hosts/tsuki/services/vscode-server.nix new file mode 100644 index 0000000..99ed43b --- /dev/null +++ b/hosts/tsuki/services/vscode-server.nix @@ -0,0 +1,8 @@ +{ ... }: +{ + imports = [ + (fetchTarball "https://github.com/msteen/nixos-vscode-server/tarball/master") + ]; + + services.vscode-server.enable = true; +} diff --git a/modules/colors.nix b/modules/colors.nix new file mode 100644 index 0000000..80084cb --- /dev/null +++ b/modules/colors.nix @@ -0,0 +1,72 @@ +{ pkgs, lib, config, ... }: +let + cfg = config.colors; + inherit (lib) types mkOption; +in { + options.colors = let + colorType = types.str; + + mkColorOption = mkOption { + # name = + type = colorType; + }; + + colorSetType = types.submodule ({ name, ... }: { + name = mkOption { + type = types.str; + default = name; + }; + foreground = mkColorOption; + background = mkColorOption; + black = mkColorOption; + red = mkColorOption; + green = mkColorOption; + yellow = mkColorOption; + blue = mkColorOption; + magenta = mkColorOption; + cyan = mkColorOption; + white = mkColorOption; + }); + + in { + colorSets = mkOption { + type = types.attrsof colorSetType; + }; + defaultColorSet = mkOption { + description = "the default color to use for applications"; + type = colorSetType; + default = cfg.color.colorSets.monokai; + }; + }; + + config = { + colors.colorSets = { + monokai = rec { + foreground = white; + background = black; + black = "#272822"; + red = "#f92672"; + green = "#a6e22e"; + yellow = "#f4bf75"; + blue = "#66d9ef"; + magenta = "#ae81ff"; + cyan = "#a1efe4"; + white = "#f8f8f2"; + }; + + paper = { + background = "#f2e3bd"; + foreground = "#2f343f"; + black = "#222222"; + red = "#C30771"; + green = "#10A778"; + yellow = "#A89C14"; + blue = "#008ec4"; + magenta = "#523C79"; + cyan = "#20A5BA"; + white = "#f7f3ee"; + }; + }; + }; +} + diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..b40d172 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + imports = [ + ./colors.nix + ./machineVars.nix + ]; +} diff --git a/modules/machineVars.nix b/modules/machineVars.nix new file mode 100644 index 0000000..ce1e968 --- /dev/null +++ b/modules/machineVars.nix @@ -0,0 +1,72 @@ +{ pkgs, config, ... }: +let + inherit (pkgs) lib; + inherit (lib) types mkEnableOption mkOption mkIf; + cfg = config.machineVars; +in { + options.machineVars = { + headless = mkEnableOption "Whether or not the machine should have graphical output."; + + screens = mkOption { + type = types.attrsOf (types.submodule ( { name, ...}: { + options = { + resolution = mkOption { + type = types.str; + example = "1920x1080"; + description = "The resolution of the screen"; + }; + + name = mkOption { + type = types.str; + default = name; + example = "DP-1"; + description = "The name of the screen"; + }; + + freq = mkOption { + type = types.nullOr types.str; + example = "60.00"; + description = "The update frequency of the screen, defined in Hz"; + }; + }; + })); + default = { }; + description = "A detailed description of the machines screens."; + }; + + gaming = mkEnableOption "Whether or not the machine should have gaming software installed."; + development = mkEnableOption "Whether or not the machine should come with developmen +t tools preinstalled."; + creative = mkEnableOption "Whether or not the machine should have creative software +(music, video and image editing) installed."; + + laptop = mkEnableOption "Whether the machine is a laptop"; + + fixDisplayCommand = mkOption { + type = types.nullOr types.str; + default = null; + }; + }; + + config = { + assertions = [ + { + assertion = cfg.headless -> !cfg.creative; + message = "A headless machine can't have creative software installed."; + } + { + assertion = cfg.headless -> !cfg.gaming; + message = "A headless machine can't have gaming software installed."; + } + { + assertion = cfg.headless -> (cfg.screens == { } && cfg.fixDisplayCommand == null); + message = "A headless machine can't have any screens."; + } + ]; + + warnings = lib.optionals (0 < (lib.length (builtins.attrNames cfg.screens)) && (cfg.fixDisplayCommand != null)) [ + "You are overriding the fixDisplayCommand even though machineVars.screens is defined. One of these should be omitted" + ]; + }; +} + diff --git a/packages.nix b/packages.nix index 01bec16..faed324 100644 --- a/packages.nix +++ b/packages.nix @@ -1,4 +1,4 @@ -{ pkgs, machineVars, ... }: +{ pkgs, config, ... }: { home.packages = with pkgs; [ asciidoctor @@ -51,13 +51,14 @@ mmv mps-youtube mtr + navi neofetch nix-diff nix-index nix-output-monitor nix-tree nix-zsh-completions - nixops + # nixops nmap ouch pandoc @@ -86,6 +87,8 @@ wavemon wiki-tui youtube-dl + yq + zip # Needed for VSCode liveshare desktop-file-utils @@ -94,76 +97,74 @@ icu openssl xorg.xprop - ] ++ ( - lib.optionals (!machineVars.headless) [ - ahoviewer - anki - audacity - calibre - cool-retro-term - copyq - darktable - discord - element-desktop - fcitx - geogebra - gnome.gnome-font-viewer - google-chrome - inkscape - insomnia - iwgtk - kid3 - koreader - krita - ktouch - libreoffice-fresh - light - maim - mopidy - mopidy-mpd - mopidy-soundcloud - mopidy-spotify - mopidy-youtube - mpc_cli - nyxt - pulseaudio - pulsemixer - scrcpy - shellcheck - slack - sublime3 - sxiv - tagainijisho - teams - tenacity - transcribe - wireshark - xcalib - xclip - xdotool - xfce.thunar - xfce.thunar-archive-plugin - xfce.thunar-dropbox-plugin - xfce.thunar-media-tags-plugin - xfce.thunar-volman - # xsnow # Wait until christmas - yuzu-mainline - zeal - zoom-us - zotero - ] ++ lib.optionals (machineVars.laptop) [ - touchegg - ] ++ lib.optionals (machineVars.gaming) [ - citra - desmume - minecraft - osu-lazer - retroarchFull - steam - steam-tui - stepmania - taisei - ] - ); + ] ++ lib.optionals (!config.machineVars.headless) [ + ahoviewer + anki + audacity + calibre + cool-retro-term + copyq + darktable + discord + element-desktop + fcitx + geogebra + gnome.gnome-font-viewer + google-chrome + inkscape + insomnia + iwgtk + kid3 + koreader + krita + ktouch + libreoffice-fresh + light + maim + mopidy + mopidy-mpd + mopidy-soundcloud + mopidy-spotify + mopidy-youtube + mpc_cli + nyxt + pulseaudio + pulsemixer + scrcpy + shellcheck + slack + sublime3 + sxiv + tagainijisho + teams + tenacity + transcribe + wireshark + xcalib + xclip + xdotool + xfce.thunar + xfce.thunar-archive-plugin + xfce.thunar-dropbox-plugin + xfce.thunar-media-tags-plugin + xfce.thunar-volman + # xsnow # Wait until christmas + yuzu-mainline + zeal + zoom-us + zotero + ] ++ lib.optionals (config.machineVars.laptop) [ + touchegg + ] ++ lib.optionals (config.machineVars.gaming) [ + citra + desmume + minecraft + osu-lazer + retroarchFull + steam + steam-tui + stepmania + taisei + ]; } diff --git a/pluggables/collections/development.nix b/pluggables/collections/development.nix deleted file mode 100644 index e69de29..0000000 diff --git a/pluggables/collections/extended-terminal-tools.nix b/pluggables/collections/extended-terminal-tools.nix deleted file mode 100644 index e69de29..0000000 diff --git a/pluggables/collections/games.nix b/pluggables/collections/games.nix deleted file mode 100644 index e69de29..0000000 diff --git a/pluggables/collections/japanese.nix b/pluggables/collections/japanese.nix deleted file mode 100644 index e69de29..0000000 diff --git a/pluggables/collections/multimedia.nix b/pluggables/collections/multimedia.nix deleted file mode 100644 index e69de29..0000000 diff --git a/pluggables/collections/school.nix b/pluggables/collections/school.nix deleted file mode 100644 index e69de29..0000000 diff --git a/pluggables/server/torrent.nix b/pluggables/server/torrent.nix deleted file mode 100644 index 205e789..0000000 --- a/pluggables/server/torrent.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ pkgs }: -{ - services.deluge = { - enable = true; - user = "h7x4"; - - # https://git.deluge-torrent.org/deluge/tree/deluge/core/preferencesmanager.py#n41 - # config = { - # download_location = ""; - # share_ratio_limit = ""; - # daemon_port = ""; - # listen_ports = ""; - # }; - - openFirewall = true; - # authFile = - - declarative = true; - - web = { - enable = true; - # port = - openFirewall = true; - }; - }; -} diff --git a/pluggables/tools/programming.nix b/pluggables/tools/programming.nix deleted file mode 100644 index aa139bd..0000000 --- a/pluggables/tools/programming.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ pkgs, ... }: -{ - system.extraDependencies = with pkgs; [ - asciidoc - asciidoctor - cabal2nix - clang - dart - dotnet-sdk - dotnet-sdk_3 - dotnet-sdk_5 - dotnetPackages.Nuget - elm2nix - elmPackages.elm - flutter - gcc - ghc - ghcid - haskellPackages.Cabal_3_6_2_0 - maven - nixfmt - nixpkgs-fmt - # nixpkgs-hammering - nodePackages.node2nix - nodePackages.npm - nodePackages.sass - nodePackages.typescript - nodePackages.yarn - nodejs - plantuml - python3 - rustc - rustc - rustup - sqlcheck - sqlint - sqlite - sqlite-web - ]; -} - diff --git a/programs/alacritty.nix b/programs/alacritty.nix index 28a8ff3..f14004b 100644 --- a/programs/alacritty.nix +++ b/programs/alacritty.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, colorTheme, ... }: +{ pkgs, lib, config, ... }: { programs.alacritty = { enable = true; @@ -22,10 +22,10 @@ primaryColors = [ "foreground" "background" ]; in { - primary = getAttrs primaryColors colorTheme.default; + primary = getAttrs primaryColors config.colors.defaultColorSet; normal = let removePrimaryColorAttrs = n: v: !(any (pc: n ? pc) primaryColors); - in filterAttrs removePrimaryColorAttrs colorTheme.default; + in filterAttrs removePrimaryColorAttrs config.colors.defaultColorSet; }; background_opacity = 1.0; diff --git a/programs/xmobar/default.nix b/programs/xmobar/default.nix index d5dc86b..4a3e2c0 100644 --- a/programs/xmobar/default.nix +++ b/programs/xmobar/default.nix @@ -1,13 +1,36 @@ -{ pkgs, colorTheme, ... }: let +{ pkgs, config, ... }: let inherit (pkgs) lib; in { programs.xmobar = let networkCard = "wlp2s0f0u7u4"; + disks = [ "/" "/data" "/data/disks/data2" ]; + + mpd_status_script = pkgs.writeShellScript "mpd-status" '' + MPD_STATUS=$(${pkgs.mpc}/bin/mpc 2>/dev/null | sed -n '2{p;q}' | cut -d ' ' -f1) + case "$MPD_STATUS" in + "[playing]") + echo "▶" + # echo "[行]" + exit 0 + ;; + "[paused]") + echo "⏸" + # echo "[止]" + exit 0 + ;; + *) + echo "⏼" + # echo "[無]" + exit 0 + ;; + esac + ''; + in { enable = true; extraConfig = '' @@ -22,7 +45,7 @@ in { ] , borderColor = "black" , border = TopB - , bgColor = "#272822" + , bgColor = "${config.colors.defaultColorSet.background}" , fgColor = "grey" , alpha = 255 , position = Static { xpos = 0 , ypos = 0, width = 1920, height = 40 } @@ -48,7 +71,7 @@ in { Run Memory ["-t","%"] 10, Run Swap ["-t", "%"] 100, Run Date "%a %_d %b - %H:%M - W%W" "date" 10, - Run Com "${./scripts/mpd_status.sh}" [] "mpc" 10, + Run Com "${mpd_status_script}" [] "mpc" 10, -- Run Com "${./scripts/wireless.sh}" [] "wi" 100, Run Com "${./scripts/volume.py}" [] "vol" 10, Run UnsafeStdinReader, diff --git a/services/stalonetray.nix b/services/stalonetray.nix index 584abfb..d2a6ad7 100644 --- a/services/stalonetray.nix +++ b/services/stalonetray.nix @@ -1,4 +1,4 @@ -{ colorTheme, ... }: +{ config, ... }: { services.stalonetray = { enable = true; @@ -7,7 +7,7 @@ transparent = false; dockapp_mode = "none"; geometry = "8x1-0+0"; - background = colorTheme.default.background; + background = config.colors.defaultColorSet.background; kludges = "force_icons_size"; grow_gravity = "NW"; icon_gravity = "NW"; diff --git a/shellOptions.nix b/shellOptions.nix index 56b6774..1c97112 100644 --- a/shellOptions.nix +++ b/shellOptions.nix @@ -1,4 +1,4 @@ -{ pkgs, config, machineVars, ... }: let +{ pkgs, config, ... }: let # FIXME: lib should be imported directly as a module argument. inherit (pkgs) lib; @@ -141,6 +141,7 @@ in rec { hms = "home-manager switch"; nxr = "sudo nixos-rebuild switch"; + nxp = "nix-shell -p "; nxc = "sudoedit /etc/nixos/configuration.nix"; nxh = "vim ~/.config/nixpkgs/home.nix"; @@ -262,13 +263,6 @@ in rec { view-latex = "${texlive.combined.scheme-full}/bin/latexmk -pdf -pvc main.tex"; reload-tmux = "${tmux}/bin/tmux source $HOME/.config/tmux/tmux.conf"; - - fixdisplay = let - commands = { - "kasei" = "xrandr --output DVI-I-1 --mode 1920x1080 --pos 1920x0 -r 60 --primary --output DP-3 --mode 1920x1080 --pos 0x0 -r 144"; - }; - in - if commands ? ${machineVars.hostname} then commands.${machineVars.hostname} else "echo \"fixdisplay not defined for this hostname\""; }; # ░█▀▀░█▀▀░█▀█░█▀▀░█▀▄░█▀█░▀█▀░█▀▀░█▀▄