Skip to content

Commit de22e16

Browse files
authored
DETERMINATE_NIX_KVM fixup, support Magic Nix Cache + FlakeHub Cache on Namespace runners (#72)
* Share /bin with nix for post-build-hooks * test the magic nix cache * wtf * permissions * Share /home and the network namespace too * test the devshell * Don't force-set kvm to 0 ... d'oh! * dev shell support for aarch64-linux * ? * More testing / debug * Make it run anyway * Bind /lib too so /bin/sh works ... sigh * Disable gha-cache for tesing * Kill the magic nix cache before reinstalling * Don't set the extra environment variables extraniously * Enable gha cache again
1 parent e279ba5 commit de22e16

File tree

5 files changed

+40
-10
lines changed

5 files changed

+40
-10
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ jobs:
1616
- run: npm run all
1717
- run: git status --porcelain=v1
1818
- run: test $(git status --porcelain=v1 2>/dev/null | wc -l) -eq 0
19-
run-x86_64-linux:
20-
name: Run x86_64 Linux
19+
run-test-suite:
20+
name: Run test suite
2121
strategy:
2222
matrix:
2323
runner:
24-
- ubuntu-latest
25-
- nscloud-ubuntu-22.04-amd64-4x16
26-
- namespace-profile-default-arm64
24+
- ubuntu-latest
25+
- nscloud-ubuntu-22.04-amd64-4x16
26+
- namespace-profile-default-arm64
2727
runs-on: ${{ matrix.runner }}
28+
permissions:
29+
contents: read
30+
id-token: write
2831
steps:
2932
- uses: actions/checkout@v3
3033
- name: Install Nix
@@ -33,8 +36,15 @@ jobs:
3336
logger: pretty
3437
log-directives: nix_installer=trace
3538
backtrace: full
39+
- uses: DeterminateSystems/magic-nix-cache-action@main
3640
- name: echo $PATH
3741
run: echo $PATH
42+
43+
- name: Render the devshell
44+
if: success() || failure()
45+
run: |
46+
nix develop --command date
47+
3848
- name: Test `nix` with `$GITHUB_PATH`
3949
if: success() || failure()
4050
run: |
@@ -43,6 +53,7 @@ jobs:
4353
hello
4454
nix store gc
4555
nix run nixpkgs#hello
56+
4657
- name: Test bash
4758
run: nix-instantiate -E 'builtins.currentTime' --eval
4859
if: success() || failure()
@@ -91,6 +102,9 @@ jobs:
91102
run-x86_64-darwin:
92103
name: Run x86_64 Darwin
93104
runs-on: macos-12
105+
permissions:
106+
contents: read
107+
id-token: write
94108
steps:
95109
- uses: actions/checkout@v3
96110
- name: Install Nix
@@ -99,6 +113,7 @@ jobs:
99113
logger: pretty
100114
log-directives: nix_installer=trace
101115
backtrace: full
116+
- uses: DeterminateSystems/magic-nix-cache-action@main
102117
- name: echo $PATH
103118
run: echo $PATH
104119
- name: Test `nix` with `$GITHUB_PATH`
@@ -135,6 +150,10 @@ jobs:
135150
hello
136151
nix store gc
137152
nix run nixpkgs#hello
153+
- name: Terminate the magic nix cache pre-reinstall
154+
if: success() || failure()
155+
run: |
156+
pkill magic-nix-cache
138157
- name: Reinstall Nix
139158
uses: ./
140159
with:

dist/index.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
outputs = { self, flake-schemas, nixpkgs }:
1111
let
12-
supportedSystems = [ "x86_64-linux" "aarch64-darwin" ];
12+
supportedSystems = [ "x86_64-linux" "aarch64-darwin" "aarch64-linux" "x86_64-darwin" ];
1313
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
1414
pkgs = import nixpkgs { inherit system; };
1515
});

src/main.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,6 @@ class NixInstallerAction {
513513
actions_core.info("KVM is not available.");
514514
actions_core.exportVariable("DETERMINATE_NIX_KVM", "0");
515515
}
516-
517-
actions_core.exportVariable("DETERMINATE_NIX_KVM", "0");
518516
}
519517

520518
// Normal just doing of the install
@@ -587,9 +585,16 @@ class NixInstallerAction {
587585
"run",
588586
"--detach",
589587
"--privileged",
588+
"--network=host",
590589
"--userns=host",
591590
"--pid=host",
592591
"--mount",
592+
"type=bind,src=/bin,dst=/bin,readonly",
593+
"--mount",
594+
"type=bind,src=/lib,dst=/lib,readonly",
595+
"--mount",
596+
"type=bind,src=/home,dst=/home,readonly",
597+
"--mount",
593598
"type=bind,src=/tmp,dst=/tmp",
594599
"--mount",
595600
"type=bind,src=/nix,dst=/nix",

0 commit comments

Comments
 (0)