Skip to content

Commit

Permalink
style: reformat .nix files with nixfmt-rfc-style
Browse files Browse the repository at this point in the history
  • Loading branch information
dixslyf committed Oct 13, 2024
1 parent 2bb58cd commit 90b09df
Show file tree
Hide file tree
Showing 118 changed files with 1,221 additions and 807 deletions.
30 changes: 15 additions & 15 deletions devshell/ci/scripts/default.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{ pkgs
, ...
}: {
configure-git-user = pkgs.resholve.writeScriptBin "configure-git-user.sh"
{
interpreter = "${pkgs.bash}/bin/bash";
inputs = with pkgs; [
coreutils
git
];
execer = [
"cannot:${pkgs.git}/bin/git"
];
}
(builtins.readFile ./configure-git-user.sh);
{
pkgs,
...
}:
{
configure-git-user = pkgs.resholve.writeScriptBin "configure-git-user.sh" {
interpreter = "${pkgs.bash}/bin/bash";
inputs = with pkgs; [
coreutils
git
];
execer = [
"cannot:${pkgs.git}/bin/git"
];
} (builtins.readFile ./configure-git-user.sh);
}
19 changes: 16 additions & 3 deletions devshell/default/default.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
{ pkgs, ... }:

{
packages = with pkgs; [ sops npins nixfmt-rfc-style stylua statix deadnix ];
packages = with pkgs; [
sops
npins
nixfmt-rfc-style
stylua
statix
deadnix
];
pre-commit = {
hooks = {
nixfmt-rfc-style = {
enable = true;
excludes = [ "^planet/pkgs/npins/" "^planet/pkgs/vim-plugins/npins/" ];
excludes = [
"^planet/pkgs/npins/"
"^planet/pkgs/vim-plugins/npins/"
];
};
statix = {
enable = true;
settings = {
ignore = [ "planet/pkgs/npins/" "planet/pkgs/vim-plugins/npins/" ];
ignore = [
"planet/pkgs/npins/"
"planet/pkgs/vim-plugins/npins/"
];
};
};
stylua.enable = true;
Expand Down
25 changes: 14 additions & 11 deletions devshell/flake-module.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
{ inputs, ... }: {
perSystem = { pkgs, ... }: {
formatter = pkgs.nixfmt-rfc-style;
{ inputs, ... }:
{
perSystem =
{ pkgs, ... }:
{
formatter = pkgs.nixfmt-rfc-style;

devShells.default = inputs.devenv.lib.mkShell {
inherit inputs pkgs;
modules = [ ./default ];
};
devShells.default = inputs.devenv.lib.mkShell {
inherit inputs pkgs;
modules = [ ./default ];
};

devShells.ci = inputs.devenv.lib.mkShell {
inherit inputs pkgs;
modules = [ ./ci ];
devShells.ci = inputs.devenv.lib.mkShell {
inherit inputs pkgs;
modules = [ ./ci ];
};
};
};
}
8 changes: 5 additions & 3 deletions home-manager/users/samoyed/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{ pkgs
, ...
}: {
{
pkgs,
...
}:
{
home.stateVersion = "23.05";

xdg.userDirs = {
Expand Down
10 changes: 6 additions & 4 deletions home-manager/users/shiba/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{ importModule
, localFlakeInputs'
, ...
{
importModule,
localFlakeInputs',
...
}:

{ pkgs, ... }: {
{ pkgs, ... }:
{
imports = [
(importModule ./sops { })
];
Expand Down
8 changes: 5 additions & 3 deletions home-manager/users/shiba/sops/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{ localFlakeInputs, ... }:

{ config
, ...
}: {
{
config,
...
}:
{
imports = [
localFlakeInputs.sops-nix.homeManagerModules.sops
];
Expand Down
62 changes: 35 additions & 27 deletions lib/flake-module.nix
Original file line number Diff line number Diff line change
@@ -1,42 +1,50 @@
{ self
, flake-parts-lib
, moduleWithSystem
, inputs
, homeUsers # From home-manager flake-module via `_module.args`
, ...
{
self,
flake-parts-lib,
moduleWithSystem,
inputs,
homeUsers, # From home-manager flake-module via `_module.args`
...
}:
{
flake.lib =
let
inherit (inputs) nixpkgs;

# Adapted from https://stackoverflow.com/questions/54504685/nix-function-to-merge-attributes-records-recursively-and-concatenate-arrays
recursiveMergeAttrs = builtins.zipAttrsWith
(name: values:
if builtins.tail values == [ ]
then builtins.head values
else if builtins.all builtins.isList values
then nixpkgs.lib.lists.unique (builtins.concatLists values)
else if builtins.all builtins.isAttrs values
then recursiveMergeAttrs values
else abort "Conflicting unmergeable values for ${name}"
);

importModule = modulePath: args: moduleWithSystem (
{ self', inputs' }:
flake-parts-lib.importApply modulePath ({
inherit importModule;
localFlake = self;
localFlakeInputs = inputs;
localFlake' = self';
localFlakeInputs' = inputs';
} // args)
recursiveMergeAttrs = builtins.zipAttrsWith (
name: values:
if builtins.tail values == [ ] then
builtins.head values
else if builtins.all builtins.isList values then
nixpkgs.lib.lists.unique (builtins.concatLists values)
else if builtins.all builtins.isAttrs values then
recursiveMergeAttrs values
else
abort "Conflicting unmergeable values for ${name}"
);

importModule =
modulePath: args:
moduleWithSystem (
{ self', inputs' }:
flake-parts-lib.importApply modulePath (
{
inherit importModule;
localFlake = self;
localFlakeInputs = inputs;
localFlake' = self';
localFlakeInputs' = inputs';
}
// args
)
);
in
{
inherit recursiveMergeAttrs importModule;

mkNixosSystem = extraConfig:
mkNixosSystem =
extraConfig:
let
config = recursiveMergeAttrs [
extraConfig
Expand Down
30 changes: 15 additions & 15 deletions nixos/flake-module.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{ self
, ...
{
self,
...
}:
{
flake = {
nixosConfigurations =
{
alpha = self.lib.mkNixosSystem {
system = "x86_64-linux";
modules = [
./hosts/alpha
];
};
nixosConfigurations = {
alpha = self.lib.mkNixosSystem {
system = "x86_64-linux";
modules = [
./hosts/alpha
];
};

bravo = self.lib.mkNixosSystem {
modules = [
./hosts/bravo
];
};
bravo = self.lib.mkNixosSystem {
modules = [
./hosts/bravo
];
};
};
};
}
27 changes: 19 additions & 8 deletions nixos/hosts/alpha/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{ config
, pkgs
, inputs
, ...
}: {
{
config,
pkgs,
inputs,
...
}:
{
imports = [
./hardware
./users
Expand Down Expand Up @@ -66,7 +68,10 @@
auto-optimise-store = true;
keep-outputs = true;
keep-derivations = true;
experimental-features = [ "nix-command" "flakes" ];
experimental-features = [
"nix-command"
"flakes"
];
substituters = [
"https://playernamehere-nixos.cachix.org"
"https://nix-gaming.cachix.org"
Expand Down Expand Up @@ -142,7 +147,10 @@
planet = {
btrfs = {
enable = true;
autoScrubFileSystems = [ "/dev/sda3" "/dev/sdb1" ];
autoScrubFileSystems = [
"/dev/sda3"
"/dev/sdb1"
];
};
earlyoom.enable = true;
flatpak.enable = true;
Expand All @@ -158,7 +166,10 @@
sddm.enable = true;
tlp = {
enable = true;
diskDevices = [ "nvme0n1" "sda" ];
diskDevices = [
"nvme0n1"
"sda"
];
};
udisks2.enable = true;
upower.enable = true;
Expand Down
45 changes: 35 additions & 10 deletions nixos/hosts/alpha/hardware/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{ config
, pkgs
, modulesPath
, ...
}: {
{
config,
pkgs,
modulesPath,
...
}:
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
Expand All @@ -25,7 +27,15 @@
extraModulePackages = [ ];

initrd = {
availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "uas" "sd_mod" ];
availableKernelModules = [
"xhci_pci"
"ahci"
"nvme"
"usb_storage"
"usbhid"
"uas"
"sd_mod"
];
kernelModules = [ ];

secrets = {
Expand Down Expand Up @@ -64,7 +74,11 @@
"/" = {
device = "none";
fsType = "tmpfs";
options = [ "size=8G" "mode=755" "noatime" ];
options = [
"size=8G"
"mode=755"
"noatime"
];
};
"/boot" = {
device = "/dev/disk/by-uuid/40fcf0a0-13cc-47c4-83bb-f83df975df8e";
Expand All @@ -79,19 +93,30 @@
"/nix" = {
device = "/dev/disk/by-uuid/5315a5dd-a383-409a-b8b0-33bbc9d57a17";
fsType = "btrfs";
options = [ "subvol=@nix" "compress=zstd:1" "noatime" ];
options = [
"subvol=@nix"
"compress=zstd:1"
"noatime"
];
};
"/persist" = {
device = "/dev/disk/by-uuid/5315a5dd-a383-409a-b8b0-33bbc9d57a17";
fsType = "btrfs";
neededForBoot = true;
options = [ "subvol=@persist" "compress=zstd:1" "noatime" ];
options = [
"subvol=@persist"
"compress=zstd:1"
"noatime"
];
};
"/persist/home" = {
device = "/dev/disk/by-uuid/e4cc116c-4044-4b91-8618-86ee4ba59373";
fsType = "btrfs";
neededForBoot = true;
options = [ "compress=zstd:2" "noatime" ];
options = [
"compress=zstd:2"
"noatime"
];
};
};

Expand Down
8 changes: 5 additions & 3 deletions nixos/hosts/alpha/kmonad/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{ inputs
, ...
}: {
{
inputs,
...
}:
{
imports = [
inputs.kmonad.nixosModules.default
];
Expand Down
Loading

0 comments on commit 90b09df

Please sign in to comment.