zopsicle / crai

Cryogenic Raku Archive Index
https://crai.foldr.nl
1 stars 1 forks source link

Consider using Sparrow/Sparrowdo to deploy/configure crai instance #24

Open melezhik opened 4 years ago

melezhik commented 4 years ago

Hi! I noticed that deploy logic is implemented via Nix expression language with a bit of Raku scenario . Is it intentionally?

I understand that pure declarative style is perfect for package build scenarios, but could be difficult for deployment/CM tasks.

Consider using Sparrowdo/Sparrow alternative. It seems we already have all the bits in place.

For example:

provision of crai instance

sparrowdo ---ssh_host=$cra_instance_ip --sparrowfile=deploy.raku

deploy.raku:


user "crai";

directory "/var/lib/crai", %(
  recursive => 1 ,
  owner => 'crai',
);

systemd-service "caddy", %(
  user => "crai",
  command => "$caddy/bin/caddy -conf $out/etc/Caddyfile"
);

service-start "caddy";
service-enable "caddy";

# So on, you got the idea

copy nix files over rsync

sparrowdo --localhost --nosudo --sparrowfile=copy-files.raku

copy-files.raku:


    # I could write a nice Sparrow task for nix-store queries too, 
   # so far  it's just a plain Raku:
    my @closure = run(<nix-store --query --requisites>,
                      $production, :out).out.lines;

    bash "rsync --archive --compress --ignore-existing --relative --verbose \\
     {@closure.join(' ')} \\
     root@$host:/";

It's just a thought, appreciate your feedback.

melezhik commented 4 years ago

Hi @chloekek any updates here? thanks