Skip to content
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

[2.3] Add flake for testing purposes #9771

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# A very basic flake to conveniently `nix run nix/2.3` for testing.
# Note that this release has no built-in support for flakes,
# and this flake declaration is provided on a best-effort basis.
outputs = { self, nixpkgs, ... }:
let
inherit (nixpkgs) lib;
inherit (lib) flip genAttrs mapAttrs substring;
rev = self.sourceInfo.rev or self.sourceInfo.dirtyRev or "";
revCount = self.sourceInfo.revCount or 0;
shortRev = self.sourceInfo.shortRev or (substring 0 7 rev);
release = import ./release.nix {
nix = {
outPath = ./.;
inherit rev revCount shortRev;
};
nixpkgs = nixpkgs.outPath;
officialRelease = false;
};
in
{
# inherit release;
packages =
mapAttrs
(system: nix: {
default = nix;
nix = nix;
})
release.build;
apps =
mapAttrs
(system: packages:
let
appFor = mainProgram: {
type = "app";
program = lib.getExe' packages.nix mainProgram;
};
in flip genAttrs appFor [
"nix"
"nix-build"
"nix-channel"
"nix-collect-garbage"
"nix-copy-closure"
"nix-daemon"
"nix-env"
"nix-hash"
"nix-instantiate"
"nix-prefetch-url"
"nix-shell"
"nix-store"
])
self.packages;
};
}

2 changes: 1 addition & 1 deletion tests/add.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ echo $path2
if test "$path1" != "$path2"; then
echo "nix-store --add and --add-fixed mismatch"
exit 1
fi
fi

path3=$(nix-store --add-fixed sha256 ./dummy)
echo $path3
Expand Down
2 changes: 1 addition & 1 deletion tests/check.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ with import ./config.nix;
};

hashmismatch = import <nix/fetchurl.nix> {
url = "file://" + toString ./dummy;
url = "file://" + builtins.getEnv "TMPDIR" + "/dummy";
sha256 = "0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73";
};

Expand Down
4 changes: 2 additions & 2 deletions tests/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ nix-build check.nix -A fetchurl --no-out-link --repair --hashed-mirrors ''
nix-build check.nix -A hashmismatch --no-out-link --hashed-mirrors '' || status=$?
[ "$status" = "102" ]

echo -n > ./dummy
echo -n > $TMPDIR/dummy
nix-build check.nix -A hashmismatch --no-out-link --hashed-mirrors ''
echo 'Hello World' > ./dummy
echo 'Hello World' > $TMPDIR/dummy

nix-build check.nix -A hashmismatch --no-out-link --check --hashed-mirrors '' || status=$?
[ "$status" = "102" ]
Expand Down
Loading