From 68c1ee2656aa9acc983d246f5972b9c618675adf Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 16 Aug 2022 03:24:06 +0200 Subject: [PATCH] Make project buildable --- flake.lock | 27 +++++++++++++----------- hosts/common.nix | 22 ++++++++------------ hosts/kasei/configuration.nix | 16 ++++++-------- modules/colors.nix | 39 ++++++++++++++++++----------------- modules/machineVars.nix | 5 +++-- packages.nix | 6 +++--- programs/xmobar/default.nix | 2 +- 7 files changed, 57 insertions(+), 60 deletions(-) diff --git a/flake.lock b/flake.lock index 4df7bc1..4e999ce 100644 --- a/flake.lock +++ b/flake.lock @@ -34,8 +34,8 @@ "fonts": { "flake": false, "locked": { - "lastModified": 1649003599, - "narHash": "sha256-QtT+ansp3ombpdS2+jNWgZKSqpxhVq3cyrpAKkDzA9Y=", + "lastModified": 1651945262, + "narHash": "sha256-7r0hq5G/HjK6yVOt18VKaxuJcGM6GPu/jmwbkksJ7LE=", "path": "/home/h7x4/git/fonts", "type": "path" }, @@ -51,11 +51,11 @@ ] }, "locked": { - "lastModified": 1654113405, - "narHash": "sha256-VpK+0QaWG2JRgB00lw77N9TjkE3ec0iMYIX1TzGpxa4=", + "lastModified": 1656169755, + "narHash": "sha256-Nlnm4jeQWEGjYrE6hxi/7HYHjBSZ/E0RtjCYifnNsWk=", "owner": "nix-community", "repo": "home-manager", - "rev": "ac2287df5a2d6f0a44bbcbd11701dbbf6ec43675", + "rev": "4a3d01fb53f52ac83194081272795aa4612c2381", "type": "github" }, "original": { @@ -67,11 +67,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1655456688, - "narHash": "sha256-j2trI5gv2fnHdfUQFBy957avCPxxzCqE8R+TOYHPSRE=", + "lastModified": 1660496378, + "narHash": "sha256-sgAhmrC1iSnl5T2VPPiMpciH1aRw5c7PYEdXX6jd6Gk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d17a56d90ecbd1b8fc908d49598fb854ef188461", + "rev": "879121648fe522b38cc1cf75aef160a14a1f2e7b", "type": "github" }, "original": { @@ -99,7 +99,10 @@ }, "locked": { "lastModified": 1649874484, - "narHash": "sha256-NM+o+vIZ91hLG+C9iJCuho0Zj8BqZRC0Ttrn6cn+qCQ=", + "narHash": "sha256-gRo+xTefhEyqdHnUQihtjf1R6zFuHIHTtsTdjglWFI8=", + "ref": "main", + "rev": "9fffae0bad5225b508f1ee8cc98ac64603ed4410", + "revCount": 25, "type": "git", "url": "file:///home/h7x4/git/nix-secrets" }, @@ -111,11 +114,11 @@ "vscode-server": { "flake": false, "locked": { - "lastModified": 1648830510, - "narHash": "sha256-U+UGKbZajc2NqDvBL7hCYshAiaXgiBv5rNFIqLl0X7M=", + "lastModified": 1658079296, + "narHash": "sha256-xnUCsRKi06dJpKFxNCeMsmzkyek4teGGzjYYR+vYI7c=", "owner": "msteen", "repo": "nixos-vscode-server", - "rev": "d2343b5eb47b811856085f3eff4d899a32b2c136", + "rev": "867d5691871acc039fb47d45018c69e9ac751d95", "type": "github" }, "original": { diff --git a/hosts/common.nix b/hosts/common.nix index cdbbbe6..61dea7e 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -1,8 +1,8 @@ { pkgs, config, inputs, secrets, ... }: let inherit (pkgs) lib; - inherit (specialArgs) machineVars; - # inherit (config) machineVars; + # inherit (specialArgs) machineVars; + inherit (config) machineVars; # has_graphics = !config.machineVars.headless; in { nixpkgs.config = { @@ -11,7 +11,7 @@ in { nix = { package = pkgs.nixFlakes; - distributedBuilds = machineVars.hostname != "Tsuki"; + distributedBuilds = config.networking.hostName != "Tsuki"; binaryCaches = [ "https://cache.nixos.org/" ]; @@ -92,12 +92,6 @@ in { dash ]; - systemPackages = with pkgs; [ - wget - ] ++ (lib.optionals (!machineVars.headless) [ - haskellPackages.xmobar - ]); - etc = { # TODO: move this out of etc, and reference it directly in sudo config. sudoLecture = { @@ -127,15 +121,17 @@ in { 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) - ]); + (if screenArgs == null + then "xrandr ${screenArgs}" + else (lib.mkIf (fixDisplayCommand != null) fixDisplayCommand)); }; fonts = { diff --git a/hosts/kasei/configuration.nix b/hosts/kasei/configuration.nix index 3f92e88..4486334 100644 --- a/hosts/kasei/configuration.nix +++ b/hosts/kasei/configuration.nix @@ -21,10 +21,12 @@ default = main; }; - screens = { - "DP-1" = {}; - "HDMI-1" = {}; - }; + fixDisplayCommand = "xrandr --output DP-4 --mode 1920x1080 --pos 0x0 -r 144 --output DVI-D-1 --primary --mode 1920x1080 --pos 1920x0 -r 60"; + + # screens = { + # "DP-1" = {}; + # "HDMI-1" = {}; + # }; }; systemd.targets = { @@ -55,12 +57,6 @@ firewall.enable = true; }; - environment = { - shellAliases = { - fixscreen = "xrandr --output DP-4 --mode 1920x1080 --pos 0x0 -r 144 --output DVI-D-1 --primary --mode 1920x1080 --pos 1920x0 -r 60"; - }; - }; - services = { openssh.enable = true; printing.enable = true; diff --git a/modules/colors.nix b/modules/colors.nix index 80084cb..ee94568 100644 --- a/modules/colors.nix +++ b/modules/colors.nix @@ -3,44 +3,44 @@ let cfg = config.colors; inherit (lib) types mkOption; in { - options.colors = let + options.colors = let colorType = types.str; mkColorOption = mkOption { - # name = type = colorType; }; colorSetType = types.submodule ({ name, ... }: { - name = mkOption { - type = types.str; - default = name; + options = { + 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; }; - 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; + type = types.attrsOf colorSetType; }; defaultColorSet = mkOption { description = "the default color to use for applications"; type = colorSetType; - default = cfg.color.colorSets.monokai; }; }; - config = { - colors.colorSets = { + config.colors = rec { + colorSets = { monokai = rec { foreground = white; background = black; @@ -67,6 +67,7 @@ in { white = "#f7f3ee"; }; }; + defaultColorSet = colorSets.monokai; }; } diff --git a/modules/machineVars.nix b/modules/machineVars.nix index 2bbe3c6..2bc80ef 100644 --- a/modules/machineVars.nix +++ b/modules/machineVars.nix @@ -47,9 +47,10 @@ t tools preinstalled."; default = null; }; - dataDrives = let + dataDrives = let driveType = - types.addCheck types.path (path: builtins.elem path (builtins.attrNames config.fileSystems)); + types.path; + # types.addCheck types.path (path: builtins.elem path (builtins.attrNames config.fileSystems)); in { drives = mkOption { type = types.attrsOf driveType; diff --git a/packages.nix b/packages.nix index a7d3ba2..c584fc9 100644 --- a/packages.nix +++ b/packages.nix @@ -1,5 +1,6 @@ -{ pkgs, config, ... }: -{ +{ pkgs, config, ... }: let + inherit (config) machineVars; +in { home.packages = with pkgs; [ asciidoctor beets @@ -130,7 +131,6 @@ mopidy mopidy-mpd mopidy-soundcloud - mopidy-spotify mopidy-youtube mpc_cli nyxt diff --git a/programs/xmobar/default.nix b/programs/xmobar/default.nix index fe51d89..075db33 100644 --- a/programs/xmobar/default.nix +++ b/programs/xmobar/default.nix @@ -12,7 +12,7 @@ in { ]; mpd_status_script = pkgs.writeShellScript "mpd-status" '' - MPD_STATUS=$(${pkgs.mpc}/bin/mpc 2>/dev/null | sed -n '2{p;q}' | cut -d ' ' -f1) + MPD_STATUS=$(${pkgs.mpc-cli}/bin/mpc 2>/dev/null | sed -n '2{p;q}' | cut -d ' ' -f1) case "$MPD_STATUS" in "[playing]") echo "▶"