mirror of
https://github.com/nmattia/niv.git
synced 2024-09-19 11:27:40 +03:00
nixpkgs-fmt
This commit is contained in:
parent
f555c9cc5f
commit
2f2ee45a08
@ -19,7 +19,7 @@ let
|
|||||||
pkgs.fetchzip { inherit (spec) url sha256; };
|
pkgs.fetchzip { inherit (spec) url sha256; };
|
||||||
|
|
||||||
fetch_git = spec:
|
fetch_git = spec:
|
||||||
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
|
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
|
||||||
|
|
||||||
fetch_builtin-tarball = spec:
|
fetch_builtin-tarball = spec:
|
||||||
builtins.trace
|
builtins.trace
|
||||||
@ -132,5 +132,4 @@ let
|
|||||||
pkgs = mkPkgs sources;
|
pkgs = mkPkgs sources;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
mkSources (mkConfig {}) //
|
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
||||||
{ __functor = _: settings: mkSources (mkConfig settings); }
|
|
||||||
|
@ -6,76 +6,72 @@ pkgs.runCommand "git-test"
|
|||||||
{ nativeBuildInputs = [ pkgs.git niv pkgs.nix pkgs.jq ]; }
|
{ nativeBuildInputs = [ pkgs.git niv pkgs.nix pkgs.jq ]; }
|
||||||
(
|
(
|
||||||
|
|
||||||
# make sure the tests run smoothly in multi-user install
|
# make sure the tests run smoothly in multi-user install
|
||||||
# https://github.com/NixOS/nix/issues/3258
|
# https://github.com/NixOS/nix/issues/3258
|
||||||
''
|
''
|
||||||
export NIX_STATE_DIR=$TMPDIR
|
export NIX_STATE_DIR=$TMPDIR
|
||||||
export NIX_LOG_DIR=$TMPDIR
|
export NIX_LOG_DIR=$TMPDIR
|
||||||
export HOME=$TMPDIR
|
export HOME=$TMPDIR
|
||||||
'' +
|
'' + # First we create a dummy git repo with one commit on master, and one commit
|
||||||
# First we create a dummy git repo with one commit on master, and one commit
|
# on "branch".
|
||||||
# on "branch".
|
''
|
||||||
''
|
gitdir=$(mktemp -d)
|
||||||
gitdir=$(mktemp -d)
|
pushd $gitdir > /dev/null
|
||||||
pushd $gitdir > /dev/null
|
git init .
|
||||||
git init .
|
echo hello > file
|
||||||
echo hello > file
|
git config user.email "niv@foo.bar"
|
||||||
git config user.email "niv@foo.bar"
|
git config user.name "Niv Niverson"
|
||||||
git config user.name "Niv Niverson"
|
git add file
|
||||||
git add file
|
git commit -m "Initial commit"
|
||||||
git commit -m "Initial commit"
|
gitrev=$(git rev-parse HEAD)
|
||||||
gitrev=$(git rev-parse HEAD)
|
|
||||||
|
|
||||||
git checkout -b branch
|
git checkout -b branch
|
||||||
echo world >> file
|
echo world >> file
|
||||||
git add file
|
git add file
|
||||||
git commit -m "second commit"
|
git commit -m "second commit"
|
||||||
gitrev2=$(git rev-parse HEAD)
|
gitrev2=$(git rev-parse HEAD)
|
||||||
|
|
||||||
# reset to master as "default branch"
|
# reset to master as "default branch"
|
||||||
git checkout master
|
git checkout master
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
'' +
|
'' + # Then we `niv add` that repo and check some properties, like the revision
|
||||||
|
# and revCount, to make sure it was imported properly, and that sources.nix
|
||||||
|
# does what it's supposed to do.
|
||||||
|
''
|
||||||
|
nivdir=$(mktemp -d)
|
||||||
|
pushd $nivdir > /dev/null
|
||||||
|
mkdir -p nix
|
||||||
|
echo "{}" > nix/sources.json
|
||||||
|
niv init
|
||||||
|
niv add git -n my-git-repo --repo file://$gitdir
|
||||||
|
nivrev=$(nix eval --json '(import ./nix/sources.nix).my-git-repo.rev' | jq -r)
|
||||||
|
if [ ! "$gitrev" = "$nivrev" ]; then
|
||||||
|
echo "Mismatched revs: $gitrev != $nivrev"
|
||||||
|
exit 42
|
||||||
|
fi
|
||||||
|
|
||||||
# Then we `niv add` that repo and check some properties, like the revision
|
# here we cheat a bit and use "outPath", which actually is the result of
|
||||||
# and revCount, to make sure it was imported properly, and that sources.nix
|
# builtins.fetchGit.
|
||||||
# does what it's supposed to do.
|
nivnixrev=$(nix eval --json '(import ./nix/sources.nix).my-git-repo.outPath.rev' | jq -r)
|
||||||
''
|
if [ ! "$gitrev" = "$nivnixrev" ]; then
|
||||||
nivdir=$(mktemp -d)
|
echo "Mismatched revs: $gitrev != $nivnixrev"
|
||||||
pushd $nivdir > /dev/null
|
exit 42
|
||||||
mkdir -p nix
|
fi
|
||||||
echo "{}" > nix/sources.json
|
nivnixrevcount=$(nix eval --json '(import ./nix/sources.nix).my-git-repo.outPath.revCount')
|
||||||
niv init
|
if [ ! "1" -eq "$nivnixrevcount" ]; then
|
||||||
niv add git -n my-git-repo --repo file://$gitdir
|
echo "Mismatched revCount: 1 != $nivnixrevcount"
|
||||||
nivrev=$(nix eval --json '(import ./nix/sources.nix).my-git-repo.rev' | jq -r)
|
exit 42
|
||||||
if [ ! "$gitrev" = "$nivrev" ]; then
|
fi
|
||||||
echo "Mismatched revs: $gitrev != $nivrev"
|
|
||||||
exit 42
|
|
||||||
fi
|
|
||||||
|
|
||||||
# here we cheat a bit and use "outPath", which actually is the result of
|
niv update my-git-repo -a ref=branch
|
||||||
# builtins.fetchGit.
|
nivrev2=$(nix eval --json '(import ./nix/sources.nix).my-git-repo.rev' | jq -r)
|
||||||
nivnixrev=$(nix eval --json '(import ./nix/sources.nix).my-git-repo.outPath.rev' | jq -r)
|
if [ ! "$gitrev2" = "$nivrev2" ]; then
|
||||||
if [ ! "$gitrev" = "$nivnixrev" ]; then
|
echo "Mismatched revs: $gitrev2 != $nivrev2"
|
||||||
echo "Mismatched revs: $gitrev != $nivnixrev"
|
exit 42
|
||||||
exit 42
|
fi
|
||||||
fi
|
|
||||||
nivnixrevcount=$(nix eval --json '(import ./nix/sources.nix).my-git-repo.outPath.revCount')
|
|
||||||
if [ ! "1" -eq "$nivnixrevcount" ]; then
|
|
||||||
echo "Mismatched revCount: 1 != $nivnixrevcount"
|
|
||||||
exit 42
|
|
||||||
fi
|
|
||||||
|
|
||||||
niv update my-git-repo -a ref=branch
|
popd > /dev/null
|
||||||
nivrev2=$(nix eval --json '(import ./nix/sources.nix).my-git-repo.rev' | jq -r)
|
|
||||||
if [ ! "$gitrev2" = "$nivrev2" ]; then
|
|
||||||
echo "Mismatched revs: $gitrev2 != $nivrev2"
|
|
||||||
exit 42
|
|
||||||
fi
|
|
||||||
|
|
||||||
popd > /dev/null
|
touch $out
|
||||||
|
''
|
||||||
touch $out
|
|
||||||
''
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user