Skip to content

Commit

Permalink
Experiment 2
Browse files Browse the repository at this point in the history
  • Loading branch information
piegamesde committed Aug 17, 2024
1 parent c002c55 commit 3fac7f2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 42 deletions.
3 changes: 3 additions & 0 deletions src/Nixfmt/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ absorbExpr _ expr = pretty expr
absorbRHS :: Expression -> Doc
absorbRHS expr = case expr of
-- Absorbable expression. Always start on the same line
(Term (Set _ _ binders _))
| case unItems binders of [(Item (Inherit{}))] -> True; _ -> False ->
hardspace <> group (absorbExpr False expr)
_ | isAbsorbableExpr expr -> hardspace <> group (absorbExpr True expr)
-- Parenthesized expression. Same thing as the special case for parenthesized last argument in function calls.
(Term (Parenthesized open expr' close)) -> hardspace <> absorbParen open expr' close
Expand Down
24 changes: 6 additions & 18 deletions test/diff/idioms_lib_4/out-pure.nix
Original file line number Diff line number Diff line change
Expand Up @@ -521,33 +521,25 @@ rec {
# the normalized name for macOS.
macos = {
execFormat = macho;
families = {
inherit darwin;
};
families = { inherit darwin; };
name = "darwin";
};
ios = {
execFormat = macho;
families = {
inherit darwin;
};
families = { inherit darwin; };
};
# A tricky thing about FreeBSD is that there is no stable ABI across
# versions. That means that putting in the version as part of the
# config string is paramount.
freebsd12 = {
execFormat = elf;
families = {
inherit bsd;
};
families = { inherit bsd; };
name = "freebsd";
version = 12;
};
freebsd13 = {
execFormat = elf;
families = {
inherit bsd;
};
families = { inherit bsd; };
name = "freebsd";
version = 13;
};
Expand All @@ -557,19 +549,15 @@ rec {
};
netbsd = {
execFormat = elf;
families = {
inherit bsd;
};
families = { inherit bsd; };
};
none = {
execFormat = unknown;
families = { };
};
openbsd = {
execFormat = elf;
families = {
inherit bsd;
};
families = { inherit bsd; };
};
solaris = {
execFormat = elf;
Expand Down
24 changes: 6 additions & 18 deletions test/diff/idioms_lib_4/out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -521,33 +521,25 @@ rec {
# the normalized name for macOS.
macos = {
execFormat = macho;
families = {
inherit darwin;
};
families = { inherit darwin; };
name = "darwin";
};
ios = {
execFormat = macho;
families = {
inherit darwin;
};
families = { inherit darwin; };
};
# A tricky thing about FreeBSD is that there is no stable ABI across
# versions. That means that putting in the version as part of the
# config string is paramount.
freebsd12 = {
execFormat = elf;
families = {
inherit bsd;
};
families = { inherit bsd; };
name = "freebsd";
version = 12;
};
freebsd13 = {
execFormat = elf;
families = {
inherit bsd;
};
families = { inherit bsd; };
name = "freebsd";
version = 13;
};
Expand All @@ -557,19 +549,15 @@ rec {
};
netbsd = {
execFormat = elf;
families = {
inherit bsd;
};
families = { inherit bsd; };
};
none = {
execFormat = unknown;
families = { };
};
openbsd = {
execFormat = elf;
families = {
inherit bsd;
};
families = { inherit bsd; };
};
solaris = {
execFormat = elf;
Expand Down
4 changes: 1 addition & 3 deletions test/diff/idioms_nixos_1/out-pure.nix
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,7 @@ in
})

(mkIf (!config.boot.isContainer) {
system.build = {
inherit kernel;
};
system.build = { inherit kernel; };

system.modulesTree = [ kernel ] ++ config.boot.extraModulePackages;

Expand Down
4 changes: 1 addition & 3 deletions test/diff/idioms_nixos_1/out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,7 @@ in
})

(mkIf (!config.boot.isContainer) {
system.build = {
inherit kernel;
};
system.build = { inherit kernel; };

system.modulesTree = [ kernel ] ++ config.boot.extraModulePackages;

Expand Down

0 comments on commit 3fac7f2

Please sign in to comment.