Skip to content

Commit

Permalink
clean up by root
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Mar 8, 2024
1 parent c9e06ce commit a77483d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ jobs:
container_name="$(podman ps --sort=created --format {{.Names}} | tail -1)"
[ -n "$container_name" ] # May be fail with bg timing
podman exec --user=user -it "$container_name" /provisioner/needs_systemd.bash
podman exec --user=root -it "$container_name" rm -rf /provisioner/cleanup.bash
podman commit "$container_name" ran-nix-commands-by-user
podman kill "$container_name"
- name: Finalize the image
Expand Down
1 change: 1 addition & 0 deletions containers/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN mkdir -p ~/.local/state/nix/profiles
# Don't use /tmp, it removes in first run
COPY ./ /provisioner/dotfiles/
COPY ./containers/needs_systemd.bash /provisioner/needs_systemd.bash
COPY ./containers/cleanup.bash /provisioner/cleanup.bash

# Should back to original of kachick/ubuntu-nix-systemd, we need to run systemd fist
USER root
Expand Down
8 changes: 8 additions & 0 deletions containers/cleanup.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -euxo pipefail

# Focus to root privilege operations

rm -rf /provisioner/dotfiles
nix store gc
3 changes: 0 additions & 3 deletions containers/needs_systemd.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@ set -euxo pipefail

nix-shell --packages git --command 'git config --global --add safe.directory /provisioner/dotfiles'
nix run '/provisioner/dotfiles#home-manager' -- switch -b backup --flake '/provisioner/dotfiles/#user'

rm -rf /provisioner/dotfiles
nix store gc

0 comments on commit a77483d

Please sign in to comment.