Skip to content

Commit

Permalink
feat(nix): copy paths to cachixe
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 committed Dec 20, 2023
1 parent 703411b commit 3744bb2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
42 changes: 21 additions & 21 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion machines/shared.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{ pkgs, ... }:
let
cachixe = (pkgs.callPackage ../packages/cachixe.nix { });
in
{
imports =
[
Expand Down Expand Up @@ -77,6 +80,7 @@
package = pkgs.nixFlakes;
extraOptions = ''
experimental-features = nix-command flakes
post-build-hook = ${cachixe}/bin/upload-to-cache
'';
settings = {
auto-optimise-store = true;
Expand Down Expand Up @@ -129,7 +133,7 @@
services.cron.enable = true;
services.avahi = {
enable = true;
nssmdns = true;
nssmdns4 = true;
publish = {
enable = true;
domain = true;
Expand Down
22 changes: 22 additions & 0 deletions packages/cachixe.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ stdenv, writeText, ... }:
let
script = writeText "upload-to-cache.sh" ''
#!/bin/sh
set -eu
set -f # disable globbing
export IFS=' '
echo "Uploading paths" $OUT_PATHS
exec nix copy --to "ssh://cachixe.local" $OUT_PATHS
'';
in
stdenv.mkDerivation {
name = "upload-to-cache";
version = "unstable";
dontUnpack = true;

installPhase = ''
mkdir -vp $out/bin
cp ${script} $out/bin/upload-to-cachixe
chmod +x $out/bin/upload-to-cachixe
'';
}

0 comments on commit 3744bb2

Please sign in to comment.