Compare commits

..
Author SHA1 Message Date
Théophane Hufschmitt 64472c58e2 Dynamically set the runners
Only use the Cirrus runners on NixOS/nix since forks won't have access
to them
2024-04-22 17:24:54 +02:00
Théophane HufschmittandFedor Korotkov 2a633da236 Enable the Cirrus builders for the CI
https://cirruslabs.org/ kindly provided us with four beefy CI runners,
so use them for our CI.

In addition to making the builds way faster, these also allow us to test
on aach64-linux, which is quite welcome.

Co-Authored-By: Fedor Korotkov <fedor.korotkov@gmail.com>
2024-04-22 16:56:49 +02:00
15 changed files with 125 additions and 254 deletions

No files matched your search

+38 -32
View File
@@ -8,12 +8,36 @@ permissions: read-all
jobs:
setup_github_env:
permissions:
contents: none
name: Check Cachix and Docker secrets present for installer tests
runs-on: ubuntu-latest
outputs:
cachix: ${{ steps.secret.outputs.cachix }}
docker: ${{ steps.secret.outputs.docker }}
runners: ${{ steps.secret.outputs.runners }}
steps:
- name: Check for secrets
id: secret
env:
_CACHIX_SECRETS: ${{ secrets.CACHIX_SIGNING_KEY }}${{ secrets.CACHIX_AUTH_TOKEN }}
_DOCKER_SECRETS: ${{ secrets.DOCKERHUB_USERNAME }}${{ secrets.DOCKERHUB_TOKEN }}
run: |
echo "::set-output name=cachix::${{ env._CACHIX_SECRETS != '' }}"
echo "::set-output name=docker::${{ env._DOCKER_SECRETS != '' }}"
if [[ ${{ github.repository }} == "NixOS/nix" ]]; then
echo 'runners=["ghcr.io/cirruslabs/ubuntu-runner-arm64:22.04-md", "ghcr.io/cirruslabs/ubuntu-runner-amd64:22.04-md", "ghcr.io/cirruslabs/macos-runner:sonoma"]' >> "$GITHUB_OUTPUT"
else
echo 'runners=["ubuntu-latest", "macos-latest"]' >> "$GITHUB_OUTPUT"
fi
tests:
needs: [check_secrets]
needs: [setup_github_env]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: ${{ fromJSON(needs.setup_github_env.outputs.runners) }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
@@ -26,35 +50,17 @@ jobs:
extra_nix_config: "sandbox = true"
- run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
- uses: cachix/cachix-action@v14
if: needs.check_secrets.outputs.cachix == 'true'
if: needs.setup_github_env.outputs.cachix == 'true'
with:
name: '${{ env.CACHIX_NAME }}'
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix --experimental-features 'nix-command flakes' flake check -L
check_secrets:
permissions:
contents: none
name: Check Cachix and Docker secrets present for installer tests
runs-on: ubuntu-latest
outputs:
cachix: ${{ steps.secret.outputs.cachix }}
docker: ${{ steps.secret.outputs.docker }}
steps:
- name: Check for secrets
id: secret
env:
_CACHIX_SECRETS: ${{ secrets.CACHIX_SIGNING_KEY }}${{ secrets.CACHIX_AUTH_TOKEN }}
_DOCKER_SECRETS: ${{ secrets.DOCKERHUB_USERNAME }}${{ secrets.DOCKERHUB_TOKEN }}
run: |
echo "::set-output name=cachix::${{ env._CACHIX_SECRETS != '' }}"
echo "::set-output name=docker::${{ env._DOCKER_SECRETS != '' }}"
installer:
needs: [tests, check_secrets]
if: github.event_name == 'push' && needs.check_secrets.outputs.cachix == 'true'
runs-on: ubuntu-latest
needs: [tests, setup_github_env]
if: github.event_name == 'push' && needs.setup_github_env.outputs.cachix == 'true'
runs-on: ghcr.io/cirruslabs/ubuntu-runner-amd64:22.04-md
outputs:
installerURL: ${{ steps.prepare-installer.outputs.installerURL }}
steps:
@@ -74,12 +80,12 @@ jobs:
run: scripts/prepare-installer-for-github-actions
installer_test:
needs: [installer, check_secrets]
if: github.event_name == 'push' && needs.check_secrets.outputs.cachix == 'true'
needs: [installer, setup_github_env]
if: github.event_name == 'push' && needs.setup_github_env.outputs.cachix == 'true'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: ["ghcr.io/cirruslabs/ubuntu-runner-arm64:22.04-md", "ghcr.io/cirruslabs/ubuntu-runner-amd64:22.04-md", "ghcr.io/cirruslabs/macos-runner:sonoma"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
@@ -100,15 +106,15 @@ jobs:
- run: exec bash -c "nix-channel --update && nix-env -iA nixpkgs.hello && hello"
docker_push_image:
needs: [check_secrets, tests]
needs: [setup_github_env, tests]
permissions:
contents: read
packages: write
if: >-
github.event_name == 'push' &&
github.ref_name == 'master' &&
needs.check_secrets.outputs.cachix == 'true' &&
needs.check_secrets.outputs.docker == 'true'
needs.setup_github_env.outputs.cachix == 'true' &&
needs.setup_github_env.outputs.docker == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -120,7 +126,7 @@ jobs:
- run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
- run: echo NIX_VERSION="$(nix --experimental-features 'nix-command flakes' eval .\#default.version | tr -d \")" >> $GITHUB_ENV
- uses: cachix/cachix-action@v14
if: needs.check_secrets.outputs.cachix == 'true'
if: needs.setup_github_env.outputs.cachix == 'true'
with:
name: '${{ env.CACHIX_NAME }}'
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
@@ -161,7 +167,7 @@ jobs:
docker push $IMAGE_ID:master
vm_tests:
runs-on: ubuntu-22.04
runs-on: ghcr.io/cirruslabs/ubuntu-runner-amd64:22.04
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
-11
View File
@@ -317,17 +317,6 @@ case "$host_os" in
[CXXFLAGS="$LIBSECCOMP_CFLAGS $CXXFLAGS"])
have_seccomp=1
AC_DEFINE([HAVE_SECCOMP], [1], [Whether seccomp is available and should be used for sandboxing.])
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([[
#include <seccomp.h>
#ifndef __SNR_fchmodat2
# error "Missing support for fchmodat2"
#endif
]])
], [], [
echo "libseccomp is missing __SNR_fchmodat2. Please provide libseccomp 2.5.5 or later"
exit 1
])
else
have_seccomp=
fi
@@ -0,0 +1,13 @@
---
synopsis: "`nix eval` prints derivations as `.drv` paths"
prs: 10200
---
`nix eval` will now print derivations as their `.drv` paths, rather than as
attribute sets. This makes commands like `nix eval nixpkgs#bash` terminate
instead of infinitely looping into recursive self-referential attributes:
```ShellSession
$ nix eval nixpkgs#bash
«derivation /nix/store/m32cbgbd598f4w299g0hwyv7gbw6rqcg-bash-5.2p26.drv»
```
+8
View File
@@ -0,0 +1,8 @@
---
synopsis: Remove experimental repl-flake
significance: significant
issues: 10103
prs: 10299
---
The `repl-flake` experimental feature has been removed. The `nix repl` command now works like the rest of the new CLI in that `nix repl {path}` now tries to load a flake at `{path}` (or fails if the `flakes` experimental feature isn't enabled).*
-1
View File
@@ -122,7 +122,6 @@
- [C++ style guide](contributing/cxx.md)
- [Releases](release-notes/index.md)
{{#include ./SUMMARY-rl-next.md}}
- [Release 2.22 (2024-04-23)](release-notes/rl-2.22.md)
- [Release 2.21 (2024-03-11)](release-notes/rl-2.21.md)
- [Release 2.20 (2024-01-29)](release-notes/rl-2.20.md)
- [Release 2.19 (2023-11-17)](release-notes/rl-2.19.md)
-21
View File
@@ -1,21 +0,0 @@
# Release 2.22.0 (2024-04-23)
### Significant changes
- Remove experimental repl-flake [#10103](https://github.com/NixOS/nix/issues/10103) [#10299](https://github.com/NixOS/nix/pull/10299)
The `repl-flake` experimental feature has been removed. The `nix repl` command now works like the rest of the new CLI in that `nix repl {path}` now tries to load a flake at `{path}` (or fails if the `flakes` experimental feature isn't enabled).
### Other changes
- `nix eval` prints derivations as `.drv` paths [#10200](https://github.com/NixOS/nix/pull/10200)
`nix eval` will now print derivations as their `.drv` paths, rather than as
attribute sets. This makes commands like `nix eval nixpkgs#bash` terminate
instead of infinitely looping into recursive self-referential attributes:
```ShellSession
$ nix eval nixpkgs#bash
«derivation /nix/store/m32cbgbd598f4w299g0hwyv7gbw6rqcg-bash-5.2p26.drv»
```
+3 -3
View File
@@ -26,7 +26,7 @@
inherit (nixpkgs) lib;
inherit (lib) fileset;
officialRelease = true;
officialRelease = false;
version = lib.fileContents ./.version + versionSuffix;
versionSuffix =
@@ -183,7 +183,7 @@
nix =
let
officialRelease = true;
officialRelease = false;
versionSuffix =
if officialRelease
then ""
@@ -195,7 +195,7 @@
stdenv
versionSuffix
;
officialRelease = true;
officialRelease = false;
boehmgc = final.boehmgc-nix;
libgit2 = final.libgit2-nix;
busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell;
+1 -8
View File
@@ -1,5 +1,4 @@
{ lib
, fetchurl
, stdenv
, releaseTools
, autoconf-archive
@@ -249,13 +248,7 @@ in {
] ++ lib.optionals buildUnitTests [
gtest
rapidcheck
] ++ lib.optional stdenv.isLinux (libseccomp.overrideAttrs (_: rec {
version = "2.5.5";
src = fetchurl {
url = "https://github.com/seccomp/libseccomp/releases/download/v${version}/libseccomp-${version}.tar.gz";
hash = "sha256-JIosik2bmFiqa69ScSw0r+/PnJ6Ut23OAsHJqiX7M3U=";
};
}))
] ++ lib.optional stdenv.isLinux libseccomp
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid
# There have been issues building these dependencies
++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform && (stdenv.isLinux || stdenv.isDarwin))
+1
View File
@@ -22,6 +22,7 @@
#include "experimental-features.hh"
using namespace nix;
using namespace nix::unix;
using std::cin;
static void handleAlarm(int sig) {
+3 -31
View File
@@ -5,26 +5,10 @@
namespace nix {
/**
* Open (possibly create) a lock file and return the file descriptor.
* -1 is returned if create is false and the lock could not be opened
* because it doesn't exist. Any other error throws an exception.
*/
AutoCloseFD openLockFile(const Path & path, bool create);
/**
* Delete an open lock file.
*/
void deleteLockFile(const Path & path, Descriptor desc);
enum LockType { ltRead, ltWrite, ltNone };
bool lockFile(Descriptor desc, LockType lockType, bool wait);
class PathLocks
{
private:
typedef std::pair<Descriptor, Path> FDPair;
typedef std::pair<int, Path> FDPair;
std::list<FDPair> fds;
bool deletePaths;
@@ -40,18 +24,6 @@ public:
void setDeletion(bool deletePaths);
};
struct FdLock
{
Descriptor desc;
bool acquired = false;
FdLock(Descriptor desc, LockType lockType, bool wait, std::string_view waitMsg);
~FdLock()
{
if (acquired)
lockFile(desc, ltNone, false);
}
};
}
#include "pathlocks-impl.hh"
+2
View File
@@ -9,6 +9,8 @@
namespace nix {
using namespace nix::unix;
#if __linux__
static std::vector<gid_t> get_group_list(const char *username, gid_t group_id)
+38
View File
@@ -0,0 +1,38 @@
#pragma once
///@file
#include "file-descriptor.hh"
namespace nix::unix {
/**
* Open (possibly create) a lock file and return the file descriptor.
* -1 is returned if create is false and the lock could not be opened
* because it doesn't exist. Any other error throws an exception.
*/
AutoCloseFD openLockFile(const Path & path, bool create);
/**
* Delete an open lock file.
*/
void deleteLockFile(const Path & path, int fd);
enum LockType { ltRead, ltWrite, ltNone };
bool lockFile(int fd, LockType lockType, bool wait);
struct FdLock
{
int fd;
bool acquired = false;
FdLock(int fd, LockType lockType, bool wait, std::string_view waitMsg);
~FdLock()
{
if (acquired)
lockFile(fd, ltNone, false);
}
};
}
+13 -11
View File
@@ -14,7 +14,9 @@
namespace nix {
AutoCloseFD openLockFile(const Path & path, bool create)
using namespace nix::unix;
AutoCloseFD unix::openLockFile(const Path & path, bool create)
{
AutoCloseFD fd;
@@ -26,20 +28,20 @@ AutoCloseFD openLockFile(const Path & path, bool create)
}
void deleteLockFile(const Path & path, Descriptor desc)
void unix::deleteLockFile(const Path & path, int fd)
{
/* Get rid of the lock file. Have to be careful not to introduce
races. Write a (meaningless) token to the file to indicate to
other processes waiting on this lock that the lock is stale
(deleted). */
unlink(path.c_str());
writeFull(desc, "d");
writeFull(fd, "d");
/* Note that the result of unlink() is ignored; removing the lock
file is an optimisation, not a necessity. */
}
bool lockFile(Descriptor desc, LockType lockType, bool wait)
bool unix::lockFile(int fd, LockType lockType, bool wait)
{
int type;
if (lockType == ltRead) type = LOCK_SH;
@@ -48,7 +50,7 @@ bool lockFile(Descriptor desc, LockType lockType, bool wait)
else abort();
if (wait) {
while (flock(desc, type) != 0) {
while (flock(fd, type) != 0) {
checkInterrupt();
if (errno != EINTR)
throw SysError("acquiring/releasing lock");
@@ -56,7 +58,7 @@ bool lockFile(Descriptor desc, LockType lockType, bool wait)
return false;
}
} else {
while (flock(desc, type | LOCK_NB) != 0) {
while (flock(fd, type | LOCK_NB) != 0) {
checkInterrupt();
if (errno == EWOULDBLOCK) return false;
if (errno != EINTR)
@@ -147,16 +149,16 @@ void PathLocks::unlock()
}
FdLock::FdLock(Descriptor desc, LockType lockType, bool wait, std::string_view waitMsg)
: desc(desc)
FdLock::FdLock(int fd, LockType lockType, bool wait, std::string_view waitMsg)
: fd(fd)
{
if (wait) {
if (!lockFile(desc, lockType, false)) {
if (!lockFile(fd, lockType, false)) {
printInfo("%s", waitMsg);
acquired = lockFile(desc, lockType, true);
acquired = lockFile(fd, lockType, true);
}
} else
acquired = lockFile(desc, lockType, false);
acquired = lockFile(fd, lockType, false);
}
+2
View File
@@ -0,0 +1,2 @@
#pragma once
///@file Needed because Unix-specific counterpart
+3 -136
View File
@@ -1,149 +1,16 @@
#include "logging.hh"
#include "pathlocks.hh"
#include "signals.hh"
#include "util.hh"
#include <errhandlingapi.h>
#include <fileapi.h>
#include <windows.h>
#include "windows-error.hh"
namespace nix {
void deleteLockFile(const Path & path, Descriptor desc)
bool PathLocks::lockPaths(const PathSet & _paths, const std::string & waitMsg, bool wait)
{
int exit = DeleteFileA(path.c_str());
if (exit == 0)
warn("%s: &s", path, std::to_string(GetLastError()));
return true;
}
void PathLocks::unlock()
{
for (auto & i : fds) {
if (deletePaths)
deleteLockFile(i.second, i.first);
if (CloseHandle(i.first) == -1)
printError("error (ignored): cannot close lock file on '%1%'", i.second);
debug("lock released on '%1%'", i.second);
}
fds.clear();
}
AutoCloseFD openLockFile(const Path & path, bool create)
{
AutoCloseFD desc = CreateFileA(
path.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
create ? OPEN_ALWAYS : OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_POSIX_SEMANTICS, NULL);
if (desc.get() == INVALID_HANDLE_VALUE)
warn("%s: %s", path, std::to_string(GetLastError()));
return desc;
}
bool lockFile(Descriptor desc, LockType lockType, bool wait)
{
switch (lockType) {
case ltNone: {
OVERLAPPED ov = {0};
if (!UnlockFileEx(desc, 0, 2, 0, &ov)) {
WinError winError("Failed to unlock file desc %s", desc);
throw winError;
}
return true;
}
case ltRead: {
OVERLAPPED ov = {0};
if (!LockFileEx(desc, wait ? 0 : LOCKFILE_FAIL_IMMEDIATELY, 0, 1, 0, &ov)) {
WinError winError("Failed to lock file desc %s", desc);
if (winError.lastError == ERROR_LOCK_VIOLATION)
return false;
throw winError;
}
ov.Offset = 1;
if (!UnlockFileEx(desc, 0, 1, 0, &ov)) {
WinError winError("Failed to unlock file desc %s", desc);
if (winError.lastError != ERROR_NOT_LOCKED)
throw winError;
}
return true;
}
case ltWrite: {
OVERLAPPED ov = {0};
ov.Offset = 1;
if (!LockFileEx(desc, LOCKFILE_EXCLUSIVE_LOCK | (wait ? 0 : LOCKFILE_FAIL_IMMEDIATELY), 0, 1, 0, &ov)) {
WinError winError("Failed to lock file desc %s", desc);
if (winError.lastError == ERROR_LOCK_VIOLATION)
return false;
throw winError;
}
ov.Offset = 0;
if (!UnlockFileEx(desc, 0, 1, 0, &ov)) {
WinError winError("Failed to unlock file desc %s", desc);
if (winError.lastError != ERROR_NOT_LOCKED)
throw winError;
}
return true;
}
default:
assert(false);
}
}
bool PathLocks::lockPaths(const PathSet & paths, const std::string & waitMsg, bool wait)
{
assert(fds.empty());
for (auto & path : paths) {
checkInterrupt();
Path lockPath = path + ".lock";
debug("locking path '%1%'", path);
AutoCloseFD fd;
while (1) {
fd = openLockFile(lockPath, true);
if (!lockFile(fd.get(), ltWrite, false)) {
if (wait) {
if (waitMsg != "")
printError(waitMsg);
lockFile(fd.get(), ltWrite, true);
} else {
unlock();
return false;
}
}
debug("lock aquired on '%1%'", lockPath);
struct _stat st;
if (_fstat(fromDescriptorReadOnly(fd.get()), &st) == -1)
throw SysError("statting lock file '%1%'", lockPath);
if (st.st_size != 0)
debug("open lock file '%1%' has become stale", lockPath);
else
break;
}
fds.push_back(FDPair(fd.release(), lockPath));
}
return true;
}
FdLock::FdLock(Descriptor desc, LockType lockType, bool wait, std::string_view waitMsg)
: desc(desc)
{
if (wait) {
if (!lockFile(desc, lockType, false)) {
printInfo("%s", waitMsg);
acquired = lockFile(desc, lockType, true);
}
} else
acquired = lockFile(desc, lockType, false);
warn("PathLocks::unlock: not yet implemented");
}
}