-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent some rebuilds for future Nix reformats #326430
Changes from all commits
65e7143
323012c
ea17c50
7cb66fd
e6d4558
8f425c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,57 @@ | ||
{ lib, options, ... }: | ||
let discardPositions = lib.mapAttrs (k: v: v); | ||
let | ||
discardPositions = lib.mapAttrs (k: v: v); | ||
in | ||
# unsafeGetAttrPos is unspecified best-effort behavior, so we only want to consider this test on an evaluator that satisfies some basic assumptions about this function. | ||
assert builtins.unsafeGetAttrPos "a" { a = true; } != null; | ||
assert builtins.unsafeGetAttrPos "a" (discardPositions { a = true; }) == null; | ||
assert | ||
builtins.unsafeGetAttrPos "a" (discardPositions { | ||
a = true; | ||
}) == null; | ||
{ | ||
imports = [ | ||
{ | ||
options.imported.line10 = lib.mkOption { | ||
options.imported.line14 = lib.mkOption { | ||
type = lib.types.int; | ||
}; | ||
|
||
# Simulates various patterns of generating modules such as | ||
# programs.firefox.nativeMessagingHosts.ff2mpv. We don't expect to get | ||
# line numbers for these, but we can fall back on knowing the file. | ||
options.generated = discardPositions { | ||
line18 = lib.mkOption { | ||
line22 = lib.mkOption { | ||
type = lib.types.int; | ||
}; | ||
}; | ||
|
||
options.submoduleLine34.extraOptLine23 = lib.mkOption { | ||
options.submoduleLine38.extraOptLine27 = lib.mkOption { | ||
default = 1; | ||
type = lib.types.int; | ||
}; | ||
} | ||
]; | ||
|
||
options.nested.nestedLine30 = lib.mkOption { | ||
options.nested.nestedLine34 = lib.mkOption { | ||
type = lib.types.int; | ||
}; | ||
|
||
options.submoduleLine34 = lib.mkOption { | ||
options.submoduleLine38 = lib.mkOption { | ||
default = { }; | ||
type = lib.types.submoduleWith { | ||
modules = [ | ||
({ options, ... }: { | ||
options.submodDeclLine39 = lib.mkOption { }; | ||
}) | ||
( | ||
{ options, ... }: | ||
{ | ||
options.submodDeclLine45 = lib.mkOption { }; | ||
} | ||
) | ||
{ freeformType = with lib.types; lazyAttrsOf (uniq unspecified); } | ||
]; | ||
}; | ||
}; | ||
|
||
config = { | ||
submoduleLine34.submodDeclLine39 = (options.submoduleLine34.type.getSubOptions [ ]).submodDeclLine39.declarationPositions; | ||
submoduleLine38.submodDeclLine45 = | ||
(options.submoduleLine38.type.getSubOptions [ ]).submodDeclLine45.declarationPositions; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,19 +1,28 @@ | ||||||||||||
with import <localpkgs> {}; | ||||||||||||
with import <localpkgs> { }; | ||||||||||||
let | ||||||||||||
inherit (vimUtils.override {inherit vim;}) buildVimPlugin; | ||||||||||||
inherit (vimUtils.override { inherit vim; }) buildVimPlugin; | ||||||||||||
inherit (neovimUtils) buildNeovimPlugin; | ||||||||||||
|
||||||||||||
generated = callPackage <localpkgs/pkgs/applications/editors/vim/plugins/generated.nix> { | ||||||||||||
inherit buildNeovimPlugin buildVimPlugin; | ||||||||||||
} {} {}; | ||||||||||||
hasChecksum = value: | ||||||||||||
lib.isAttrs value && lib.hasAttrByPath ["src" "outputHash"] value; | ||||||||||||
getChecksum = name: value: | ||||||||||||
if hasChecksum value then { | ||||||||||||
submodules = value.src.fetchSubmodules or false; | ||||||||||||
sha256 = value.src.outputHash; | ||||||||||||
rev = value.src.rev; | ||||||||||||
} else null; | ||||||||||||
} { } { }; | ||||||||||||
hasChecksum = | ||||||||||||
value: | ||||||||||||
lib.isAttrs value | ||||||||||||
&& lib.hasAttrByPath [ | ||||||||||||
"src" | ||||||||||||
"outputHash" | ||||||||||||
] value; | ||||||||||||
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a nixpkgs-fmt user this feels ugly.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed this can be simplified and reformatted to just
Relevant motto from the RFC:
😆 |
||||||||||||
getChecksum = | ||||||||||||
name: value: | ||||||||||||
if hasChecksum value then | ||||||||||||
{ | ||||||||||||
submodules = value.src.fetchSubmodules or false; | ||||||||||||
sha256 = value.src.outputHash; | ||||||||||||
rev = value.src.rev; | ||||||||||||
} | ||||||||||||
else | ||||||||||||
null; | ||||||||||||
checksums = lib.mapAttrs getChecksum generated; | ||||||||||||
in | ||||||||||||
lib.filterAttrs (n: v: v != null) checksums | ||||||||||||
lib.filterAttrs (n: v: v != null) checksums |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Just some text |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
{ lib, haskellPackages, runCommand }: | ||
{ lib, haskell, haskellPackages, runCommand }: | ||
|
||
let | ||
localRaw = haskellPackages.callPackage ./local/generated.nix {}; | ||
src = lib.fileset.toSource { | ||
root = ./local; | ||
fileset = lib.fileset.unions [ | ||
./local/app | ||
./local/CHANGELOG.md | ||
./local/local.cabal | ||
]; | ||
}; | ||
# This prevents the source from depending on the formatting of the ./local/generated.nix file | ||
localRaw = haskell.lib.compose.overrideSrc { | ||
inherit src; | ||
} (haskellPackages.callPackage ./local/generated.nix {}); | ||
Comment on lines
+4
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since that's technically a generated file, I think it's cleaner to override the source from here instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's named as such but is in no way generated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure it was generated using |
||
in | ||
lib.recurseIntoAttrs rec { | ||
|
||
|
@@ -20,14 +31,14 @@ lib.recurseIntoAttrs rec { | |
assumptionLocalHasDirectReference = runCommand "localHasDirectReference" { | ||
drvPath = builtins.unsafeDiscardOutputDependency localRaw.drvPath; | ||
} '' | ||
grep ${./local} $drvPath >/dev/null | ||
grep ${src} $drvPath >/dev/null | ||
touch $out | ||
''; | ||
|
||
localHasNoDirectReference = runCommand "localHasNoDirectReference" { | ||
drvPath = builtins.unsafeDiscardOutputDependency localFromCabalSdist.drvPath; | ||
} '' | ||
grep -v ${./local} $drvPath >/dev/null | ||
grep -v ${src} $drvPath >/dev/null | ||
touch $out | ||
''; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,16 +15,25 @@ let | |
makeGoldenTest = testname: runCommand "make-binary-wrapper-test-${testname}" env '' | ||
mkdir -p tmp/foo # for the chdir test | ||
|
||
params=$(<"${./.}/${testname}.cmdline") | ||
source=${lib.fileset.toSource { | ||
root = ./.; | ||
fileset = lib.fileset.unions [ | ||
(./. + "/${testname}.cmdline") | ||
(./. + "/${testname}.c") | ||
(lib.fileset.maybeMissing (./. + "/${testname}.env")) | ||
]; | ||
}} | ||
Comment on lines
+18
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be clearer if extracted to another binding. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is fine, I don't think much is gained from having an intermediate Nix binding (we already assign it to a bash variable here) |
||
|
||
params=$(<"$source/${testname}.cmdline") | ||
eval "makeCWrapper /send/me/flags $params" > wrapper.c | ||
|
||
diff wrapper.c "${./.}/${testname}.c" | ||
diff wrapper.c "$source/${testname}.c" | ||
|
||
if [ -f "${./.}/${testname}.env" ]; then | ||
if [ -f "$source/${testname}.env" ]; then | ||
eval "makeWrapper ${envCheck} wrapped $params" | ||
env -i ./wrapped > env.txt | ||
sed "s#SUBST_ARGV0#${envCheck}#;s#SUBST_CWD#$PWD#" \ | ||
"${./.}/${testname}.env" > golden-env.txt | ||
"$source/${testname}.env" > golden-env.txt | ||
if ! diff env.txt golden-env.txt; then | ||
echo "env/argv should be:" | ||
cat golden-env.txt | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
let | ||
pkgs = import <nixpkgs> {}; | ||
in pkgs.runCommand "diagnostics-multiuser" | ||
{ } | ||
'' | ||
set -x | ||
# no cache: ${toString builtins.currentTime} | ||
# For reproducibility, nix always uses nixbld group: | ||
# https://github.com/NixOS/nix/blob/1dd29d7aebae706f3e90a18bbfae727f2ed03c70/src/libstore/build.cc#L1896-L1908 | ||
test "$(groups)" == "nixbld" | ||
touch $out | ||
'' | ||
pkgs = import <nixpkgs> { }; | ||
in | ||
pkgs.runCommand "diagnostics-multiuser" { } '' | ||
set -x | ||
# no cache: ${toString builtins.currentTime} | ||
# For reproducibility, nix always uses nixbld group: | ||
# https://github.com/NixOS/nix/blob/1dd29d7aebae706f3e90a18bbfae727f2ed03c70/src/libstore/build.cc#L1896-L1908 | ||
test "$(groups)" == "nixbld" | ||
touch $out | ||
'' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
let | ||
pkgs = import <nixpkgs> {}; | ||
in pkgs.runCommand "diagnostics-sandbox" | ||
{ } | ||
'' | ||
set -x | ||
# no cache: ${toString builtins.currentTime} | ||
test -d "$(dirname "$out")/../var/nix" | ||
touch $out | ||
'' | ||
pkgs = import <nixpkgs> { }; | ||
in | ||
pkgs.runCommand "diagnostics-sandbox" { } '' | ||
set -x | ||
# no cache: ${toString builtins.currentTime} | ||
test -d "$(dirname "$out")/../var/nix" | ||
touch $out | ||
'' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sigh, this is on my list of #208242 things to go make better.