diff --git a/default.nix b/default.nix index 0643e244..d8340ab7 100644 --- a/default.nix +++ b/default.nix @@ -2,7 +2,7 @@ rec { sources = import ./nix/sources.nix; pkgs = import ./pkgs { inherit sources; }; modList = import ./lib/modules.nix; - + profiles = modList { modulesDir = ./profiles; }; diff --git a/hosts/athame/meta.nix b/hosts/athame/meta.nix index f3010bb4..2767c647 100644 --- a/hosts/athame/meta.nix +++ b/hosts/athame/meta.nix @@ -50,14 +50,14 @@ with config.resources; { #}; /* resources.athame_rdns = { - provider = "hcloud"; - type = "rdns"; - inputs = { - server_id = athame.refAttr "id"; - dns_ptr = "athame.kittywit.ch"; - ip_address = athame.refAttr "ipv4_address"; - }; - }; + provider = "hcloud"; + type = "rdns"; + inputs = { + server_id = athame.refAttr "id"; + dns_ptr = "athame.kittywit.ch"; + ip_address = athame.refAttr "ipv4_address"; + }; + }; */ #dns.records.kittywitch_athame = { diff --git a/hosts/athame/nixos/virtualhosts.nix b/hosts/athame/nixos/virtualhosts.nix index 45b3f70f..d2d0a118 100644 --- a/hosts/athame/nixos/virtualhosts.nix +++ b/hosts/athame/nixos/virtualhosts.nix @@ -7,7 +7,8 @@ let enableACME = true; forceSSL = true; }; -in { +in +{ services.nginx.virtualHosts = { "kittywit.ch" = { root = pkgs.kat-website; } // common; "athame.kittywit.ch" = { root = "/var/www/athame"; } // common; diff --git a/hosts/dummy/home/default.nix b/hosts/dummy/home/default.nix index 865d4690..88d8a3b6 100644 --- a/hosts/dummy/home/default.nix +++ b/hosts/dummy/home/default.nix @@ -1,5 +1,3 @@ { config, lib, pkgs, ... }: -{ - -} +{ } diff --git a/hosts/dummy/nixos/default.nix b/hosts/dummy/nixos/default.nix index bb0f841b..c6ce0909 100644 --- a/hosts/dummy/nixos/default.nix +++ b/hosts/dummy/nixos/default.nix @@ -6,7 +6,8 @@ let hexchen = (import sources.nix-hexchen) { }; hexYgg = filterAttrs (_: c: c.enable) (mapAttrs (_: host: host.config.hexchen.network) hexchen.hosts); -in { +in +{ # stuff so dummy host is buildable (you probably don't want/need this???) # but idk your config sooooo boot.isContainer = true; @@ -17,8 +18,9 @@ in { enable = true; pubkey = "0000000000000000000000000000000000000000000000000000000000000000"; listen.enable = true; - listen.endpoints = flatten (map (c: c.listen.endpoints) (filter (c: - c.listen.enable && (c.pubkey + listen.endpoints = flatten (map (c: c.listen.endpoints) (filter + (c: + c.listen.enable && (c.pubkey != "0000000000000000000000000000000000000000000000000000000000000000")) (attrValues hexYgg))); extra.pubkeys = { diff --git a/hosts/samhain/home/sway/default.nix b/hosts/samhain/home/sway/default.nix index 0057f7cb..10365424 100644 --- a/hosts/samhain/home/sway/default.nix +++ b/hosts/samhain/home/sway/default.nix @@ -4,67 +4,72 @@ imports = [ ./swayidle.nix ]; wayland.windowManager.sway = { - config = let lockCommand = "swaylock -i HDMI-A-1:${../../../../users/kat/sway/wallpapers/main.png} -i DP-1:${ + config = + let + lockCommand = "swaylock -i HDMI-A-1:${../../../../users/kat/sway/wallpapers/main.png} -i DP-1:${ ../../../../users/kat/sway/wallpapers/left.jpg } -i DVI-D-1:${../../../../users/kat/sway/wallpapers/right.jpg} -s fill"; - cfg = config.wayland.windowManager.sway.config; - in { - #startup = [{ command = "${pkgs.ckb-next}/bin/ckb-next -b"; }]; + cfg = config.wayland.windowManager.sway.config; + in + { + #startup = [{ command = "${pkgs.ckb-next}/bin/ckb-next -b"; }]; - output = let - left = { - res = "1920x1080"; - pos = "0 0"; - }; - middle = { - res = "1920x1200"; - pos = "1920 0"; - }; - right = { - res = "1920x1080"; - pos = "3840 0"; - }; - in { - "DP-1" = left; - "DVI-D-1" = middle; - "HDMI-A-1" = right; - }; - - keybindings = { - "${cfg.modifier}+x" = "exec ${lockCommand}"; - }; - - modes = { - "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown" = + output = + let + left = { + res = "1920x1080"; + pos = "0 0"; + }; + middle = { + res = "1920x1200"; + pos = "1920 0"; + }; + right = { + res = "1920x1080"; + pos = "3840 0"; + }; + in { - "l" = "exec ${lockCommand}, mode default"; - "e" = "exec swaymsg exit, mode default"; - "s" = "exec systemctl suspend, mode default"; - "h" = "exec systemctl hibernate, mode default"; - "r" = "exec systemctl reboot, mode default"; - "Shift+s" = "exec systemctl shutdown, mode default"; - "Return" = "mode default"; - "Escape" = "mode default"; + "DP-1" = left; + "DVI-D-1" = middle; + "HDMI-A-1" = right; + }; + + keybindings = { + "${cfg.modifier}+x" = "exec ${lockCommand}"; + }; + + modes = { + "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown" = + { + "l" = "exec ${lockCommand}, mode default"; + "e" = "exec swaymsg exit, mode default"; + "s" = "exec systemctl suspend, mode default"; + "h" = "exec systemctl hibernate, mode default"; + "r" = "exec systemctl reboot, mode default"; + "Shift+s" = "exec systemctl shutdown, mode default"; + "Return" = "mode default"; + "Escape" = "mode default"; + }; + }; + + input = { + "5824:1503:screenstub-tablet" = { events = "disabled"; }; + "5824:1503:screenstub-mouse" = { events = "disabled"; }; + "5824:1503:screenstub-kbd" = { events = "disabled"; }; + "1386:215:Wacom_BambooPT_2FG_Small_Pen" = { + map_to_output = "HDMI-A-1"; + }; + "1386:215:Wacom_BambooPT_2FG_Small_Finger" = { + natural_scroll = "enabled"; + middle_emulation = "enabled"; + tap = "enabled"; + dwt = "enabled"; + accel_profile = "flat"; + pointer_accel = "0.05"; }; }; - - input = { - "5824:1503:screenstub-tablet" = { events = "disabled"; }; - "5824:1503:screenstub-mouse" = { events = "disabled"; }; - "5824:1503:screenstub-kbd" = { events = "disabled"; }; - "1386:215:Wacom_BambooPT_2FG_Small_Pen" = { - map_to_output = "HDMI-A-1"; - }; - "1386:215:Wacom_BambooPT_2FG_Small_Finger" = { - natural_scroll = "enabled"; - middle_emulation = "enabled"; - tap = "enabled"; - dwt = "enabled"; - accel_profile = "flat"; - pointer_accel = "0.05"; - }; }; - }; extraConfig = '' workspace "1" output "DP-1" workspace "11:F1" output "DVI-1" diff --git a/hosts/samhain/nixos/default.nix b/hosts/samhain/nixos/default.nix index 52805faf..593cff75 100644 --- a/hosts/samhain/nixos/default.nix +++ b/hosts/samhain/nixos/default.nix @@ -6,7 +6,8 @@ let hexchen = (import sources.nix-hexchen) { }; hexYgg = filterAttrs (_: c: c.enable) (mapAttrs (_: host: host.config.hexchen.network) hexchen.hosts); -in { +in +{ imports = [ ./hw.nix profiles.gui diff --git a/hosts/samhain/nixos/transmission.nix b/hosts/samhain/nixos/transmission.nix index d9647d14..337c1577 100644 --- a/hosts/samhain/nixos/transmission.nix +++ b/hosts/samhain/nixos/transmission.nix @@ -1,33 +1,35 @@ { config, pkgs, ... }: { - services.transmission = let - transmission-done-script = pkgs.writeScriptBin "script" '' - #!${pkgs.bash}/bin/bash - set -e - if [ "$TR_TORRENT_DIR"/"$TR_TORRENT_NAME" != "/" ]; then - cd "$TR_TORRENT_DIR"/"$TR_TORRENT_NAME" - if [ ! -z "*.rar" ]; then - ${pkgs.unrar}/bin/unrar x "*.rar" - fi - chmod ugo=rwX . - fi''; - in { - enable = true; - home = "/mnt/zraw/transmission"; - downloadDirPermissions = "777"; - settings = { - download-dir = "/mnt/zraw/media/unsorted"; - incomplete-dir = "/mnt/zraw/media/.incomplete"; - incomplete-dir-enabled = true; - rpc-bind-address = "::"; - rpc-whitelist-enabled = false; - rpc-host-whitelist-enabled = false; - script-torrent-done-enabled = true; - dht-enabled = true; - pex-enabled = true; - script-torrent-done-filename = "${transmission-done-script}/bin/script"; - umask = 0; + services.transmission = + let + transmission-done-script = pkgs.writeScriptBin "script" '' + #!${pkgs.bash}/bin/bash + set -e + if [ "$TR_TORRENT_DIR"/"$TR_TORRENT_NAME" != "/" ]; then + cd "$TR_TORRENT_DIR"/"$TR_TORRENT_NAME" + if [ ! -z "*.rar" ]; then + ${pkgs.unrar}/bin/unrar x "*.rar" + fi + chmod ugo=rwX . + fi''; + in + { + enable = true; + home = "/mnt/zraw/transmission"; + downloadDirPermissions = "777"; + settings = { + download-dir = "/mnt/zraw/media/unsorted"; + incomplete-dir = "/mnt/zraw/media/.incomplete"; + incomplete-dir-enabled = true; + rpc-bind-address = "::"; + rpc-whitelist-enabled = false; + rpc-host-whitelist-enabled = false; + script-torrent-done-enabled = true; + dht-enabled = true; + pex-enabled = true; + script-torrent-done-filename = "${transmission-done-script}/bin/script"; + umask = 0; + }; }; - }; } diff --git a/hosts/yule/home/sway/default.nix b/hosts/yule/home/sway/default.nix index fb2c8837..24c9ca4a 100644 --- a/hosts/yule/home/sway/default.nix +++ b/hosts/yule/home/sway/default.nix @@ -3,19 +3,24 @@ { imports = [ ./swayidle.nix ]; - wayland.windowManager.sway.config = let lockCommand = "swaylock -i eDP-1:${ + wayland.windowManager.sway.config = + let + lockCommand = "swaylock -i eDP-1:${ ../../../../users/kat/sway/wallpapers/main.png } -s fill"; - cfg = config.wayland.windowManager.sway.config; - in { - output = let - laptop = { - res = "1920x1080"; - pos = "0 0"; - }; - in { "eDP-1" = laptop; }; + cfg = config.wayland.windowManager.sway.config; + in + { + output = + let + laptop = { + res = "1920x1080"; + pos = "0 0"; + }; + in + { "eDP-1" = laptop; }; - keybindings = { + keybindings = { "${cfg.modifier}+x" = "exec ${lockCommand}"; }; @@ -31,16 +36,16 @@ "Return" = "mode default"; "Escape" = "mode default"; }; - }; + }; - input = { - "1739:33362:Synaptics_TM3336-002" = { - dwt = "enabled"; - tap = "enabled"; - natural_scroll = "enabled"; - middle_emulation = "enabled"; - click_method = "clickfinger"; + input = { + "1739:33362:Synaptics_TM3336-002" = { + dwt = "enabled"; + tap = "enabled"; + natural_scroll = "enabled"; + middle_emulation = "enabled"; + click_method = "clickfinger"; + }; }; }; - }; } diff --git a/lib/colorhelpers.nix b/lib/colorhelpers.nix index 7a98a3b7..62a6f014 100644 --- a/lib/colorhelpers.nix +++ b/lib/colorhelpers.nix @@ -5,17 +5,21 @@ let pairs = lib.imap0 (lib.flip lib.nameValuePair) hexChars; idx = builtins.listToAttrs pairs; - in idx.${lib.toLower char}; + in + idx.${lib.toLower char}; hexToInt = str: lib.foldl (value: chr: value * 16 + hexCharToInt chr) 0 - (lib.stringToCharacters str); + (lib.stringToCharacters str); hextorgba = hex: - (let - r_hex = lib.substring 1 2 hex; - g_hex = lib.substring 3 2 hex; - b_hex = lib.substring 5 2 hex; - r_dec = hexToInt r_hex; - g_dec = hexToInt g_hex; - b_dec = hexToInt b_hex; - in "rgba(${toString r_dec}, ${toString g_dec}, ${toString b_dec}, 0.75)"); + ( + let + r_hex = lib.substring 1 2 hex; + g_hex = lib.substring 3 2 hex; + b_hex = lib.substring 5 2 hex; + r_dec = hexToInt r_hex; + g_dec = hexToInt g_hex; + b_dec = hexToInt b_hex; + in + "rgba(${toString r_dec}, ${toString g_dec}, ${toString b_dec}, 0.75)" + ); } diff --git a/lib/deploy.nix b/lib/deploy.nix index f2bb0dde..17c65fcc 100644 --- a/lib/deploy.nix +++ b/lib/deploy.nix @@ -14,18 +14,20 @@ let tf = { targetName, target }: tfEval ({ config, ... }: { imports = optional (builtins.pathExists ../trusted/tf) (import ../trusted/tf/meta.nix) - ++ map (hostName: ../hosts + "/${hostName}/meta.nix") target ++ [{ - config = mkMerge (map (hostName: - mapAttrs (_: mkMerge) hosts.${hostName}.config.deploy.tf.out.set) + ++ map (hostName: ../hosts + "/${hostName}/meta.nix") target ++ [{ + config = mkMerge (map + (hostName: + mapAttrs (_: mkMerge) hosts.${hostName}.config.deploy.tf.out.set) target); }] ++ optional (builtins.pathExists (../trusted/targets + "/${targetName}")) (../trusted/targets + "/${targetName}") ++ optional (builtins.pathExists (../targets + "/${targetName}")) - (../targets + "/${targetName}") ++ concatMap (hostName: + (../targets + "/${targetName}") ++ concatMap + (hostName: filter builtins.pathExists - (map (profile: ../profiles + "/${profile}/meta.nix") (attrNames - (filterAttrs (_: id) hosts.${hostName}.config.deploy.profile)))) + (map (profile: ../profiles + "/${profile}/meta.nix") (attrNames + (filterAttrs (_: id) hosts.${hostName}.config.deploy.profile)))) target; deps = { @@ -73,7 +75,8 @@ let inherit targetName; }; }); -in { +in +{ inherit tf; target = mapAttrs (targetName: target: tf { inherit target targetName; }) targets; diff --git a/lib/hosts.nix b/lib/hosts.nix index 3dbf9c22..eea3113f 100644 --- a/lib/hosts.nix +++ b/lib/hosts.nix @@ -1,5 +1,11 @@ -{ pkgs, target, users, hostsDir ? ../hosts, profiles, pkgsPath ? ../pkgs -, sources ? { } }: +{ pkgs +, target +, users +, hostsDir ? ../hosts +, profiles +, pkgsPath ? ../pkgs +, sources ? { } +}: with pkgs.lib; @@ -18,18 +24,21 @@ rec { }; }; - hosts = listToAttrs (map (hostName: - nameValuePair hostName (import (pkgs.path + "/nixos/lib/eval-config.nix") { - modules = [ - (hostConfig hostName) - (if sources ? home-manager then - sources.home-manager + "/nixos" - else - { }) - ]; - specialArgs = { inherit sources target profiles hostName users; }; - })) hostNames); + hosts = listToAttrs (map + (hostName: + nameValuePair hostName (import (pkgs.path + "/nixos/lib/eval-config.nix") { + modules = [ + (hostConfig hostName) + (if sources ? home-manager then + sources.home-manager + "/nixos" + else + { }) + ]; + specialArgs = { inherit sources target profiles hostName users; }; + })) + hostNames); targets = foldAttrs (host: hosts: [ host ] ++ hosts) [ ] (mapAttrsToList - (hostName: host: { ${host.config.deploy.target} = hostName; }) hosts); + (hostName: host: { ${host.config.deploy.target} = hostName; }) + hosts); } diff --git a/lib/modules.nix b/lib/modules.nix index 6f37ffb7..be9efda3 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -5,19 +5,23 @@ with builtins; let filterAttrNamesToList = filter: set: foldl' (a: b: a ++ b) [ ] - (map (e: if (filter e set.${e}) then [ e ] else [ ]) (attrNames set)); + (map (e: if (filter e set.${e}) then [ e ] else [ ]) (attrNames set)); nameValuePair = name: value: { inherit name value; }; listToAttrs = foldl' (acc: val: acc // { ${val.name} = val.value; }) { }; directories = filterAttrNamesToList (_: type: type == "directory") (readDir modulesDir); files = map (dir: nameValuePair dir (modulesDir + "/${dir}/${defaultFile}")) directories; - modules = map ({ name, value }: - # if the file contains a function, assume it to be a module and pass the path - # (for dedup and such). if it contains anything else, pass that. - let m = import value; - in { - inherit name; - value = if (isFunction m) && !importAll then value else m; - }) files; -in (listToAttrs modules) + modules = map + ({ name, value }: + # if the file contains a function, assume it to be a module and pass the path + # (for dedup and such). if it contains anything else, pass that. + let m = import value; + in + { + inherit name; + value = if (isFunction m) && !importAll then value else m; + }) + files; +in +(listToAttrs modules) diff --git a/modules/home/deploy-tf/default.nix b/modules/home/deploy-tf/default.nix index 16236887..17ad5278 100644 --- a/modules/home/deploy-tf/default.nix +++ b/modules/home/deploy-tf/default.nix @@ -8,9 +8,10 @@ let name = "unmergedValues"; merge = loc: defs: map (def: def.value) defs; }; -in { +in +{ - options.deploy.tf = mkOption { + options.deploy.tf = mkOption { type = types.submodule { freeformType = types.attrsOf unmergedValues; @@ -22,7 +23,7 @@ in { out.set = mkOption { type = types.unspecified; }; }; }; - + }; config = { deploy.tf = { diff --git a/modules/home/vim.nix b/modules/home/vim.nix index 7fa97f8f..50e74e45 100644 --- a/modules/home/vim.nix +++ b/modules/home/vim.nix @@ -31,36 +31,43 @@ let }; vimSettingsType = types.submodule { - options = let - opt = name: type: - mkOption { - type = types.nullOr type; - default = null; - visible = false; - }; - in mapAttrs opt knownSettings; + options = + let + opt = name: type: + mkOption { + type = types.nullOr type; + default = null; + visible = false; + }; + in + mapAttrs opt knownSettings; }; setExpr = name: value: let - v = if isBool value then - (if value then "" else "no") + name - else - "${name}=${ + v = + if isBool value then + (if value then "" else "no") + name + else + "${name}=${ if isList value then concatStringsSep "," value else toString value }"; - in optionalString (value != null) ("set " + v); + in + optionalString (value != null) ("set " + v); - plugins = let - vpkgs = pkgs.vimPlugins; - getPkg = p: - if isDerivation p then - [ p ] - else - optional (isString p && hasAttr p vpkgs) vpkgs.${p}; - in concatMap getPkg cfg.plugins; + plugins = + let + vpkgs = pkgs.vimPlugins; + getPkg = p: + if isDerivation p then + [ p ] + else + optional (isString p && hasAttr p vpkgs) vpkgs.${p}; + in + concatMap getPkg cfg.plugins; -in { +in +{ options = { programs.vim = { enable = mkEnableOption "Vim"; @@ -136,45 +143,52 @@ in { }; }; - config = (let - customRC = '' - ${concatStringsSep "\n" (filter (v: v != "") (mapAttrsToList setExpr - (builtins.intersectAttrs knownSettings cfg.settings)))} + config = ( + let + customRC = '' + ${concatStringsSep "\n" (filter (v: v != "") (mapAttrsToList setExpr + (builtins.intersectAttrs knownSettings cfg.settings)))} - ${cfg.extraConfig} - ''; + ${cfg.extraConfig} + ''; - vim = cfg.package.customize { - name = "vim"; - vimrcConfig = { - inherit customRC; + vim = cfg.package.customize { + name = "vim"; + vimrcConfig = { + inherit customRC; - packages.home-manager.start = plugins; + packages.home-manager.start = plugins; + }; }; - }; - in mkIf cfg.enable { - assertions = let - packagesNotFound = - filter (p: isString p && (!hasAttr p pkgs.vimPlugins)) cfg.plugins; - in [{ - assertion = packagesNotFound == [ ]; - message = "Following VIM plugin not found in pkgs.vimPlugins: ${ + in + mkIf cfg.enable { + assertions = + let + packagesNotFound = + filter (p: isString p && (!hasAttr p pkgs.vimPlugins)) cfg.plugins; + in + [{ + assertion = packagesNotFound == [ ]; + message = "Following VIM plugin not found in pkgs.vimPlugins: ${ concatMapStringsSep ", " (p: ''"${p}"'') packagesNotFound }"; - }]; + }]; - warnings = let stringPlugins = filter isString cfg.plugins; - in optional (stringPlugins != [ ]) '' - Specifying VIM plugins using strings is deprecated, found ${ - concatMapStringsSep ", " (p: ''"${p}"'') stringPlugins - } as strings. - ''; + warnings = + let stringPlugins = filter isString cfg.plugins; + in + optional (stringPlugins != [ ]) '' + Specifying VIM plugins using strings is deprecated, found ${ + concatMapStringsSep ", " (p: ''"${p}"'') stringPlugins + } as strings. + ''; - home.packages = [ cfg.finalPackage ]; + home.packages = [ cfg.finalPackage ]; - programs.vim = { - finalPackage = vim; - plugins = defaultPlugins; - }; - }); + programs.vim = { + finalPackage = vim; + plugins = defaultPlugins; + }; + } + ); } diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 325a5bce..a41668b1 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -1,7 +1,8 @@ { sources, lib, ... }: let hexchen = (import sources.nix-hexchen) { }; -in { +in +{ imports = [ ./katnet ./deploy-tf diff --git a/modules/nixos/deploy-tf/default.nix b/modules/nixos/deploy-tf/default.nix index e7ab0876..56bff7a0 100644 --- a/modules/nixos/deploy-tf/default.nix +++ b/modules/nixos/deploy-tf/default.nix @@ -6,7 +6,8 @@ let name = "unmergedValues"; merge = loc: defs: map (def: def.value) defs; }; -in { +in +{ options.deploy.target = mkOption { type = with types; str; default = ""; @@ -27,39 +28,41 @@ in { }; config = { - deploy.tf = mkMerge (singleton { - attrs = [ "out" "attrs" ]; - out.set = removeAttrs cfg cfg.attrs; - deploy.systems.${config.networking.hostName} = - with tf.resources; { - isRemote = - (config.networking.hostName != builtins.getEnv "HOME_HOSTNAME"); - nixosConfig = config; - connection = tf.resources.${config.networking.hostName}.connection.set; - triggers.copy.${config.networking.hostName} = - tf.resources.${config.networking.hostName}.refAttr "id"; - triggers.secrets.${config.networking.hostName} = - tf.resources.${config.networking.hostName}.refAttr "id"; - }; + deploy.tf = mkMerge (singleton + { + attrs = [ "out" "attrs" ]; + out.set = removeAttrs cfg cfg.attrs; + deploy.systems.${config.networking.hostName} = + with tf.resources; { + isRemote = + (config.networking.hostName != builtins.getEnv "HOME_HOSTNAME"); + nixosConfig = config; + connection = tf.resources.${config.networking.hostName}.connection.set; + triggers.copy.${config.networking.hostName} = + tf.resources.${config.networking.hostName}.refAttr "id"; + triggers.secrets.${config.networking.hostName} = + tf.resources.${config.networking.hostName}.refAttr "id"; + }; - dns.records."kittywitch_net_${config.networking.hostName}" = - mkIf (config.hexchen.network.enable) { - tld = "kittywit.ch."; - domain = "${config.networking.hostName}.net"; - aaaa.address = config.hexchen.network.address; - }; + dns.records."kittywitch_net_${config.networking.hostName}" = + mkIf (config.hexchen.network.enable) { + tld = "kittywit.ch."; + domain = "${config.networking.hostName}.net"; + aaaa.address = config.hexchen.network.address; + }; - } ++ mapAttrsToList (_: user: - mapAttrs (_: mkMerge) user.deploy.tf.out.set) - config.home-manager.users); + } ++ mapAttrsToList + (_: user: + mapAttrs (_: mkMerge) user.deploy.tf.out.set) + config.home-manager.users); - security.acme.certs."${config.networking.hostName}.net.kittywit.ch" = - mkIf (config.services.nginx.enable && config.hexchen.network.enable) { - domain = "${config.networking.hostName}.net.kittywit.ch"; - dnsProvider = "rfc2136"; - credentialsFile = config.secrets.files.dns_creds.path; - group = "nginx"; - }; + security.acme.certs."${config.networking.hostName}.net.kittywit.ch" = + mkIf (config.services.nginx.enable && config.hexchen.network.enable) { + domain = "${config.networking.hostName}.net.kittywit.ch"; + dnsProvider = "rfc2136"; + credentialsFile = config.secrets.files.dns_creds.path; + group = "nginx"; + }; _module.args.tf = target.${config.deploy.target}; }; diff --git a/modules/nixos/katnet/default.nix b/modules/nixos/katnet/default.nix index 188c16f2..cc4af4ef 100644 --- a/modules/nixos/katnet/default.nix +++ b/modules/nixos/katnet/default.nix @@ -3,7 +3,8 @@ with lib; let cfg = config.katnet; -in { +in +{ options.katnet = { public.tcp.ports = mkOption { type = types.listOf types.port; @@ -52,23 +53,28 @@ in { }; config = { - networking.firewall.interfaces = let - fwTypes = { - ports = "Ports"; - ranges = "PortRanges"; - }; + networking.firewall.interfaces = + let + fwTypes = { + ports = "Ports"; + ranges = "PortRanges"; + }; - interfaceDef = visibility: - listToAttrs (flatten (mapAttrsToList (type: typeString: - map (proto: { - name = "allowed${toUpper proto}${typeString}"; - value = cfg.${visibility}.${proto}.${type}; - }) [ "tcp" "udp" ]) fwTypes)); + interfaceDef = visibility: + listToAttrs (flatten (mapAttrsToList + (type: typeString: + map + (proto: { + name = "allowed${toUpper proto}${typeString}"; + value = cfg.${visibility}.${proto}.${type}; + }) [ "tcp" "udp" ]) + fwTypes)); - interfaces = visibility: - listToAttrs - (map (interface: nameValuePair interface (interfaceDef visibility)) - cfg.${visibility}.interfaces); - in mkMerge (map (visibility: interfaces visibility) [ "public" "private" ]); + interfaces = visibility: + listToAttrs + (map (interface: nameValuePair interface (interfaceDef visibility)) + cfg.${visibility}.interfaces); + in + mkMerge (map (visibility: interfaces visibility) [ "public" "private" ]); }; } diff --git a/nix/sources.nix b/nix/sources.nix index b54826a7..ff4b630f 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -8,11 +8,13 @@ let fetch_file = pkgs: name: spec: let name' = sanitizeName name + "-src"; - in if spec.builtin or true then - builtins_fetchurl { - inherit (spec) url sha256; - name = name'; - } + in + if spec.builtin or true then + builtins_fetchurl + { + inherit (spec) url sha256; + name = name'; + } else pkgs.fetchurl { inherit (spec) url sha256; @@ -21,11 +23,13 @@ let fetch_tarball = pkgs: name: spec: let name' = sanitizeName name + "-src"; - in if spec.builtin or true then - builtins_fetchTarball { - name = name'; - inherit (spec) url sha256; - } + in + if spec.builtin or true then + builtins_fetchTarball + { + name = name'; + inherit (spec) url sha256; + } else pkgs.fetchzip { name = name'; @@ -34,16 +38,18 @@ let fetch_git = name: spec: let - ref = if spec ? ref then - spec.ref - else if spec ? branch then - "refs/heads/${spec.branch}" - else if spec ? tag then - "refs/tags/${spec.tag}" - else - abort - "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; - in builtins.fetchGit { + ref = + if spec ? ref then + spec.ref + else if spec ? branch then + "refs/heads/${spec.branch}" + else if spec ? tag then + "refs/tags/${spec.tag}" + else + abort + "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; + in + builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; @@ -75,12 +81,14 @@ let mkPkgs = sources: system: let sourcesNixpkgs = import - (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { + (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) + { inherit system; }; hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; hasThisAsNixpkgsPath = == ./.; - in if builtins.hasAttr "nixpkgs" sources then + in + if builtins.hasAttr "nixpkgs" sources then sourcesNixpkgs else if hasNixpkgsPath && !hasThisAsNixpkgsPath then import { } @@ -109,34 +117,38 @@ let fetch_builtin-url name else abort - "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; + "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; # If the environment variable NIV_OVERRIDE_${name} is set, then use # the path directly as opposed to the fetched source. replace = name: drv: let saneName = stringAsChars - (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; + (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) + name; ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; - in if ersatz == "" then + in + if ersatz == "" then drv else # this turns the string into an actual Nix path (for both absolute and # relative paths) - if builtins.substring 0 1 ersatz == "/" then - /. + ersatz - else - /. + builtins.getEnv "PWD" + "/${ersatz}"; + if builtins.substring 0 1 ersatz == "/" then + /. + ersatz + else + /. + builtins.getEnv "PWD" + "/${ersatz}"; # Ports of functions for older nix versions # a Nix version of mapAttrs if the built-in doesn't exist mapAttrs = builtins.mapAttrs or (f: set: with builtins; - listToAttrs (map (attr: { - name = attr; - value = f attr set.${attr}; - }) (attrNames set))); + listToAttrs (map + (attr: { + name = attr; + value = f attr set.${attr}; + }) + (attrNames set))); # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 range = first: last: @@ -160,39 +172,44 @@ let # fetchTarball version that is compatible between all the versions of Nix builtins_fetchTarball = { url, name ? null, sha256 }@attrs: let inherit (builtins) lessThan nixVersion fetchTarball; - in if lessThan nixVersion "1.12" then + in + if lessThan nixVersion "1.12" then fetchTarball - ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) + ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) else fetchTarball attrs; # fetchurl version that is compatible between all the versions of Nix builtins_fetchurl = { url, name ? null, sha256 }@attrs: let inherit (builtins) lessThan nixVersion fetchurl; - in if lessThan nixVersion "1.12" then + in + if lessThan nixVersion "1.12" then fetchurl - ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) + ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) else fetchurl attrs; # Create the final "sources" from the config mkSources = config: - mapAttrs (name: spec: - if builtins.hasAttr "outPath" spec then - abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = replace name (fetch config.pkgs name spec); }) - config.sources; + mapAttrs + (name: spec: + if builtins.hasAttr "outPath" spec then + abort + "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = replace name (fetch config.pkgs name spec); }) + config.sources; # The "config" used by the fetchers - mkConfig = { sourcesFile ? - if builtins.pathExists ./sources.json then ./sources.json else null + mkConfig = + { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null , sources ? if isNull sourcesFile then - { } - else - builtins.fromJSON (builtins.readFile sourcesFile) - , system ? builtins.currentSystem, pkgs ? mkPkgs sources system }: rec { + { } + else + builtins.fromJSON (builtins.readFile sourcesFile) + , system ? builtins.currentSystem + , pkgs ? mkPkgs sources system + }: rec { # The sources, i.e. the attribute set of spec name to spec inherit sources; @@ -200,6 +217,7 @@ let inherit pkgs; }; -in mkSources (mkConfig { }) // { +in +mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/nixos.nix b/nixos.nix index f79013f4..9b12f3f8 100644 --- a/nixos.nix +++ b/nixos.nix @@ -36,11 +36,11 @@ users = { kat = { - imports = lib.optional (builtins.pathExists (./hosts + "/${hostName}/home")) (import (./hosts + "/${hostName}/home")) - # trusted hosts check - ++ lib.optional (builtins.pathExists (./trusted/hosts + "/${hostName}/home")) (import (./trusted/hosts + "/${hostName}/home")) - # trusted users check - ++ lib.optional (builtins.pathExists ./trusted/users) (import ./trusted/users); + imports = lib.optional (builtins.pathExists (./hosts + "/${hostName}/home")) (import (./hosts + "/${hostName}/home")) + # trusted hosts check + ++ lib.optional (builtins.pathExists (./trusted/hosts + "/${hostName}/home")) (import (./trusted/hosts + "/${hostName}/home")) + # trusted users check + ++ lib.optional (builtins.pathExists ./trusted/users) (import ./trusted/users); options = { deploy.profile.gui = lib.mkEnableOption "graphical system"; diff --git a/pkgs/default.nix b/pkgs/default.nix index 382abbfb..fece3fca 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -49,7 +49,7 @@ let ''; }; - obs-studio = super.obs-studio.override { pipewireSupport = true; }; + obs-studio = super.obs-studio.override { pipewireSupport = true; }; hextorgba = (import ../lib/colorhelpers.nix { inherit (super) lib; }).hextorgba; @@ -71,6 +71,7 @@ let kat-scrot = self.callPackage ./kat-scrot { }; } // super.lib.optionalAttrs (builtins.pathExists ../trusted/pkgs) - (import ../trusted/pkgs { inherit super self; }); + (import ../trusted/pkgs { inherit super self; }); -in (pkgs.extend (import (sources.arc-nixexprs + "/overlay.nix"))).extend overlay +in +(pkgs.extend (import (sources.arc-nixexprs + "/overlay.nix"))).extend overlay diff --git a/pkgs/notmuch/default.nix b/pkgs/notmuch/default.nix index 931a7b64..cf132640 100644 --- a/pkgs/notmuch/default.nix +++ b/pkgs/notmuch/default.nix @@ -2,7 +2,8 @@ let notmuch = args.notmuch.super or args.notmuch; drv = notmuch.override { withEmacs = false; }; -in drv.overrideAttrs (old: { +in +drv.overrideAttrs (old: { doCheck = false; postInstall = '' diff --git a/profiles/common/access.nix b/profiles/common/access.nix index da202920..4a41b0b0 100644 --- a/profiles/common/access.nix +++ b/profiles/common/access.nix @@ -5,10 +5,12 @@ users.users.root = { openssh.authorizedKeys.keys = with pkgs.lib; - concatLists (mapAttrsToList (name: user: - if elem "wheel" user.extraGroups then - user.openssh.authorizedKeys.keys - else - [ ]) config.users.users); + concatLists (mapAttrsToList + (name: user: + if elem "wheel" user.extraGroups then + user.openssh.authorizedKeys.keys + else + [ ]) + config.users.users); }; } diff --git a/profiles/gui/mingetty.nix b/profiles/gui/mingetty.nix index 6d39c95d..89a81275 100644 --- a/profiles/gui/mingetty.nix +++ b/profiles/gui/mingetty.nix @@ -24,12 +24,13 @@ let " ${c1} .::::' ::::. ${c2}'::::. " " ${c1} .:::: :::: ${c2}'::::. " ]; -in { +in +{ services.getty = { greetingLine = '' \e[H\e[2J \e[9;10]'' + lib.concatStringsSep "\n" nixos_logo + "\n\n" - + "\\e[1;32m>>> NixOS ${config.system.nixos.label} (Linux \\r) - \\l\\e[0m"; + + "\\e[1;32m>>> NixOS ${config.system.nixos.label} (Linux \\r) - \\l\\e[0m"; helpLine = lib.mkForce ""; }; } diff --git a/services/calendar.nix b/services/calendar.nix index 2b7f203d..f19315a7 100644 --- a/services/calendar.nix +++ b/services/calendar.nix @@ -8,7 +8,8 @@ let (flip mapAttrsToList mailAccounts (mail: user: mail + ":" + user.hashedPassword + "\n"))); -in { +in +{ services.radicale = { enable = true; config = '' diff --git a/services/matrix.nix b/services/matrix.nix index d90cf11a..45ebb7f1 100644 --- a/services/matrix.nix +++ b/services/matrix.nix @@ -109,20 +109,23 @@ "/_matrix" = { proxyPass = "http://[::1]:8008"; }; "= /.well-known/matrix/server".extraConfig = let server = { "m.server" = "kittywit.ch:443"; }; - in '' + in + '' add_header Content-Type application/json; return 200 '${builtins.toJSON server}'; ''; - "= /.well-known/matrix/client".extraConfig = let - client = { - "m.homeserver" = { "base_url" = "https://kittywit.ch"; }; - "m.identity_server" = { "base_url" = "https://vector.im"; }; - }; - in '' - add_header Content-Type application/json; - add_header Access-Control-Allow-Origin *; - return 200 '${builtins.toJSON client}'; - ''; + "= /.well-known/matrix/client".extraConfig = + let + client = { + "m.homeserver" = { "base_url" = "https://kittywit.ch"; }; + "m.identity_server" = { "base_url" = "https://vector.im"; }; + }; + in + '' + add_header Content-Type application/json; + add_header Access-Control-Allow-Origin *; + return 200 '${builtins.toJSON client}'; + ''; }; }; } diff --git a/services/prometheus.nix b/services/prometheus.nix index d2980178..3c1beb0f 100644 --- a/services/prometheus.nix +++ b/services/prometheus.nix @@ -10,7 +10,8 @@ let hosts)); nd_configs = (mapAttrs (hostName: host: host.config.services.netdata) (filterAttrs (_: host: host.config.services.netdata.enable) hosts)); -in { +in +{ services.prometheus = { enable = true; scrapeConfigs = [ @@ -23,18 +24,22 @@ in { metrics_path = "/metrics"; static_configs = [{ targets = [ "samhain.net.kittywit.ch:10445" ]; }]; } - ] ++ mapAttrsToList (hostName: prom: { - job_name = "${hostName}-nd"; - metrics_path = "/api/v1/allmetrics"; - honor_labels = true; - params = { format = [ "prometheus" ]; }; - static_configs = [{ targets = [ "${hostName}.net.kittywit.ch:19999" ]; }]; - }) nd_configs ++ mapAttrsToList (hostName: prom: { - job_name = hostName; - static_configs = [{ - targets = [ "${hostName}.net.kittywit.ch:${toString prom.port}" ]; - }]; - }) prom_configs; + ] ++ mapAttrsToList + (hostName: prom: { + job_name = "${hostName}-nd"; + metrics_path = "/api/v1/allmetrics"; + honor_labels = true; + params = { format = [ "prometheus" ]; }; + static_configs = [{ targets = [ "${hostName}.net.kittywit.ch:19999" ]; }]; + }) + nd_configs ++ mapAttrsToList + (hostName: prom: { + job_name = hostName; + static_configs = [{ + targets = [ "${hostName}.net.kittywit.ch:${toString prom.port}" ]; + }]; + }) + prom_configs; }; } diff --git a/services/promtail.nix b/services/promtail.nix index 030a8c43..7fbd5cc0 100644 --- a/services/promtail.nix +++ b/services/promtail.nix @@ -26,7 +26,8 @@ let http_listen_port = 28183; }; }); -in { +in +{ systemd.services.promtail = { description = "Promtail service for Loki"; wantedBy = [ "multi-user.target" ]; diff --git a/services/xmpp.nix b/services/xmpp.nix index c285f46c..b39ff032 100644 --- a/services/xmpp.nix +++ b/services/xmpp.nix @@ -19,10 +19,12 @@ with lib; ssl.cert = "/var/lib/acme/prosody/fullchain.pem"; ssl.key = "/var/lib/acme/prosody/key.pem"; admins = [ "kat@kittywit.ch" ]; - package = let - package = pkgs.prosody.override (old: { - withExtraLibs = old.withExtraLibs ++ singleton pkgs.luaPackages.luadbi-postgresql; - }); in package; + package = + let + package = pkgs.prosody.override (old: { + withExtraLibs = old.withExtraLibs ++ singleton pkgs.luaPackages.luadbi-postgresql; + }); in + package; extraConfig = '' legacy_ssl_ports = { 5223 } storage = "sql" diff --git a/users/kat/base/packages.nix b/users/kat/base/packages.nix index 9077cada..01e09af0 100644 --- a/users/kat/base/packages.nix +++ b/users/kat/base/packages.nix @@ -14,7 +14,7 @@ rsync wget ripgrep - nixfmt + nixpkgs-fmt pv progress zstd diff --git a/users/kat/base/ssh.nix b/users/kat/base/ssh.nix index 827b8fdb..8627dff5 100644 --- a/users/kat/base/ssh.nix +++ b/users/kat/base/ssh.nix @@ -6,20 +6,22 @@ controlMaster = "auto"; controlPersist = "10m"; hashKnownHosts = true; - matchBlocks = let - common = { - forwardAgent = true; - extraOptions = { - RemoteForward = - "/run/user/1000/gnupg/S.gpg-agent /run/user/1000/gnupg/S.gpg-agent.extra"; + matchBlocks = + let + common = { + forwardAgent = true; + extraOptions = { + RemoteForward = + "/run/user/1000/gnupg/S.gpg-agent /run/user/1000/gnupg/S.gpg-agent.extra"; + }; + port = 62954; }; - port = 62954; + in + { + "athame" = { hostname = "athame.kittywit.ch"; } // common; + "samhain" = { hostname = "192.168.1.135"; } // common; + "yule" = { hostname = "192.168.1.92"; } // common; + "ostara" = { hostname = "192.168.1.245"; } // common; }; - in { - "athame" = { hostname = "athame.kittywit.ch"; } // common; - "samhain" = { hostname = "192.168.1.135"; } // common; - "yule" = { hostname = "192.168.1.92"; } // common; - "ostara" = { hostname = "192.168.1.245"; } // common; - }; }; } diff --git a/users/kat/base/tmux.nix b/users/kat/base/tmux.nix index 59e1a4e2..2c2ab5e0 100644 --- a/users/kat/base/tmux.nix +++ b/users/kat/base/tmux.nix @@ -2,54 +2,52 @@ { programs.zsh.shellAliases = { - tne = "tmux new -s"; - tat = "tmux attach -t"; - tren = "tmux new -AD -s"; + tt = "tmux new -AD -s"; }; programs.tmux = { enable = true; extraConfig = '' - # start from 1 - set -g base-index 1 - setw -g pane-base-index 1 + # start from 1 + set -g base-index 1 + setw -g pane-base-index 1 - # proper title handling - set -g set-titles on - set -g set-titles-string "#T" + # proper title handling + set -g set-titles on + set -g set-titles-string "#T" - # 256 color - set -g default-terminal "screen-256color" + # 256 color + set -g default-terminal "screen-256color" - # modes - setw -g clock-mode-colour colour5 - setw -g mode-style 'fg=colour1 bg=colour18 bold' + # modes + setw -g clock-mode-colour colour5 + setw -g mode-style 'fg=colour1 bg=colour18 bold' - # panes - set -g pane-border-style 'fg=colour19 bg=colour0' - set -g pane-active-border-style 'bg=colour0 fg=colour9' + # panes + set -g pane-border-style 'fg=colour19 bg=colour0' + set -g pane-active-border-style 'bg=colour0 fg=colour9' - # statusbar - set -g status-position bottom - set -g status-justify left - set -g status-style 'bg=colour18 fg=colour137 dim' - set -g status-left ''' - set -g status-right '#[fg=colour233,bg=colour19] %F #[fg=colour233,bg=colour8] %H:%M:%S %Z' - set -g status-right-length 50 - set -g status-left-length 20 + # statusbar + set -g status-position bottom + set -g status-justify left + set -g status-style 'bg=colour18 fg=colour137 dim' + set -g status-left ''' + set -g status-right '#[fg=colour233,bg=colour19] %F #[fg=colour233,bg=colour8] %H:%M:%S %Z' + set -g status-right-length 50 + set -g status-left-length 20 - setw -g window-status-current-style 'fg=colour1 bg=colour19 bold' - setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F ' + setw -g window-status-current-style 'fg=colour1 bg=colour19 bold' + setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F ' - setw -g window-status-style 'fg=colour9 bg=colour18' - setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F ' + setw -g window-status-style 'fg=colour9 bg=colour18' + setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F ' - setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold' + setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold' - # messages - set -g message-style 'fg=colour232 bg=colour16 bold' + # messages + set -g message-style 'fg=colour232 bg=colour16 bold' - # mouse - set -g mouse on - ''; + # mouse + set -g mouse on + ''; }; } diff --git a/users/kat/base/zsh.nix b/users/kat/base/zsh.nix index 93ee8fd3..18bf7f90 100644 --- a/users/kat/base/zsh.nix +++ b/users/kat/base/zsh.nix @@ -7,7 +7,7 @@ enable = true; enableAutosuggestions = true; shellAliases = { - nixdirfmt = "fd --color=never .nix | xargs nixfmt"; + nixdirfmt = "fd --color=never .nix | xargs nixpkgs-fmt"; exa = "exa --time-style long-iso"; ls = "exa -G"; la = "exa -Ga"; diff --git a/users/kat/gui/firefox/default.nix b/users/kat/gui/firefox/default.nix index 0ab3b00c..b8524934 100644 --- a/users/kat/gui/firefox/default.nix +++ b/users/kat/gui/firefox/default.nix @@ -9,7 +9,8 @@ let "browser.urlbar.placeholderName" = "DuckDuckGo"; "toolkit.legacyUserProfileCustomizations.stylesheets" = true; }; -in { +in +{ programs.zsh.shellAliases = { ff-pm = "firefox --ProfileManager"; ff-main = "firefox -P main"; @@ -48,23 +49,17 @@ in { main = { id = 0; isDefault = true; - settings = commonSettings // { - - }; + settings = commonSettings // { }; userChrome = import ./userChrome.css.nix { profile = "main"; }; }; work = { id = 1; - settings = commonSettings // { - - }; + settings = commonSettings // { }; userChrome = import ./userChrome.css.nix { profile = "work"; }; }; lewd = { id = 2; - settings = commonSettings // { - - }; + settings = commonSettings // { }; userChrome = import ./userChrome.css.nix { profile = "lewd"; }; }; }; diff --git a/users/kat/gui/kitty.nix b/users/kat/gui/kitty.nix index 9a0025b2..5c7a8344 100644 --- a/users/kat/gui/kitty.nix +++ b/users/kat/gui/kitty.nix @@ -8,7 +8,8 @@ let size = "10"; size_css = "14px"; }; -in { +in +{ programs.kitty = { enable = true; font.name = witch.style.font.name; diff --git a/users/kat/media/mpd.nix b/users/kat/media/mpd.nix index 62c05e6f..c257f7a9 100644 --- a/users/kat/media/mpd.nix +++ b/users/kat/media/mpd.nix @@ -36,6 +36,6 @@ always_on "yes" tags "yes" } - ''; + ''; }; } diff --git a/users/kat/media/mpv.nix b/users/kat/media/mpv.nix index 37c1ae2e..cc4457e4 100644 --- a/users/kat/media/mpv.nix +++ b/users/kat/media/mpv.nix @@ -4,27 +4,29 @@ programs.mpv = { enable = true; scripts = [ pkgs.mpvScripts.sponsorblock ]; - bindings = let - unbind = "keyup"; in { + bindings = + let + unbind = "keyup"; in + { "WHEEL_UP" = "add volume 2"; "WHEEL_DOWN" = "add volume -2"; "ctrl+r" = "loadfile \${path}"; }; - config = { - profile = "gpu-hq"; - gpu-context = "wayland"; - vo = "gpu"; - volume-max = 200; - keep-open = true; - opengl-waitvsync = true; - hwdec = "auto"; - demuxer-max-bytes = "2000MiB"; - demuxer-max-back-bytes = "250MiB"; - osd-scale-by-window = false; - osd-bar-h = 2.5; # 3.125 default - osd-border-size = 2; # font border pixels, default 3 - term-osd-bar = true; - script-opts = lib.concatStringsSep "," + config = { + profile = "gpu-hq"; + gpu-context = "wayland"; + vo = "gpu"; + volume-max = 200; + keep-open = true; + opengl-waitvsync = true; + hwdec = "auto"; + demuxer-max-bytes = "2000MiB"; + demuxer-max-back-bytes = "250MiB"; + osd-scale-by-window = false; + osd-bar-h = 2.5; # 3.125 default + osd-border-size = 2; # font border pixels, default 3 + term-osd-bar = true; + script-opts = lib.concatStringsSep "," (lib.mapAttrsToList (k: v: "${k}=${toString v}") { osc-layout = "slimbox"; osc-vidscale = "no"; @@ -37,6 +39,6 @@ osc-seekbarkeyframes = "no"; osc-seekrangestyle = "slider"; }); - }; }; - } + }; +} diff --git a/users/kat/sway/mako.nix b/users/kat/sway/mako.nix index 1b6e97fc..079f53b4 100644 --- a/users/kat/sway/mako.nix +++ b/users/kat/sway/mako.nix @@ -8,7 +8,8 @@ let size = "10"; size_css = "14px"; }; -in { +in +{ systemd.user.services = { mako = { Unit = { diff --git a/users/kat/sway/sway.nix b/users/kat/sway/sway.nix index ec298baf..3f50462e 100644 --- a/users/kat/sway/sway.nix +++ b/users/kat/sway/sway.nix @@ -8,7 +8,8 @@ let size = "10"; size_css = "14px"; }; -in { +in +{ home.sessionVariables = { MOZ_ENABLE_WAYLAND = 1; XDG_CURRENT_DESKTOP = "sway"; @@ -36,25 +37,26 @@ in { fi ''; - wayland.windowManager.sway = let - cfg = config.wayland.windowManager.sway.config; - bindsym = k: v: "bindsym ${k} ${v}"; - bindWorkspace = key: workspace: { - "${cfg.modifier}+${key}" = "workspace number ${workspace}"; - "${cfg.modifier}+shift+${key}" = - "move container to workspace number ${workspace}"; - }; - workspaceBindings = map (v: bindWorkspace v "${v}:${v}") [ - "1" - "2" - "3" - "4" - "5" - "6" - "7" - "8" - "9" - ] ++ [ (bindWorkspace "0" "10:10") ] + wayland.windowManager.sway = + let + cfg = config.wayland.windowManager.sway.config; + bindsym = k: v: "bindsym ${k} ${v}"; + bindWorkspace = key: workspace: { + "${cfg.modifier}+${key}" = "workspace number ${workspace}"; + "${cfg.modifier}+shift+${key}" = + "move container to workspace number ${workspace}"; + }; + workspaceBindings = map (v: bindWorkspace v "${v}:${v}") [ + "1" + "2" + "3" + "4" + "5" + "6" + "7" + "8" + "9" + ] ++ [ (bindWorkspace "0" "10:10") ] ++ lib.imap1 (i: v: bindWorkspace v "${toString (10 + i)}:${v}") [ "F1" "F2" @@ -69,156 +71,159 @@ in { "F11" "F12" ]; - workspaceBindings' = map (lib.mapAttrsToList bindsym) workspaceBindings; - workspaceBindingsStr = - lib.concatStringsSep "\n" (lib.flatten workspaceBindings'); - in { - enable = true; - config = let - dmenu = - "${pkgs.bemenu}/bin/bemenu --fn '${font.name} ${font.size}' --nb '${base16.base00}' --nf '${base16.base07}' --sb '${base16.base01}' --sf '${base16.base07}' -l 5 -m -1 -i"; - in { - bars = [{ command = "${pkgs.waybar}/bin/waybar"; }]; - - input = { - "*" = { - xkb_layout = "gb"; - # xkb_variant = "nodeadkeys"; - # xkb_options = "ctrl:nocaps"; - }; - }; - - fonts = [ "${font.name} ${font.size}" ]; - terminal = "${pkgs.kitty}/bin/kitty"; - # TODO: replace with wofi - menu = - "${pkgs.j4-dmenu-desktop}/bin/j4-dmenu-desktop --dmenu=\"${dmenu}\" --term='${cfg.terminal}'"; - modifier = "Mod4"; - - assigns = { "12:F2" = [{ class = "screenstub"; }]; }; - startup = [ + workspaceBindings' = map (lib.mapAttrsToList bindsym) workspaceBindings; + workspaceBindingsStr = + lib.concatStringsSep "\n" (lib.flatten workspaceBindings'); + in + { + enable = true; + config = + let + dmenu = + "${pkgs.bemenu}/bin/bemenu --fn '${font.name} ${font.size}' --nb '${base16.base00}' --nf '${base16.base07}' --sb '${base16.base01}' --sf '${base16.base07}' -l 5 -m -1 -i"; + in { - command = "systemctl --user restart mako"; - always = true; - } - { command = "mkchromecast -t"; } - { - command = "systemctl --user restart konawall.service"; - always = true; - } - ]; + bars = [{ command = "${pkgs.waybar}/bin/waybar"; }]; - window = { - border = 1; - titlebar = true; - }; + input = { + "*" = { + xkb_layout = "gb"; + # xkb_variant = "nodeadkeys"; + # xkb_options = "ctrl:nocaps"; + }; + }; - keybindings = { - "${cfg.modifier}+Return" = "exec ${cfg.terminal}"; + fonts = [ "${font.name} ${font.size}" ]; + terminal = "${pkgs.kitty}/bin/kitty"; + # TODO: replace with wofi + menu = + "${pkgs.j4-dmenu-desktop}/bin/j4-dmenu-desktop --dmenu=\"${dmenu}\" --term='${cfg.terminal}'"; + modifier = "Mod4"; - "${cfg.modifier}+Left" = "focus left"; - "${cfg.modifier}+Down" = "focus down"; - "${cfg.modifier}+Up" = "focus up"; - "${cfg.modifier}+Right" = "focus right"; + assigns = { "12:F2" = [{ class = "screenstub"; }]; }; + startup = [ + { + command = "systemctl --user restart mako"; + always = true; + } + { command = "mkchromecast -t"; } + { + command = "systemctl --user restart konawall.service"; + always = true; + } + ]; - "${cfg.modifier}+Shift+Left" = "move left"; - "${cfg.modifier}+Shift+Down" = "move down"; - "${cfg.modifier}+Shift+Up" = "move up"; - "${cfg.modifier}+Shift+Right" = "move right"; + window = { + border = 1; + titlebar = true; + }; - "${cfg.modifier}+Shift+space" = "floating toggle"; - "${cfg.modifier}+space" = "focus mode_toggle"; + keybindings = { + "${cfg.modifier}+Return" = "exec ${cfg.terminal}"; - "${cfg.modifier}+Tab" = "workspace back_and_forth"; - "${cfg.modifier}+Shift+Tab" = - "exec ${config.services.i3gopher.focus-last}"; - "${cfg.modifier}+Ctrl+Left" = "workspace prev_on_output"; - "${cfg.modifier}+Ctrl+Right" = "workspace next_on_output"; + "${cfg.modifier}+Left" = "focus left"; + "${cfg.modifier}+Down" = "focus down"; + "${cfg.modifier}+Up" = "focus up"; + "${cfg.modifier}+Right" = "focus right"; - "XF86AudioRaiseVolume" = - "exec pactl set-sink-volume $(pacmd list-sinks |awk '/* index:/{print $3}') +5%"; - "XF86AudioLowerVolume" = - "exec pactl set-sink-volume $(pacmd list-sinks |awk '/* index:/{print $3}') -5%"; - "XF86AudioMute" = - "exec pactl set-sink-mute $(pacmd list-sinks |awk '/* index:/{print $3}') toggle"; - "XF86AudioMicMute" = - "exec pactl set-source-mute $(pacmd list-sources |awk '/* index:/{print $3}') toggle"; - "XF86MonBrightnessDown" = "exec ${pkgs.light}/bin/light -U 5"; - "XF86MonBrightnessUp" = "exec ${pkgs.light}/bin/light -A 5"; + "${cfg.modifier}+Shift+Left" = "move left"; + "${cfg.modifier}+Shift+Down" = "move down"; + "${cfg.modifier}+Shift+Up" = "move up"; + "${cfg.modifier}+Shift+Right" = "move right"; - "${cfg.modifier}+d" = "exec ${cfg.menu}"; + "${cfg.modifier}+Shift+space" = "floating toggle"; + "${cfg.modifier}+space" = "focus mode_toggle"; - "${cfg.modifier}+Print" = - "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify upload screen"; - "${cfg.modifier}+Shift+Print" = - "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify upload area"; - "${cfg.modifier}+Mod1+Print" = - "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify upload window"; - "${cfg.modifier}+Control+Print" = - "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify upload output"; + "${cfg.modifier}+Tab" = "workspace back_and_forth"; + "${cfg.modifier}+Shift+Tab" = + "exec ${config.services.i3gopher.focus-last}"; + "${cfg.modifier}+Ctrl+Left" = "workspace prev_on_output"; + "${cfg.modifier}+Ctrl+Right" = "workspace next_on_output"; - "Print" = "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify copys screen"; - "Shift+Print" = - "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify copys area"; - "Mod1+Print" = - "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify copys window"; - "Control+Print" = - "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify copys output"; + "XF86AudioRaiseVolume" = + "exec pactl set-sink-volume $(pacmd list-sinks |awk '/* index:/{print $3}') +5%"; + "XF86AudioLowerVolume" = + "exec pactl set-sink-volume $(pacmd list-sinks |awk '/* index:/{print $3}') -5%"; + "XF86AudioMute" = + "exec pactl set-sink-mute $(pacmd list-sinks |awk '/* index:/{print $3}') toggle"; + "XF86AudioMicMute" = + "exec pactl set-source-mute $(pacmd list-sources |awk '/* index:/{print $3}') toggle"; + "XF86MonBrightnessDown" = "exec ${pkgs.light}/bin/light -U 5"; + "XF86MonBrightnessUp" = "exec ${pkgs.light}/bin/light -A 5"; - "${cfg.modifier}+i" = "move workspace to output left"; - "${cfg.modifier}+o" = "move workspace to output right"; - "${cfg.modifier}+b" = "splith"; - "${cfg.modifier}+v" = "splitv"; - "${cfg.modifier}+s" = "layout stacking"; - "${cfg.modifier}+w" = "layout tabbed"; - "${cfg.modifier}+e" = "layout toggle split"; - "${cfg.modifier}+f" = "fullscreen"; + "${cfg.modifier}+d" = "exec ${cfg.menu}"; - "${cfg.modifier}+Shift+q" = "kill"; - "${cfg.modifier}+Shift+c" = "reload"; + "${cfg.modifier}+Print" = + "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify upload screen"; + "${cfg.modifier}+Shift+Print" = + "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify upload area"; + "${cfg.modifier}+Mod1+Print" = + "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify upload window"; + "${cfg.modifier}+Control+Print" = + "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify upload output"; - "${cfg.modifier}+r" = "mode resize"; - "${cfg.modifier}+Delete" = '' - mode "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown"''; - }; + "Print" = "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify copys screen"; + "Shift+Print" = + "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify copys area"; + "Mod1+Print" = + "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify copys window"; + "Control+Print" = + "exec ${pkgs.kat-scrot}/bin/kat-scrot --notify copys output"; - colors = { - focused = { - border = base16.base08; - background = base16.base0A; - text = base16.base00; - indicator = base16.base0B; - childBorder = base16.base08; + "${cfg.modifier}+i" = "move workspace to output left"; + "${cfg.modifier}+o" = "move workspace to output right"; + "${cfg.modifier}+b" = "splith"; + "${cfg.modifier}+v" = "splitv"; + "${cfg.modifier}+s" = "layout stacking"; + "${cfg.modifier}+w" = "layout tabbed"; + "${cfg.modifier}+e" = "layout toggle split"; + "${cfg.modifier}+f" = "fullscreen"; + + "${cfg.modifier}+Shift+q" = "kill"; + "${cfg.modifier}+Shift+c" = "reload"; + + "${cfg.modifier}+r" = "mode resize"; + "${cfg.modifier}+Delete" = '' + mode "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown"''; + }; + + colors = { + focused = { + border = base16.base08; + background = base16.base0A; + text = base16.base00; + indicator = base16.base0B; + childBorder = base16.base08; + }; + focusedInactive = { + border = base16.base00; + background = base16.base07; + text = base16.base0A; + indicator = base16.base0B; + childBorder = base16.base03; + }; + unfocused = { + border = base16.base00; + background = base16.base01; + text = base16.base04; + indicator = base16.base08; + childBorder = base16.base08; + }; + urgent = { + border = base16.base00; + background = base16.base09; + text = base16.base00; + indicator = base16.base01; + childBorder = base16.base08; + }; + }; }; - focusedInactive = { - border = base16.base00; - background = base16.base07; - text = base16.base0A; - indicator = base16.base0B; - childBorder = base16.base03; - }; - unfocused = { - border = base16.base00; - background = base16.base01; - text = base16.base04; - indicator = base16.base08; - childBorder = base16.base08; - }; - urgent = { - border = base16.base00; - background = base16.base09; - text = base16.base00; - indicator = base16.base01; - childBorder = base16.base08; - }; - }; + wrapperFeatures.gtk = true; + extraConfig = '' + seat seat0 xcursor_theme breeze_cursors 20 + workspace_auto_back_and_forth yes + ${workspaceBindingsStr} + ''; }; - wrapperFeatures.gtk = true; - extraConfig = '' - seat seat0 xcursor_theme breeze_cursors 20 - workspace_auto_back_and_forth yes - ${workspaceBindingsStr} - ''; - }; } diff --git a/users/kat/sway/waybar/default.nix b/users/kat/sway/waybar/default.nix index f073104a..79ea9643 100644 --- a/users/kat/sway/waybar/default.nix +++ b/users/kat/sway/waybar/default.nix @@ -8,7 +8,8 @@ let size = "10"; size_css = "14px"; }; -in { +in +{ config = lib.mkIf config.deploy.profile.sway { programs.waybar = { enable = true;