Skip to content

Commit

Permalink
chore: remove manual environment configuration step
Browse files Browse the repository at this point in the history
GH actions now have proper Nix with KVM so the extra step of fixup-env
is no longer needed.

Closes #2.
  • Loading branch information
sfc-gh-vtimofeenko committed Mar 22, 2024
1 parent 69a287f commit be92467
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 36 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ machine).
2. Wait for endpoints provisioning to complete (you can monitor the output of
`SHOW ENDPOINTS IN SERVICE <serviceName>`)
3. Open the `ttyd` endpoint URL
4. If using the Nix-based image, run `fixup-env` command to set up the
environment

# Packages in the container

Expand Down
42 changes: 8 additions & 34 deletions packages/ttydContainer/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@
let
pkgs = targetPkgs;

fixUpEnv = pkgs.writeShellApplication {
name = "fixup-env";
runtimeInputs = [ pkgs.shadow ];

meta.description = "Performs post-setup updates in the container allowing to use nix command.";

text = ''
mkdir -p /tmp
${pkgs.dockerTools.shadowSetup}
groupadd -r nixbld
for n in $(seq 1 10); do useradd -c "Nix build user $n" -d /var/empty -g nixbld -G nixbld -M -N -r -s "$(command -v nologin)" "nixbld$n"; done
'';
};

nixConfig = pkgs.stdenv.mkDerivation {
name = "nix-conf";
src = ./.;
Expand Down Expand Up @@ -54,7 +39,7 @@ let
moreutils
;
})
++ [ nixConfig fixUpEnv ];
++ [ nixConfig ];
in
pkgs.dockerTools.buildImage {
name = "ttyd-container";
Expand All @@ -73,25 +58,14 @@ pkgs.dockerTools.buildImage {
}) ++ commonPackages;
};

/* runAsRoot needs nix with `kvm`. This can be achieved with cachix action:
- uses: cachix/install-nix-action@vXX
with:
extra_nix_config: "system-features = nixos-test benchmark big-parallel kvm"
which might need udevadm action:
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
source: https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
# Needs Nix runner with kvm capabilities. GH actions provide one.
runAsRoot = ''
mkdir -p /tmp
TODO: try with cachix and try with det sys action for the magic cache.
*/
# runAsRoot = "";
${pkgs.dockerTools.shadowSetup}
groupadd -r nixbld
for n in $(seq 1 10); do useradd -c "Nix build user $n" -d /var/empty -g nixbld -G nixbld -M -N -r -s "$(command -v nologin)" "nixbld$n"; done
'';

architecture = "amd64";

Expand Down

0 comments on commit be92467

Please sign in to comment.