treewide: Format remaining files with nixfmt-rfc-style

This commit is contained in:
Donovan Glover 2024-08-03 14:42:39 -04:00
parent a32f73a388
commit 8ece3e2812
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
7 changed files with 199 additions and 140 deletions

143
flake.nix
View File

@ -26,14 +26,40 @@
}; };
}; };
outputs = { self, nixpkgs, mobile-nixos, ... } @ attrs: outputs =
{
self,
nixpkgs,
mobile-nixos,
...
}@attrs:
let let
inherit (nixpkgs.lib) nixosSystem; inherit (nixpkgs.lib) nixosSystem;
inherit (nixpkgs.legacyPackages) x86_64-linux aarch64-linux; inherit (nixpkgs.legacyPackages) x86_64-linux aarch64-linux;
inherit (builtins) attrNames listToAttrs map replaceStrings readDir;
flakeOutputs = [ "overlays" "nixosModules" "homeModules" "packages" "checks" ]; inherit (builtins)
flakeDirectories = [ "overlays" "modules" "home" "packages" "tests" ]; attrNames
listToAttrs
map
replaceStrings
readDir
;
flakeOutputs = [
"overlays"
"nixosModules"
"homeModules"
"packages"
"checks"
];
flakeDirectories = [
"overlays"
"modules"
"home"
"packages"
"tests"
];
in in
{ {
nixosConfigurations = nixosConfigurations =
@ -46,7 +72,10 @@
{ {
nixos = nixosSystem { nixos = nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = attrs // { nix-config = self; };
specialArgs = attrs // {
nix-config = self;
};
modules = [ modules = [
./hosts/laptop/configuration.nix ./hosts/laptop/configuration.nix
@ -56,12 +85,13 @@
mobile-nixos = nixosSystem { mobile-nixos = nixosSystem {
system = "aarch64-linux"; system = "aarch64-linux";
specialArgs = attrs // { nix-config = self; };
specialArgs = attrs // {
nix-config = self;
};
modules = phoneModules ++ [ modules = phoneModules ++ [
(import "${mobile-nixos}/lib/configuration.nix" { (import "${mobile-nixos}/lib/configuration.nix" { device = "pine64-pinephone"; })
device = "pine64-pinephone";
})
{ {
mobile.beautification = { mobile.beautification = {
@ -74,66 +104,61 @@
mobile-nixos-vm = nixosSystem { mobile-nixos-vm = nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = attrs // { nix-config = self; };
specialArgs = attrs // {
nix-config = self;
};
modules = phoneModules; modules = phoneModules;
}; };
}; };
formatter.x86_64-linux = x86_64-linux.nixpkgs-fmt; formatter.x86_64-linux = x86_64-linux.nixpkgs-fmt;
formatter.aarch64-linux = aarch64-linux.nixpkgs-fmt; formatter.aarch64-linux = aarch64-linux.nixpkgs-fmt;
} // }
(listToAttrs // (listToAttrs (
(map map (attributeName: {
(attributeName: { name = attributeName;
name = attributeName; value =
value = let
let directory = replaceStrings flakeOutputs flakeDirectories attributeName;
directory = replaceStrings flakeOutputs flakeDirectories attributeName;
attributeValue = listToAttrs attributeValue = listToAttrs (
(map map (file: {
(file: { name = replaceStrings [ ".nix" ] [ "" ] file;
name = replaceStrings [ ".nix" ] [ "" ] file; value =
value = if directory == "packages" then
if directory == "packages" x86_64-linux.callPackage ./${directory}/${file} { }
then x86_64-linux.callPackage ./${directory}/${file} { } else if directory == "tests" then
else import ./${directory}/${file} {
if directory == "tests" inherit self;
then pkgs = x86_64-linux;
import ./${directory}/${file} }
{ else
inherit self; import ./${directory}/${file};
pkgs = x86_64-linux; }) (attrNames (readDir ./${directory}))
} );
else import ./${directory}/${file};
})
(attrNames (readDir ./${directory})));
aarch64Packages = listToAttrs aarch64Packages = listToAttrs (
(map map (file: {
(file: { name = replaceStrings [ ".nix" ] [ "" ] file;
name = replaceStrings [ ".nix" ] [ "" ] file; value =
value = if directory == "packages" then aarch64-linux.callPackage ./${directory}/${file} { } else null;
if directory == "packages" }) (attrNames (readDir ./${directory}))
then aarch64-linux.callPackage ./${directory}/${file} { } );
else null;
})
(attrNames (readDir ./${directory})));
attributeSet = attributeSet =
if directory == "packages" if directory == "packages" then
then { {
x86_64-linux = attributeValue; x86_64-linux = attributeValue;
aarch64-linux = aarch64Packages; aarch64-linux = aarch64Packages;
} }
else else if directory == "tests" then
if directory == "tests" { x86_64-linux = attributeValue; }
then { else
x86_64-linux = attributeValue; attributeValue;
} in
else attributeValue; attributeSet;
in }) flakeOutputs
attributeSet; ));
})
flakeOutputs));
} }

View File

@ -1,13 +1,22 @@
{ config, lib, modulesPath, ... }: {
config,
lib,
modulesPath,
...
}:
{ {
imports = [ imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
(modulesPath + "/installer/scan/not-detected.nix")
];
boot = { boot = {
initrd = { initrd = {
availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "sd_mod" ]; availableKernelModules = [
"nvme"
"xhci_pci"
"usb_storage"
"sd_mod"
];
kernelModules = [ ]; kernelModules = [ ];
}; };

View File

@ -1,4 +1,10 @@
{ self, pkgs, config, lib, ... }: {
self,
pkgs,
config,
lib,
...
}:
let let
inherit (lib) mkIf mkForce; inherit (lib) mkIf mkForce;
@ -7,17 +13,19 @@ let
inherit (builtins) attrValues; inherit (builtins) attrValues;
getColorCh = colorName: channel: config.lib.stylix.colors."${colorName}-rgb-${channel}"; 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"})''; bg = ''linear-gradient(${rgba "base00" "0.7"}, ${rgba "base00" "0.7"})'';
in in
{ {
imports = attrValues self.nixosModules; imports = attrValues self.nixosModules;
nixpkgs.overlays = attrValues { nixpkgs.overlays = with self.overlays; [
inherit (self.overlays) phinger-cursors
phinger-cursors ];
;
};
home-manager.sharedModules = attrValues { home-manager.sharedModules = attrValues {
inherit (self.homeModules) inherit (self.homeModules)
@ -73,8 +81,15 @@ in
"org/gnome/desktop/input-sources" = { "org/gnome/desktop/input-sources" = {
sources = [ sources = [
(mkTuple [ "xkb" "us" ]) (mkTuple [
(mkTuple [ "xkb" "jp+kana" ]) "xkb"
"us"
])
(mkTuple [
"xkb"
"jp+kana"
])
]; ];
}; };
@ -91,40 +106,35 @@ in
}; };
background = { background = {
stylix.targets.gtk.extraCss = /* css */ '' stylix.targets.gtk.extraCss = # css
phosh-lockscreen { ''
background: ${bg}, url('file:///home/${username}/wall-lock.jpg'); phosh-lockscreen {
} background: ${bg}, url('file:///home/${username}/wall-lock.jpg');
}
phosh-app-grid { phosh-app-grid {
background: ${bg}, url('file:///home/${username}/wall-grid.jpg'); background: ${bg}, url('file:///home/${username}/wall-grid.jpg');
} }
phosh-top-panel { phosh-top-panel {
background: ${bg}, url('file:///home/${username}/wall-panel.jpg'); background: ${bg}, url('file:///home/${username}/wall-panel.jpg');
} }
phosh-home { phosh-home {
background: ${bg}, url('file:///home/${username}/wall-home.jpg'); background: ${bg}, url('file:///home/${username}/wall-home.jpg');
} }
phosh-lockscreen, phosh-app-grid, phosh-top-panel, phosh-home { phosh-lockscreen, phosh-app-grid, phosh-top-panel, phosh-home {
background-size: cover; background-size: cover;
background-position: center; background-position: center;
} }
''; '';
}; };
}; };
environment.systemPackages = attrValues { environment.systemPackages = attrValues {
inherit (self.packages.${pkgs.system}) inherit (self.packages.${pkgs.system}) webp-thumbnailer pinephone-toolkit;
webp-thumbnailer inherit (pkgs.gnome) gnome-contacts;
pinephone-toolkit
;
inherit (pkgs.gnome)
gnome-contacts
;
inherit (pkgs) inherit (pkgs)
chatty chatty
@ -158,7 +168,6 @@ in
thunar.enable = mkForce false; thunar.enable = mkForce false;
}; };
networking = { networking = {
wireless.enable = false; wireless.enable = false;
wireguard.enable = true; wireguard.enable = true;

View File

@ -1,4 +1,7 @@
test: { self, pkgs }: test:
{ self, pkgs }:
let let
inherit (pkgs.lib) mkDefault; inherit (pkgs.lib) mkDefault;

View File

@ -1,4 +1,9 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
let let
inherit (config.modules.system) username; inherit (config.modules.system) username;

View File

@ -1,4 +1,9 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
let let
inherit (config.modules.system) username; inherit (config.modules.system) username;

View File

@ -4,50 +4,53 @@ in
(import ../lib/test.nix) { (import ../lib/test.nix) {
name = "neovim"; name = "neovim";
nodes.machine = { nix-config, ... }: { nodes.machine =
imports = attrValues { { nix-config, ... }:
inherit (nix-config.nixosModules) desktop system shell; {
imports = attrValues {
inherit (nix-config.nixosModules) desktop system shell;
customConfig = { customConfig = {
modules.desktop.container = true; modules.desktop.container = true;
};
}; };
home-manager.sharedModules = with nix-config.homeModules; [
neovim
];
}; };
home-manager.sharedModules = attrValues { testScript = # python
inherit (nix-config.homeModules) neovim; ''
}; machine.wait_for_unit("default.target")
};
testScript = /* python */ '' machine.send_chars("user")
machine.wait_for_unit("default.target") 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.send_chars("nvim hello.txt")
machine.sleep(1) machine.sleep(1)
machine.send_key("ret") machine.send_key("ret")
machine.sleep(1) machine.sleep(20)
machine.send_chars("user")
machine.sleep(1)
machine.send_key("ret")
machine.sleep(5)
machine.send_chars("nvim hello.txt") machine.send_chars("i")
machine.sleep(1) machine.sleep(2)
machine.send_key("ret") machine.send_chars("Hello world")
machine.sleep(20) 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") text = machine.succeed("cat /home/user/hello.txt")
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") assert "Hello world" in text
'';
assert "Hello world" in text
'';
} }