Skip to content

Commit

Permalink
fix: correct weird bug in nix build when in devShell
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Nützi <[email protected]>
  • Loading branch information
gabyx committed Jul 6, 2024
1 parent 5372833 commit e2a92c9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
38 changes: 18 additions & 20 deletions .github/workflows/normal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ jobs:
- name: Setup Git & Cache Nix
run: |
./tools/ci/setup-git.sh
just nix-develop echo "Built cache."
just nix-develop-ci echo "Built cache."
- name: Format
run: |
just nix-develop just format
just nix-develop-ci just format
lint:
runs-on: ubuntu-latest
Expand All @@ -62,16 +62,16 @@ jobs:
- name: Setup Git & Cache Nix
run: |
./tools/ci/setup-git.sh
just nix-develop echo "Built cache."
just nix-develop-ci echo "Built cache."
- name: Lint
run: |
just nix-develop just lint
just nix-develop-ci just lint
- name: Lint Undefined-Behavior
continue-on-error: true
run: |
just nix-develop just lint-ub
just nix-develop-ci just lint-ub
- name: Allow to fail
if: failure()
Expand All @@ -90,14 +90,14 @@ jobs:
- name: Setup Git & Cache Nix
run: |
./tools/ci/setup-git.sh
just nix-develop echo "Built cache."
just nix-develop-ci echo "Built cache."
- name: build
run: |
just nix-develop just build
just nix-develop-ci just build
- name: tests
run: |
just nix-develop just test
just nix-develop-ci just test
test:
runs-on: ubuntu-latest
Expand All @@ -112,11 +112,11 @@ jobs:
- name: Setup Git & Cache Nix
run: |
./tools/ci/setup-git.sh
just nix-develop git --version
just nix-develop-ci git --version
- name: Test
run: |
just nix-develop just test
just nix-develop-ci just test
package:
runs-on: ubuntu-latest
Expand All @@ -134,17 +134,15 @@ jobs:
- name: Setup Git
run: |
./tools/ci/setup-git.sh
just nix-develop echo "Built cache."
just nix-develop-ci echo "Built cache."
- name: Build package (nix)
run: |
just nix-package
just nix-develop-ci nix-package
- name: Build container image (nix)
run: |
# TODO: This seems to error out into
# rdf-protect-base.json> variable $src or $srcs should point to the source
just nix-develop just nix-image
just nix-develop-ci just nix-image
deploy:
runs-on: ubuntu-latest
Expand All @@ -164,20 +162,20 @@ jobs:
- name: Setup Git & Nix Cache
run: |
./tools/ci/setup-git.sh
just nix-develop echo "Built cache."
just nix-develop-ci echo "Built cache."
- name: Create version tag (if release)
run: |
just nix-develop ./tools/ci/assert-tag.sh "$GITHUB_REF"
just nix-develop-ci ./tools/ci/assert-tag.sh "$GITHUB_REF"
- name: Build container image (nix)
run: |
just nix-develop just nix-image
just nix-develop-ci just nix-image
- name: Push image (if release)
run: |
just nix-develop tools/ci/upload-image.sh
just nix-develop-ci tools/ci/upload-image.sh
- name: Push tag (if release)
run: |
just nix-develop ./tools/ci/assert-tag.sh --push "$GITHUB_REF"
just nix-develop-ci ./tools/ci/assert-tag.sh --push "$GITHUB_REF"
6 changes: 6 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ nix-develop *args:
{ [ -n "${cmd:-}" ] || cmd=("zsh"); } && \
nix develop ./tools/nix#default --command "${cmd[@]}"

nix-develop-ci *args:
cd "{{root_dir}}" && \
cmd=("$@") && \
{ [ -n "${cmd:-}" ] || cmd=("zsh"); } && \
nix develop ./tools/nix#ci --command "${cmd[@]}"

## Standard stuff =============================================================
# Format the code.
format *args:
Expand Down
12 changes: 12 additions & 0 deletions tools/nix/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@
inherit buildInputs;
nativeBuildInputs = nativeBuildInputsBasic ++ nativeBuildInputsDev;
};

ci = mkShell {
inherit buildInputs;
nativeBuildInputs = nativeBuildInputsBasic ++ nativeBuildInputsDev;

# Due to some weird handling of TMPDIR inside containers:
# https://github.com/NixOS/nix/issues/8355
# We have to reset the TMPDIR to make `nix build` work inside
# a development shell.
# Without `nix develop` it works.
shellHook = "unset TMPDIR";
};
};

packages = {
Expand Down

0 comments on commit e2a92c9

Please sign in to comment.