From 8ece3e28120b546cdc52732771d38278df1737d4 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Sat, 3 Aug 2024 14:42:39 -0400 Subject: [PATCH] treewide: Format remaining files with nixfmt-rfc-style --- flake.nix | 143 ++++++++++++++---------- hosts/laptop/hardware-configuration.nix | 19 +++- hosts/phone/configuration.nix | 81 ++++++++------ lib/test.nix | 5 +- specializations/gnome.nix | 7 +- specializations/plasma.nix | 7 +- tests/neovim.nix | 77 +++++++------ 7 files changed, 199 insertions(+), 140 deletions(-) diff --git a/flake.nix b/flake.nix index c5574b4d..fee3ab35 100644 --- a/flake.nix +++ b/flake.nix @@ -26,14 +26,40 @@ }; }; - outputs = { self, nixpkgs, mobile-nixos, ... } @ attrs: + outputs = + { + self, + nixpkgs, + mobile-nixos, + ... + }@attrs: let inherit (nixpkgs.lib) nixosSystem; inherit (nixpkgs.legacyPackages) x86_64-linux aarch64-linux; - inherit (builtins) attrNames listToAttrs map replaceStrings readDir; - flakeOutputs = [ "overlays" "nixosModules" "homeModules" "packages" "checks" ]; - flakeDirectories = [ "overlays" "modules" "home" "packages" "tests" ]; + inherit (builtins) + attrNames + listToAttrs + map + replaceStrings + readDir + ; + + flakeOutputs = [ + "overlays" + "nixosModules" + "homeModules" + "packages" + "checks" + ]; + + flakeDirectories = [ + "overlays" + "modules" + "home" + "packages" + "tests" + ]; in { nixosConfigurations = @@ -46,7 +72,10 @@ { nixos = nixosSystem { system = "x86_64-linux"; - specialArgs = attrs // { nix-config = self; }; + + specialArgs = attrs // { + nix-config = self; + }; modules = [ ./hosts/laptop/configuration.nix @@ -56,12 +85,13 @@ mobile-nixos = nixosSystem { system = "aarch64-linux"; - specialArgs = attrs // { nix-config = self; }; + + specialArgs = attrs // { + nix-config = self; + }; modules = phoneModules ++ [ - (import "${mobile-nixos}/lib/configuration.nix" { - device = "pine64-pinephone"; - }) + (import "${mobile-nixos}/lib/configuration.nix" { device = "pine64-pinephone"; }) { mobile.beautification = { @@ -74,66 +104,61 @@ mobile-nixos-vm = nixosSystem { system = "x86_64-linux"; - specialArgs = attrs // { nix-config = self; }; + + specialArgs = attrs // { + nix-config = self; + }; + modules = phoneModules; }; }; formatter.x86_64-linux = x86_64-linux.nixpkgs-fmt; formatter.aarch64-linux = aarch64-linux.nixpkgs-fmt; - } // - (listToAttrs - (map - (attributeName: { - name = attributeName; - value = - let - directory = replaceStrings flakeOutputs flakeDirectories attributeName; + } + // (listToAttrs ( + map (attributeName: { + name = attributeName; + value = + let + directory = replaceStrings flakeOutputs flakeDirectories attributeName; - attributeValue = listToAttrs - (map - (file: { - name = replaceStrings [ ".nix" ] [ "" ] file; - value = - if directory == "packages" - then x86_64-linux.callPackage ./${directory}/${file} { } - else - if directory == "tests" - then - import ./${directory}/${file} - { - inherit self; - pkgs = x86_64-linux; - } - else import ./${directory}/${file}; - }) - (attrNames (readDir ./${directory}))); + attributeValue = listToAttrs ( + map (file: { + name = replaceStrings [ ".nix" ] [ "" ] file; + value = + if directory == "packages" then + x86_64-linux.callPackage ./${directory}/${file} { } + else if directory == "tests" then + import ./${directory}/${file} { + inherit self; + pkgs = x86_64-linux; + } + else + import ./${directory}/${file}; + }) (attrNames (readDir ./${directory})) + ); - aarch64Packages = listToAttrs - (map - (file: { - name = replaceStrings [ ".nix" ] [ "" ] file; - value = - if directory == "packages" - then aarch64-linux.callPackage ./${directory}/${file} { } - else null; - }) - (attrNames (readDir ./${directory}))); + aarch64Packages = listToAttrs ( + map (file: { + name = replaceStrings [ ".nix" ] [ "" ] file; + value = + if directory == "packages" then aarch64-linux.callPackage ./${directory}/${file} { } else null; + }) (attrNames (readDir ./${directory})) + ); - attributeSet = - if directory == "packages" - then { + attributeSet = + if directory == "packages" then + { x86_64-linux = attributeValue; aarch64-linux = aarch64Packages; } - else - if directory == "tests" - then { - x86_64-linux = attributeValue; - } - else attributeValue; - in - attributeSet; - }) - flakeOutputs)); + else if directory == "tests" then + { x86_64-linux = attributeValue; } + else + attributeValue; + in + attributeSet; + }) flakeOutputs + )); } diff --git a/hosts/laptop/hardware-configuration.nix b/hosts/laptop/hardware-configuration.nix index 38513f5a..91afa75d 100644 --- a/hosts/laptop/hardware-configuration.nix +++ b/hosts/laptop/hardware-configuration.nix @@ -1,13 +1,22 @@ -{ config, lib, modulesPath, ... }: +{ + config, + lib, + modulesPath, + ... +}: { - imports = [ - (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; boot = { initrd = { - availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "sd_mod" ]; + availableKernelModules = [ + "nvme" + "xhci_pci" + "usb_storage" + "sd_mod" + ]; + kernelModules = [ ]; }; diff --git a/hosts/phone/configuration.nix b/hosts/phone/configuration.nix index 268d4294..c0bacf7e 100644 --- a/hosts/phone/configuration.nix +++ b/hosts/phone/configuration.nix @@ -1,4 +1,10 @@ -{ self, pkgs, config, lib, ... }: +{ + self, + pkgs, + config, + lib, + ... +}: let inherit (lib) mkIf mkForce; @@ -7,17 +13,19 @@ let inherit (builtins) attrValues; getColorCh = colorName: channel: config.lib.stylix.colors."${colorName}-rgb-${channel}"; - rgba = color: transparency: ''rgba(${getColorCh color "r"}, ${getColorCh color "g"}, ${getColorCh color "b"}, ${transparency})''; + + rgba = + color: transparency: + ''rgba(${getColorCh color "r"}, ${getColorCh color "g"}, ${getColorCh color "b"}, ${transparency})''; + bg = ''linear-gradient(${rgba "base00" "0.7"}, ${rgba "base00" "0.7"})''; in { imports = attrValues self.nixosModules; - nixpkgs.overlays = attrValues { - inherit (self.overlays) - phinger-cursors - ; - }; + nixpkgs.overlays = with self.overlays; [ + phinger-cursors + ]; home-manager.sharedModules = attrValues { inherit (self.homeModules) @@ -73,8 +81,15 @@ in "org/gnome/desktop/input-sources" = { sources = [ - (mkTuple [ "xkb" "us" ]) - (mkTuple [ "xkb" "jp+kana" ]) + (mkTuple [ + "xkb" + "us" + ]) + + (mkTuple [ + "xkb" + "jp+kana" + ]) ]; }; @@ -91,40 +106,35 @@ in }; background = { - stylix.targets.gtk.extraCss = /* css */ '' - phosh-lockscreen { - background: ${bg}, url('file:///home/${username}/wall-lock.jpg'); - } + stylix.targets.gtk.extraCss = # css + '' + phosh-lockscreen { + background: ${bg}, url('file:///home/${username}/wall-lock.jpg'); + } - phosh-app-grid { - background: ${bg}, url('file:///home/${username}/wall-grid.jpg'); - } + phosh-app-grid { + background: ${bg}, url('file:///home/${username}/wall-grid.jpg'); + } - phosh-top-panel { - background: ${bg}, url('file:///home/${username}/wall-panel.jpg'); - } + phosh-top-panel { + background: ${bg}, url('file:///home/${username}/wall-panel.jpg'); + } - phosh-home { - background: ${bg}, url('file:///home/${username}/wall-home.jpg'); - } + phosh-home { + background: ${bg}, url('file:///home/${username}/wall-home.jpg'); + } - phosh-lockscreen, phosh-app-grid, phosh-top-panel, phosh-home { - background-size: cover; - background-position: center; - } - ''; + phosh-lockscreen, phosh-app-grid, phosh-top-panel, phosh-home { + background-size: cover; + background-position: center; + } + ''; }; }; environment.systemPackages = attrValues { - inherit (self.packages.${pkgs.system}) - webp-thumbnailer - pinephone-toolkit - ; - - inherit (pkgs.gnome) - gnome-contacts - ; + inherit (self.packages.${pkgs.system}) webp-thumbnailer pinephone-toolkit; + inherit (pkgs.gnome) gnome-contacts; inherit (pkgs) chatty @@ -158,7 +168,6 @@ in thunar.enable = mkForce false; }; - networking = { wireless.enable = false; wireguard.enable = true; diff --git a/lib/test.nix b/lib/test.nix index cee0677e..85961b57 100644 --- a/lib/test.nix +++ b/lib/test.nix @@ -1,4 +1,7 @@ -test: { self, pkgs }: +test: + +{ self, pkgs }: + let inherit (pkgs.lib) mkDefault; diff --git a/specializations/gnome.nix b/specializations/gnome.nix index 2392c70f..5f8bc826 100644 --- a/specializations/gnome.nix +++ b/specializations/gnome.nix @@ -1,4 +1,9 @@ -{ pkgs, lib, config, ... }: +{ + pkgs, + lib, + config, + ... +}: let inherit (config.modules.system) username; diff --git a/specializations/plasma.nix b/specializations/plasma.nix index c69c0770..9c73403e 100644 --- a/specializations/plasma.nix +++ b/specializations/plasma.nix @@ -1,4 +1,9 @@ -{ pkgs, lib, config, ... }: +{ + pkgs, + lib, + config, + ... +}: let inherit (config.modules.system) username; diff --git a/tests/neovim.nix b/tests/neovim.nix index 6099ca89..c68f9a5e 100644 --- a/tests/neovim.nix +++ b/tests/neovim.nix @@ -4,50 +4,53 @@ in (import ../lib/test.nix) { name = "neovim"; - nodes.machine = { nix-config, ... }: { - imports = attrValues { - inherit (nix-config.nixosModules) desktop system shell; + nodes.machine = + { nix-config, ... }: + { + imports = attrValues { + inherit (nix-config.nixosModules) desktop system shell; - customConfig = { - modules.desktop.container = true; + customConfig = { + modules.desktop.container = true; + }; }; + + home-manager.sharedModules = with nix-config.homeModules; [ + neovim + ]; }; - home-manager.sharedModules = attrValues { - inherit (nix-config.homeModules) neovim; - }; - }; + testScript = # python + '' + machine.wait_for_unit("default.target") - testScript = /* python */ '' - machine.wait_for_unit("default.target") + machine.send_chars("user") + machine.sleep(1) + machine.send_key("ret") + machine.sleep(1) + machine.send_chars("user") + machine.sleep(1) + machine.send_key("ret") + machine.sleep(5) - machine.send_chars("user") - machine.sleep(1) - machine.send_key("ret") - machine.sleep(1) - machine.send_chars("user") - machine.sleep(1) - machine.send_key("ret") - machine.sleep(5) + machine.send_chars("nvim hello.txt") + machine.sleep(1) + machine.send_key("ret") + machine.sleep(20) - machine.send_chars("nvim hello.txt") - machine.sleep(1) - machine.send_key("ret") - machine.sleep(20) + machine.send_chars("i") + machine.sleep(2) + machine.send_chars("Hello world") + machine.sleep(2) + machine.send_key("esc") + machine.sleep(2) + machine.send_chars(":wq") + machine.sleep(2) + machine.send_key("ret") + machine.sleep(2) - machine.send_chars("i") - machine.sleep(2) - machine.send_chars("Hello world") - machine.sleep(2) - machine.send_key("esc") - machine.sleep(2) - machine.send_chars(":wq") - machine.sleep(2) - machine.send_key("ret") - machine.sleep(2) + text = machine.succeed("cat /home/user/hello.txt") - text = machine.succeed("cat /home/user/hello.txt") - - assert "Hello world" in text - ''; + assert "Hello world" in text + ''; }