diff --git a/modules/containers.nix b/modules/containers.nix index 18261592..669c935c 100644 --- a/modules/containers.nix +++ b/modules/containers.nix @@ -1,4 +1,9 @@ -{ config, nix-config, lib, ... }: +{ + config, + nix-config, + lib, + ... +}: let inherit (lib) mkIf; @@ -46,21 +51,21 @@ let }; in { - systemd.tmpfiles.rules = [ - "d /run/user/1000 0700 ${username} users -" - ]; + systemd.tmpfiles.rules = [ "d /run/user/1000 0700 ${username} users -" ]; containers = mkIf enableContainers { wine = template // { hostAddress = "192.168.100.34"; localAddress = "192.168.100.49"; - config = { ... }: { - imports = [ - ../containers - ../containers/wine.nix - ]; - }; + config = + { ... }: + { + imports = [ + ../containers + ../containers/wine.nix + ]; + }; }; }; } diff --git a/modules/desktop.nix b/modules/desktop.nix index e71004f7..72c99a7c 100644 --- a/modules/desktop.nix +++ b/modules/desktop.nix @@ -1,24 +1,52 @@ -{ nix-config, pkgs, config, lib, ... }: +{ + nix-config, + pkgs, + config, + lib, + ... +}: let - inherit (lib) mkEnableOption mkIf mkMerge mkOption; + inherit (lib.types) float int; inherit (config.modules.system) username; inherit (config.lib.stylix.colors.withHashtag) base00; - inherit (cfg) bloat gnome plasma container opacity fontSize graphical; inherit (nix-config.packages.${pkgs.system}) aleo-fonts; - inherit (pkgs) phinger-cursors noto-fonts-cjk-sans maple-mono noto-fonts-emoji stdenvNoCC imagemagick; inherit (builtins) attrValues; + inherit (lib) + mkEnableOption + mkIf + mkMerge + mkOption + ; + + inherit (cfg) + bloat + gnome + plasma + container + opacity + fontSize + graphical + ; + + inherit (pkgs) + phinger-cursors + noto-fonts-cjk-sans + maple-mono + noto-fonts-emoji + stdenvNoCC + imagemagick + ; + stylix-background = stdenvNoCC.mkDerivation { pname = "stylix-background"; version = base00; dontUnpack = true; - nativeBuildInputs = [ - imagemagick - ]; + nativeBuildInputs = [ imagemagick ]; postInstall = '' mkdir -p $out @@ -62,9 +90,7 @@ in thunar = { enable = true; - plugins = attrValues { - inherit (pkgs.xfce) thunar-volman; - }; + plugins = with pkgs.xfce; [ thunar-volman ]; }; }; @@ -91,7 +117,7 @@ in xserver = mkIf (!container || graphical) { enable = true; - excludePackages = [ pkgs.xterm ]; + excludePackages = with pkgs; [ xterm ]; }; pipewire = { @@ -164,32 +190,43 @@ in }) ]; - nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ - "vagrant" - ]; + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "vagrant" ]; fonts = { enableDefaultPackages = false; - packages = [ - noto-fonts-cjk-sans - noto-fonts-emoji - maple-mono - aleo-fonts - ] ++ (with pkgs; [ - noto-fonts - noto-fonts-cjk-serif - font-awesome - (nerdfonts.override { fonts = [ "Noto" ]; }) - kanji-stroke-order-font - liberation_ttf - ]); + packages = + [ + noto-fonts-cjk-sans + noto-fonts-emoji + maple-mono + aleo-fonts + ] + ++ (with pkgs; [ + noto-fonts + noto-fonts-cjk-serif + font-awesome + (nerdfonts.override { fonts = [ "Noto" ]; }) + kanji-stroke-order-font + liberation_ttf + ]); fontconfig = { defaultFonts = { - serif = [ "Noto Serif CJK JP" "Noto Serif" ]; - sansSerif = [ "Noto Sans CJK JP" "Noto Sans" ]; - monospace = [ "Noto Sans Mono CJK JP" "Noto Sans Mono" ]; + serif = [ + "Noto Serif CJK JP" + "Noto Serif" + ]; + + sansSerif = [ + "Noto Sans CJK JP" + "Noto Sans" + ]; + + monospace = [ + "Noto Sans Mono CJK JP" + "Noto Sans Mono" + ]; }; allowBitmaps = false; @@ -244,13 +281,8 @@ in }; specialisation = { - gnome = mkIf gnome { - configuration.imports = [ ../specializations/gnome.nix ]; - }; - - plasma = mkIf plasma { - configuration.imports = [ ../specializations/plasma.nix ]; - }; + gnome = mkIf gnome { configuration.imports = [ ../specializations/gnome.nix ]; }; + plasma = mkIf plasma { configuration.imports = [ ../specializations/plasma.nix ]; }; }; }; } diff --git a/modules/hardware.nix b/modules/hardware.nix index 775c9b9d..12be9102 100644 --- a/modules/hardware.nix +++ b/modules/hardware.nix @@ -1,12 +1,29 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let - inherit (lib) mkEnableOption mkIf getExe singleton; inherit (pkgs) piper interception-tools; inherit (pkgs.interception-tools-plugins) dual-function-keys; - inherit (cfg) mouseSettings lidIgnore keyboardBinds bluetooth; inherit (builtins) toJSON; + inherit (lib) + mkEnableOption + mkIf + getExe + singleton + ; + + inherit (cfg) + mouseSettings + lidIgnore + keyboardBinds + bluetooth + ; + dualFunctionKeysConfig = "dual-function-keys.yaml"; cfg = config.modules.hardware; @@ -36,15 +53,19 @@ in plugins = [ dual-function-keys ]; udevmonConfig = toJSON (singleton { - JOB = /* bash */ '' - ${interception-tools}/bin/intercept -g $DEVNODE | - ${getExe dual-function-keys} -c /etc/${dualFunctionKeysConfig} | - ${interception-tools}/bin/uinput -d $DEVNODE - ''; + JOB = # bash + '' + ${interception-tools}/bin/intercept -g $DEVNODE | + ${getExe dual-function-keys} -c /etc/${dualFunctionKeysConfig} | + ${interception-tools}/bin/uinput -d $DEVNODE + ''; DEVICE = { EVENTS = { - EV_KEY = [ "KEY_CAPSLOCK" "KEY_ESC" ]; + EV_KEY = [ + "KEY_CAPSLOCK" + "KEY_ESC" + ]; }; }; }); diff --git a/modules/shell.nix b/modules/shell.nix index d29916c6..0ec0dc99 100644 --- a/modules/shell.nix +++ b/modules/shell.nix @@ -54,8 +54,6 @@ in rmlint jpegoptim pass - ; - inherit (pkgs) sudachi-rs tango npm-check-updates @@ -103,10 +101,6 @@ in nix-search-cli nix-tree ; - inherit (pkgs) - nodejs - deno - ; inherit (pkgs) rustc rustfmt @@ -114,8 +108,8 @@ in cargo-tarpaulin bacon clippy - ; - inherit (pkgs) + nodejs + deno tectonic ; }) diff --git a/modules/system.nix b/modules/system.nix index 0a3ef979..22591781 100644 --- a/modules/system.nix +++ b/modules/system.nix @@ -1,17 +1,38 @@ -{ nix-config, pkgs, lib, config, ... }: +{ + nix-config, + pkgs, + lib, + config, + ... +}: let - inherit (lib) mkOption mkEnableOption mkIf singleton; inherit (lib.types) nullOr str listOf; - inherit (cfg) username iHaveLotsOfRam hashedPassword mullvad allowSRB2Port allowDevPort noRoot postgres; - inherit (builtins) attrValues; + + inherit (lib) + mkOption + mkEnableOption + mkIf + singleton + ; + + inherit (cfg) + username + iHaveLotsOfRam + hashedPassword + mullvad + allowSRB2Port + allowDevPort + noRoot + postgres + ; cfg = config.modules.system; in { - imports = attrValues { - inherit (nix-config.inputs.home-manager.nixosModules) home-manager; - }; + imports = with nix-config.inputs.home-manager.nixosModules; [ + home-manager + ]; options.modules.system = { username = mkOption { @@ -36,7 +57,12 @@ in supportedLocales = mkOption { type = listOf str; - default = [ "ja_JP.UTF-8/UTF-8" "en_US.UTF-8/UTF-8" "fr_FR.UTF-8/UTF-8" ]; + + default = [ + "ja_JP.UTF-8/UTF-8" + "en_US.UTF-8/UTF-8" + "fr_FR.UTF-8/UTF-8" + ]; }; stateVersion = mkOption { @@ -59,10 +85,7 @@ in config = { boot = { - tmp = - if iHaveLotsOfRam - then { useTmpfs = true; } - else { cleanOnBoot = true; }; + tmp = if iHaveLotsOfRam then { useTmpfs = true; } else { cleanOnBoot = true; }; binfmt.emulatedSystems = [ "aarch64-linux" ]; @@ -77,9 +100,7 @@ in efi.canTouchEfiVariables = true; }; - blacklistedKernelModules = [ - "floppy" - ]; + blacklistedKernelModules = [ "floppy" ]; }; systemd = { @@ -91,11 +112,15 @@ in package = pkgs.nixVersions.nix_2_22; settings = { - experimental-features = [ "nix-command" "flakes" ]; auto-optimise-store = true; warn-dirty = false; allow-import-from-derivation = false; + experimental-features = [ + "nix-command" + "flakes" + ]; + trusted-users = [ "root" "@wheel" @@ -130,16 +155,18 @@ in isNormalUser = true; uid = 1000; password = mkIf (hashedPassword == null && !noRoot) username; + extraGroups = - if noRoot - then [ ] - else [ - "wheel" - "networkmanager" - "dialout" - "feedbackd" - "video" - ]; + if noRoot then + [ ] + else + [ + "wheel" + "networkmanager" + "dialout" + "feedbackd" + "video" + ]; }; }; @@ -221,13 +248,8 @@ in }; firewall = { - allowedUDPPorts = mkIf allowSRB2Port [ - 5029 - ]; - - allowedTCPPorts = mkIf allowDevPort [ - 3000 - ]; + allowedUDPPorts = mkIf allowSRB2Port [ 5029 ]; + allowedTCPPorts = mkIf allowDevPort [ 3000 ]; }; }; @@ -242,22 +264,14 @@ in postgresql = mkIf postgres { enable = true; - - ensureUsers = singleton { - name = username; - }; - + ensureUsers = singleton { name = username; }; ensureDatabases = [ username ]; }; }; environment = { - systemPackages = with pkgs; [ - (pass.withExtensions (ext: with ext; [ pass-otp ])) - ]; - + systemPackages = with pkgs; [ (pass.withExtensions (ext: with ext; [ pass-otp ])) ]; defaultPackages = [ ]; - gnome.excludePackages = with pkgs; [ gnome-tour ]; };