Skip to content

Commit 58dfe24

Browse files
committed
chore(nix): format
1 parent 00b2e58 commit 58dfe24

21 files changed

+860
-671
lines changed

extra/language/c.nix

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ with lib;
3535
};
3636

3737
config = {
38-
devshell.packages =
39-
[ cfg.compiler ]
40-
++ (lib.optionals hasLibraries (map lib.getLib cfg.libraries))
41-
++
42-
# Assume we want pkg-config, because it's good
43-
(lib.optionals hasIncludes ([ pkgs.pkg-config ] ++ (map lib.getDev cfg.includes)));
38+
devshell.packages = [
39+
cfg.compiler
40+
]
41+
++ (lib.optionals hasLibraries (map lib.getLib cfg.libraries))
42+
++
43+
# Assume we want pkg-config, because it's good
44+
(lib.optionals hasIncludes ([ pkgs.pkg-config ] ++ (map lib.getDev cfg.includes)));
4445

4546
env =
4647
(lib.optionals hasLibraries [

extra/language/rust.nix

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -38,53 +38,52 @@ with lib;
3838
config = {
3939
devshell.packages =
4040
if cfg.enableDefaultToolchain then (map (tool: cfg.packageSet.${tool}) cfg.tools) else [ ];
41-
env =
42-
[
43-
{
44-
# On darwin for example enables finding of libiconv
45-
name = "LIBRARY_PATH";
46-
# append in case it needs to be modified
47-
eval = "$DEVSHELL_DIR/lib";
48-
}
49-
{
50-
# some *-sys crates require additional includes
51-
name = "CFLAGS";
52-
# append in case it needs to be modified
53-
eval = "\"-I $DEVSHELL_DIR/include ${lib.optionalString pkgs.stdenv.isDarwin "-iframework $DEVSHELL_DIR/Library/Frameworks"}\"";
54-
}
55-
]
56-
++ lib.optionals pkgs.stdenv.isDarwin [
57-
{
58-
# On darwin for example required for some *-sys crate compilation
59-
name = "RUSTFLAGS";
60-
# append in case it needs to be modified
61-
eval = "\"-L framework=$DEVSHELL_DIR/Library/Frameworks\"";
62-
}
63-
{
64-
# rustdoc uses a different set of flags
65-
name = "RUSTDOCFLAGS";
66-
# append in case it needs to be modified
67-
eval = "\"-L framework=$DEVSHELL_DIR/Library/Frameworks\"";
68-
}
69-
{
70-
name = "PATH";
71-
prefix =
72-
let
73-
inherit (pkgs) xcbuild;
74-
in
75-
lib.makeBinPath [
76-
xcbuild
77-
"${xcbuild}/Toolchains/XcodeDefault.xctoolchain"
78-
];
79-
}
80-
]
81-
# fenix provides '.rust-src' in the 'complete' toolchain configuration
82-
++ lib.optionals (cfg.enableDefaultToolchain && cfg.packageSet ? rust-src) [
83-
{
84-
# rust-analyzer may use this to quicker find the rust source
85-
name = "RUST_SRC_PATH";
86-
value = "${cfg.packageSet.rust-src}/lib/rustlib/src/rust/library";
87-
}
88-
];
41+
env = [
42+
{
43+
# On darwin for example enables finding of libiconv
44+
name = "LIBRARY_PATH";
45+
# append in case it needs to be modified
46+
eval = "$DEVSHELL_DIR/lib";
47+
}
48+
{
49+
# some *-sys crates require additional includes
50+
name = "CFLAGS";
51+
# append in case it needs to be modified
52+
eval = "\"-I $DEVSHELL_DIR/include ${lib.optionalString pkgs.stdenv.isDarwin "-iframework $DEVSHELL_DIR/Library/Frameworks"}\"";
53+
}
54+
]
55+
++ lib.optionals pkgs.stdenv.isDarwin [
56+
{
57+
# On darwin for example required for some *-sys crate compilation
58+
name = "RUSTFLAGS";
59+
# append in case it needs to be modified
60+
eval = "\"-L framework=$DEVSHELL_DIR/Library/Frameworks\"";
61+
}
62+
{
63+
# rustdoc uses a different set of flags
64+
name = "RUSTDOCFLAGS";
65+
# append in case it needs to be modified
66+
eval = "\"-L framework=$DEVSHELL_DIR/Library/Frameworks\"";
67+
}
68+
{
69+
name = "PATH";
70+
prefix =
71+
let
72+
inherit (pkgs) xcbuild;
73+
in
74+
lib.makeBinPath [
75+
xcbuild
76+
"${xcbuild}/Toolchains/XcodeDefault.xctoolchain"
77+
];
78+
}
79+
]
80+
# fenix provides '.rust-src' in the 'complete' toolchain configuration
81+
++ lib.optionals (cfg.enableDefaultToolchain && cfg.packageSet ? rust-src) [
82+
{
83+
# rust-analyzer may use this to quicker find the rust source
84+
name = "RUST_SRC_PATH";
85+
value = "${cfg.packageSet.rust-src}/lib/rustlib/src/rust/library";
86+
}
87+
];
8988
};
9089
}

flake.nix

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,14 @@
8787
}
8888
];
8989
utilites = [
90-
[ "GitHub utility" "gitAndTools.hub" ]
91-
[ "golang linter" "golangci-lint" ]
90+
[
91+
"GitHub utility"
92+
"gitAndTools.hub"
93+
]
94+
[
95+
"golang linter"
96+
"golangci-lint"
97+
]
9298
];
9399
};
94100
};
@@ -105,23 +111,31 @@
105111
}
106112
);
107113

108-
apps.default = devShells.default.flakeApp;
114+
apps.default = devShells.default.flakeApp;
109115

110-
checks = eachSystem ({pkgs, ...}:
111-
with pkgs.lib;
112-
pipe { } [
113-
(x:
114-
x // (import ./tests { inherit pkgs; })
115-
// devShells
116-
// { inherit (devshell.modules-docs) markdown; }
117-
)
118-
(collect isDerivation)
119-
(map (x: { name = x.name or x.pname; value = x; }))
120-
listToAttrs
121-
]
122-
);
116+
checks = eachSystem (
117+
{ pkgs, ... }:
118+
with pkgs.lib;
119+
pipe { } [
120+
(
121+
x:
122+
x
123+
// (import ./tests { inherit pkgs; })
124+
// devShells
125+
// {
126+
inherit (devshell.modules-docs) markdown;
127+
}
128+
)
129+
(collect isDerivation)
130+
(map (x: {
131+
name = x.name or x.pname;
132+
value = x;
133+
}))
134+
listToAttrs
135+
]
136+
);
123137

124-
formatter = eachSystem ({ pkgs, ... }: pkgs.nixfmt);
138+
formatter = eachSystem ({ pkgs, ... }: pkgs.nixfmt);
125139

126140
# Import this overlay into your instance of nixpkgs
127141
overlays.default = import ./overlay.nix;

modules/back-compat.nix

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ with lib;
5151
};
5252

5353
# Copy the values over to the devshell module
54-
config.devshell =
55-
{
56-
packages = config.packages;
57-
packagesFrom = config.packagesFrom;
58-
startup.bash_extra = noDepEntry config.bash.extra;
59-
interactive.bash_interactive = noDepEntry config.bash.interactive;
60-
}
61-
// (lib.optionalAttrs (config.motd != null) { motd = config.motd; })
62-
// (lib.optionalAttrs (config.name != null) { name = config.name; });
54+
config.devshell = {
55+
packages = config.packages;
56+
packagesFrom = config.packagesFrom;
57+
startup.bash_extra = noDepEntry config.bash.extra;
58+
interactive.bash_interactive = noDepEntry config.bash.interactive;
59+
}
60+
// (lib.optionalAttrs (config.motd != null) { motd = config.motd; })
61+
// (lib.optionalAttrs (config.name != null) { name = config.name; });
6362
}

modules/commands.nix

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
{ lib, config, pkgs, options, ... }:
1+
{
2+
lib,
3+
config,
4+
pkgs,
5+
options,
6+
...
7+
}:
28
let
39
inherit (import ../nix/commands/lib.nix { inherit pkgs options config; })
410
commandsType
@@ -48,10 +54,7 @@ in
4854

4955
# Add the commands to the devshell packages. Either as wrapper scripts, or
5056
# the whole package.
51-
config.devshell.packages =
52-
lib.filter
53-
(x: x != null)
54-
(map commandToPackage config.commands);
57+
config.devshell.packages = lib.filter (x: x != null) (map commandToPackage config.commands);
5558

5659
# config.devshell.motd = "$(motd)";
5760
}

modules/devshell.nix

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -409,43 +409,42 @@ in
409409

410410
packages = foldl' (sum: drv: sum ++ (inputsOf drv)) [ ] cfg.packagesFrom;
411411

412-
startup =
413-
{
414-
motd = noDepEntry ''
415-
__devshell-motd() {
416-
cat <<DEVSHELL_PROMPT
417-
${cfg.motd}
418-
DEVSHELL_PROMPT
419-
}
412+
startup = {
413+
motd = noDepEntry ''
414+
__devshell-motd() {
415+
cat <<DEVSHELL_PROMPT
416+
${cfg.motd}
417+
DEVSHELL_PROMPT
418+
}
420419
421-
if [[ ''${DEVSHELL_NO_MOTD:-} = 1 ]]; then
422-
# Skip if that env var is set
423-
:
424-
elif [[ ''${DIRENV_IN_ENVRC:-} = 1 ]]; then
425-
# Print the motd in direnv
420+
if [[ ''${DEVSHELL_NO_MOTD:-} = 1 ]]; then
421+
# Skip if that env var is set
422+
:
423+
elif [[ ''${DIRENV_IN_ENVRC:-} = 1 ]]; then
424+
# Print the motd in direnv
425+
__devshell-motd
426+
else
427+
# Print information if the prompt is displayed. We have to make
428+
# that distinction because `nix-shell -c "cmd"` is running in
429+
# interactive mode.
430+
__devshell-prompt() {
426431
__devshell-motd
427-
else
428-
# Print information if the prompt is displayed. We have to make
429-
# that distinction because `nix-shell -c "cmd"` is running in
430-
# interactive mode.
431-
__devshell-prompt() {
432-
__devshell-motd
433-
# Make it a noop
434-
__devshell-prompt() { :; }
435-
}
436-
PROMPT_COMMAND=__devshell-prompt''${PROMPT_COMMAND+;$PROMPT_COMMAND}
437-
fi
438-
'';
439-
}
440-
// (optionalAttrs cfg.load_profiles {
441-
load_profiles = lib.noDepEntry ''
442-
# Load installed profiles
443-
for file in "$DEVSHELL_DIR/etc/profile.d/"*.sh; do
444-
# If that folder doesn't exist, bash loves to return the whole glob
445-
[[ -f "$file" ]] && source "$file"
446-
done
447-
'';
448-
});
432+
# Make it a noop
433+
__devshell-prompt() { :; }
434+
}
435+
PROMPT_COMMAND=__devshell-prompt''${PROMPT_COMMAND+;$PROMPT_COMMAND}
436+
fi
437+
'';
438+
}
439+
// (optionalAttrs cfg.load_profiles {
440+
load_profiles = lib.noDepEntry ''
441+
# Load installed profiles
442+
for file in "$DEVSHELL_DIR/etc/profile.d/"*.sh; do
443+
# If that folder doesn't exist, bash loves to return the whole glob
444+
[[ -f "$file" ]] && source "$file"
445+
done
446+
'';
447+
});
449448

450449
interactive = {
451450
PS1_util = noDepEntry ''
@@ -488,7 +487,8 @@ in
488487
# `lib.getExe`, `nix run`, `nix bundle`, etc.
489488
{
490489
mainProgram = cfg.package.meta.mainProgram;
491-
} // cfg.meta;
490+
}
491+
// cfg.meta;
492492
profile = cfg.package;
493493
passthru = {
494494
inherit config;

modules/eval-args.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ in
1313
specialArgs = {
1414
modulesPath = builtins.toString ./.;
1515
extraModulesPath = builtins.toString ../extra;
16-
} // extraSpecialArgs;
16+
}
17+
// extraSpecialArgs;
1718
}

0 commit comments

Comments
 (0)