This Project aims to provide a Github Action and Docker container which automatically builds and pushes nix configurations and packages to an attic instance.
To get up and running with development, you can use the following commands:
nix-shell . #This will install all the necessary dependencies for you
bun install #This will install the bun dependencies for you
bun run build #This will run the script for you which does the building and pushing to attic. BEFORE you run this, fill in your .env file with the envs in the .env.example file
To build the Docker container, run the following command from the root of the project:
docker build . -t attic-builder
BUILD_SYSTEMS
- Set totrue
to build systems,false
to not build systemsBUILD_PACKAGES
- Set totrue
to build packages,false
to not build packagesFLAKE_PATH
- Path to the flake you want to build (if it's not set, the current directory will be used)NO_KEEP_ATTIC_CONF
- Set totrue
to not keep the attic config (usefull if you've changed something in your conf and the config is still in the cache)DONT_FAIL
- Set totrue
to not fail the build if a system fails one or two packages (appends the --keep_going flag to nix-build)MAX_JOBS
- Set to the amount of jobs you want to run in parallel (appends the --max_jobs flag to nix-build)LITTLE_SPACE
- Set totrue
to not fail the build if there is to little diskspace (appends the --fallback flag to nix-build)ONLY_BUILD_SYSTEMS
- Set to only build the specified systems (comma separated list of hostnames)ATTIC_CACHE_URL
- (Required) The URL of the attic instanceATTIC_CACHE_NAME
- (Required) The name of the cache in atticATTIC_CACHE_TOKEN
- (Required) The token to authenticate with the attic instanceLOG_LEVEL
- Set the log level (default: INFO, possible values: DEBUG, INFO, WARNING, ERROR)JSON_LOGGING
- Set totrue
to log in JSON format (default false)
Create .github/workflows/build.yml
in your repo with the following contents:
name: "Build"
on:
push:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: Svenum/attic-builder@v1
with:
build_systems: true
build_packages: true
attic_url: https://attic.example.tld/
attic_cache: CACHENAME
attic_token: ${{ secrets.ATTIC_TOKEN }}
no_keep_attic_conf: false # Optional, set to true to not keep the attic config (usefull if you've changed something in your conf and the config is still in the cache)
dont_fail: false #Optional, set to true to not fail the build if a system fails one or two packages (appends the --keep_going flag to nix-build)
max_jobs: 2 #Optional, set to the amount of jobs you want to run in parallel (appends the --max_jobs flag to nix-build)
only_build_systems: <hostname1>,<hostname2> #Optional, set to only build the specified systems
Setting up Attic is described here: //docs.attic.rs/tutorial.html
atticadm -f /path/to/server.toml --sub 'github' --push 'CACHENAME' --validity '1y'
- On large Flakes the build sometimes is failing cause of 'to little diskspace'
- Workaround: Use self-hosted GitHub runner.
- Creating a Docker Container that automatically fetches one or more Repos and builds it localy periodically
- optionally updating flake with
nix flake update
before run. - Rewrite in pyhton