Skip to content

Commit

Permalink
Preliminary NixOS rebuilding support
Browse files Browse the repository at this point in the history
Taking pkgs specs of the form:

```
[
  {
    "name": "zlib",
    "version": "1.3@q9jf8xl1gsfmx4f1jhqpdc11yf0w9gv4",
    "distro": "nixos",
    "suite": "core",
    "architecture": "x86_64",
    "input_url": "https://cache.nixos.org/q9jf8xl1gsfmx4f1jhqpdc11yf0w9gv4.narinfo",
    "artifacts": [
      {
        "name": "zlib",
        "version": "1.3",
        "url": "https://cache.nixos.org/nar/1dv9dwz64z347s8b5s78lqrbgdl4xcm0l98zd9cm7jnz1ljd1gjy.nar.xz"
      }
    ]
  }
]
```

Yay:

```
Comparing "/tmp/rebuilderd03zPu6/inputs/1dv9dwz64z347s8b5s78lqrbgdl4xcm0l98zd9cm7jnz1ljd1gjy.nar.xz" with "/tmp/rebuilderd03zPu6/out/1dv9dwz64z347s8b5s78lqrbgdl4xcm0l98zd9cm7jnz1ljd1gjy.nar.xz"
```
  • Loading branch information
raboof committed Nov 1, 2023
1 parent 0fda367 commit cce740a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions contrib/confs/rebuilderd-worker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ path = "/usr/libexec/rebuilderd/rebuilder-debian.sh"

[backend."tails"]
path = "/usr/libexec/rebuilderd/rebuilder-tails.sh"

[backend."nixos"]
path = "/usr/libexec/rebuilderd/rebuilder-nixos.sh"
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ services:
- REBUILDERD_COOKIE_PATH=/secret/auth
volumes:
- ./secret:/secret
worker-nixos:
build:
context: .
dockerfile: worker/Dockerfile.nixos
# number of concurrent workers
scale: 1
init: true
command: ['connect', 'http://daemon:8484']
environment:
- REBUILDERD_COOKIE_PATH=/secret/auth
volumes:
- ./secret:/secret
worker-archlinux:
build:
context: .
Expand Down
16 changes: 16 additions & 0 deletions worker/rebuilder-nixos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -x

echo "Rebuilding $1"
export PATH=/root/.nix-profile/bin:$PATH
whoami

DRV=$(cat $1 | grep StorePath | cut -d ":" -f 2)

REALIZED=$(nix-build --check $DRV)

nix-store --dump $REALIZED > $REBUILDERD_OUTDIR/out.nar
xz $REBUILDERD_OUTDIR/out.nar
HASH=$(nix-hash --base32 --type sha256 --flat $REBUILDERD_OUTDIR/out.nar.xz)
mv $REBUILDERD_OUTDIR/out.nar.xz $REBUILDERD_OUTDIR/$HASH.nar.xz

0 comments on commit cce740a

Please sign in to comment.