After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build a08b3a4d19.tar.gz \
--argstr baseRev 78e9caf153f5a339bf1d4c000ff6f0a503a369c8
result/bin/apply-formatting $NIXPKGS_PATH
77 lines
1.6 KiB
Nix
77 lines
1.6 KiB
Nix
# Not part of the public API – for use within nixpkgs only
|
||
#
|
||
# Usage:
|
||
# ```nix
|
||
# let
|
||
# sources = lib.importJSON ./sources.json;
|
||
# in mkMyDerivation rec {
|
||
# version = src.version; # This obviously only works for releases
|
||
# src = pkgs.npins.mkSource sources.mySource;
|
||
# }
|
||
# ```
|
||
|
||
{
|
||
fetchgit,
|
||
fetchzip,
|
||
fetchurl,
|
||
}:
|
||
let
|
||
mkSource =
|
||
spec:
|
||
assert spec ? type;
|
||
let
|
||
path =
|
||
if spec.type == "Git" then
|
||
mkGitSource spec
|
||
else if spec.type == "GitRelease" then
|
||
mkGitSource spec
|
||
else if spec.type == "PyPi" then
|
||
mkPyPiSource spec
|
||
else if spec.type == "Channel" then
|
||
mkChannelSource spec
|
||
else
|
||
throw "Unknown source type ${spec.type}";
|
||
in
|
||
spec // { outPath = path; };
|
||
|
||
mkGitSource =
|
||
{
|
||
repository,
|
||
revision,
|
||
url ? null,
|
||
hash,
|
||
...
|
||
}:
|
||
assert repository ? type;
|
||
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
|
||
# In the latter case, there we will always be an url to the tarball
|
||
if url != null then
|
||
(fetchzip {
|
||
inherit url;
|
||
sha256 = hash;
|
||
extension = "tar";
|
||
})
|
||
else
|
||
assert repository.type == "Git";
|
||
fetchgit {
|
||
url = repository.url;
|
||
rev = revision;
|
||
};
|
||
|
||
mkPyPiSource =
|
||
{ url, hash, ... }:
|
||
fetchurl {
|
||
inherit url;
|
||
sha256 = hash;
|
||
};
|
||
|
||
mkChannelSource =
|
||
{ url, hash, ... }:
|
||
fetchzip {
|
||
inherit url;
|
||
sha256 = hash;
|
||
extension = "tar";
|
||
};
|
||
in
|
||
mkSource
|