Skip to content

Commit

Permalink
Reformat everything using nixfmt-rfc-style
Browse files Browse the repository at this point in the history
Since nixpkgs is being formatted with this tool
and it's by far the biggest Nix codebase it makes
sense to follow their style as closely as possible

It's a bit more verbose with lines, but I think
that's cool.
  • Loading branch information
Lillecarl committed Dec 6, 2024
1 parent c3d73c4 commit 2fc77fb
Show file tree
Hide file tree
Showing 109 changed files with 1,844 additions and 1,287 deletions.
14 changes: 8 additions & 6 deletions checks/flake-module.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{ self
, inputs
, __curPos ? __curPos
, ...
{
self,
inputs,
__curPos ? __curPos,
...
}:
{
perSystem = { system, pkgs, ... }:
perSystem =
{ system, pkgs, ... }:
{
checks.pre-commit-check = inputs.git-hooks.lib.${system}.run {
src = ../.;
#src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
nixfmt-rfc-style.enable = true;
};
};

Expand Down
27 changes: 16 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@
};

outputs =
{ self
, flake-parts
, ...
} @ inputs:
{
self,
flake-parts,
...
}@inputs:
let
# limits perSystem
systems = [
Expand Down Expand Up @@ -239,6 +240,7 @@
};
imports = [
./checks/flake-module.nix
./hosts/shitbox/flake-module.nix
./nixvim/flake-module.nix
./repl/flake-module.nix
./repoenv/flake-module.nix
Expand All @@ -257,13 +259,16 @@
}
{
inherit systems imports;
flake = { };
flake =
{
};
perSystem =
{ self'
, inputs'
, system
, pkgs
, ...
{
self',
inputs',
system,
pkgs,
...
}:
let
legacyPackages = pkgs.extend (import ./pkgs);
Expand All @@ -276,7 +281,7 @@
spkgs = pkgsGenerator inputs.nixpkgs-stable system;
} // specialArgs;

formatter = pkgs.nixpkgs-fmt;
formatter = pkgs.nixfmt-rfc-style;
inherit legacyPackages packages;
};
};
Expand Down
117 changes: 66 additions & 51 deletions home-manager/modules/programs/carapace.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:

let

inherit (lib)
mkOption mkEnableOption mkPackageOption mkIf pipe fileContents splitString lists;
mkOption
mkEnableOption
mkPackageOption
mkIf
pipe
fileContents
splitString
lists
;
cfg = config.programs.carapace;
bin = cfg.package + "/bin/carapace";

in
{
meta.maintainers = with lib.maintainers; [ weathercold bobvanderlinden ];
meta.maintainers = with lib.maintainers; [
weathercold
bobvanderlinden
];

options.programs.carapace = {
enable =
mkEnableOption "carapace, a multi-shell multi-command argument completer";
enable = mkEnableOption "carapace, a multi-shell multi-command argument completer";

package = mkPackageOption pkgs "carapace" { };

Expand Down Expand Up @@ -45,12 +60,14 @@ in

config =
let
carapaceListFile = pkgs.runCommandLocal "carapace-list"
{
buildInputs = [ cfg.package ];
} ''
${bin} --list | ${lib.getExe pkgs.gawk} '{ print $1 }' > $out
'';
carapaceListFile =
pkgs.runCommandLocal "carapace-list"
{
buildInputs = [ cfg.package ];
}
''
${bin} --list | ${lib.getExe pkgs.gawk} '{ print $1 }' > $out
'';
availableCompleters = splitString "\n" (builtins.readFile carapaceListFile);
enabledCompleters = lists.intersectLists availableCompleters cfg.enabledCompleters;
invalidCompleters = lists.subtractLists availableCompleters cfg.enabledCompleters;
Expand Down Expand Up @@ -78,13 +95,9 @@ in
${bin} _carapace fish | source
''
else
(
builtins.concatStringsSep "\n" (
builtins.map
(name: "${bin} ${name} fish | source")
enabledCompleters
)
)
(builtins.concatStringsSep "\n" (
builtins.map (name: "${bin} ${name} fish | source") enabledCompleters
))
);

nushell = mkIf cfg.enableNushellIntegration {
Expand All @@ -103,39 +116,41 @@ in
};
};

xdg.configFile =
mkIf (config.programs.fish.enable && cfg.enableFishIntegration) (
# Convert the entries from `carapace --list` to empty
# xdg.configFile."fish/completions/NAME.fish" entries.
#
# This is to disable fish builtin completion for each of the
# carapace-supported completions It is in line with the instructions from
# carapace-bin:
#
# carapace --list | awk '{print $1}' | xargs -I{} touch ~/.config/fish/completions/{}.fish
#
# See https://github.com/rsteube/carapace-bin#getting-started
if enabledCompleters == [ ]
then
(pipe carapaceListFile [
fileContents
(splitString "\n")
(builtins.filter
(match: match != null && (builtins.length match) > 0))
(map (match: builtins.head match))
(map (name: {
name = "fish/completions/${name}.fish";
value = { text = ""; };
}))
builtins.listToAttrs
])
else
xdg.configFile = mkIf (config.programs.fish.enable && cfg.enableFishIntegration) (
# Convert the entries from `carapace --list` to empty
# xdg.configFile."fish/completions/NAME.fish" entries.
#
# This is to disable fish builtin completion for each of the
# carapace-supported completions It is in line with the instructions from
# carapace-bin:
#
# carapace --list | awk '{print $1}' | xargs -I{} touch ~/.config/fish/completions/{}.fish
#
# See https://github.com/rsteube/carapace-bin#getting-started
if enabledCompleters == [ ] then
(pipe carapaceListFile [
fileContents
(splitString "\n")
(builtins.filter (match: match != null && (builtins.length match) > 0))
(map (match: builtins.head match))
(map (name: {
name = "fish/completions/${name}.fish";
value = {
text = "";
};
}))
builtins.listToAttrs
((map (name: {
name = "fish/completions/${name}.fish";
value = { text = ""; };
}))
cfg.enabledCompleters)
);
])
else
builtins.listToAttrs (
(map (name: {
name = "fish/completions/${name}.fish";
value = {
text = "";
};
}))
cfg.enabledCompleters
)
);
};
}
7 changes: 6 additions & 1 deletion home-manager/modules/programs/distrobox.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.programs.distrobox;
in
Expand Down
3 changes: 1 addition & 2 deletions hosts/_shared/bluetooth.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
_:
{
_: {
services.blueman.enable = true;

hardware = {
Expand Down
3 changes: 1 addition & 2 deletions hosts/_shared/btrfs.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
_:
{
_: {
services.btrfs.autoScrub = {
enable = true;
fileSystems = [ "/" ];
Expand Down
3 changes: 1 addition & 2 deletions hosts/_shared/command-not-found.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
_:
{
_: {
programs.command-not-found.enable = false;
}
9 changes: 5 additions & 4 deletions hosts/_shared/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{ pkgs
, lib
, config
, ...
{
pkgs,
lib,
config,
...
}:
{
hardware.uinput.enable = true;
Expand Down
3 changes: 1 addition & 2 deletions hosts/_shared/earlyoom.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
_:
{
_: {
services.earlyoom = {
enable = true;

Expand Down
3 changes: 1 addition & 2 deletions hosts/_shared/fish.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
_:
{
_: {
programs.fish = {
enable = true;

Expand Down
5 changes: 3 additions & 2 deletions hosts/_shared/guix.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ pkgs
, ...
{
pkgs,
...
}:
{
services.guix = {
Expand Down
7 changes: 4 additions & 3 deletions hosts/_shared/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ config
, lib
, ...
{
config,
lib,
...
}:
{
boot = {
Expand Down
5 changes: 3 additions & 2 deletions hosts/_shared/kea.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ config
, ...
{
config,
...
}:
{
services.kea = {
Expand Down
Loading

0 comments on commit 2fc77fb

Please sign in to comment.