I have the following myapp.nix
:
{ stdenv, pkgs, system }:
stdenv.mkDerivation rec {
name = "myapp";
src = ./.;
enableShared = true;
cmakePreset = {
"x86_64-linux" = "linux";
"x86_64-darwin" = "linux";
"aarch64-darwin" = "osx";
}."${system}";
cmakeFlags = [
"--preset ${cmakePreset}"
];
cmakeBuildType = "Release";
nativeBuildInputs = with pkgs; [ cmake git ninja ];
buildInputs = (with pkgs; [
...
]);
}
My presets looks like this:
{
"version": 9,
"cmakeMinimumRequired": {
"major": 3,
"minor": 30,
"patch": 0
},
"configurePresets": [
{
"name": "common-configure-settings",
"description": "Options and CMake settings common to all configure presets",
"binaryDir": "${sourceDir}/build/${presetName}",
"hidden": true
},
{
"name": "ninja",
"hidden": true,
"generator": "Ninja"
},
{
"name": "linux",
"hidden": false,
"inherits": ["ninja"],
"description": "Build preset for Linux",
"environment": {
"CXX_WARNINGS": "-Wall -Wextra -Werror -pedantic",
"PLATFORM": "POSIX64"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
}
]
}
I’m trying to create an action that builds this app using the following workflow:
name: build-linux
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
packages: read
jobs:
build:
runs-on: ubuntu-latest
if: github.ref_name == 'main'
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: cachix/install-nix-action@v27
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GH_TOKEN }}
- name: Build
working-directory: ${{github.workspace}}
run: nix build
env:
NIX_CONFIG: "access-tokens = github.com=${{ secrets.GH_TOKEN }}"
But it fails with the following message:
-- Build files have been written to: /build/gclqic95fzbdwfkdpff8w41gwgbvn4f1-source/build/linux
cmake: enabled parallel building
cmake: enabled parallel installing
Running phase: buildPhase
@nix { "action": "setPhase", "phase": "buildPhase" }
build flags: -j16
ninja: error: loading 'build.ninja': No such file or directory
How exactly is nix build
working, and how do I tell it where to look for the build files?