summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nixos/bnc.nix42
-rw-r--r--nixos/common.nix5
2 files changed, 47 insertions, 0 deletions
diff --git a/nixos/bnc.nix b/nixos/bnc.nix
new file mode 100644
index 0000000..46b6942
--- /dev/null
+++ b/nixos/bnc.nix
@@ -0,0 +1,42 @@
+{ config, pkgs, ... }:
+
+let bnc = pkgs.writeScriptBin "bnc" ''
+ #!${pkgs.bash}/bin/bash
+
+ FULLMODE=0
+ if [ "$1" == "-f" ]; then
+ FULLMODE=1
+ shift 1
+ fi
+
+ source $HOME/.awsrc
+
+ NIXKEY=$(mktemp)
+
+ _cleanup() {
+ echo "---- Cleaning up ----"
+ rm $NIXKEY
+ }
+ trap _cleanup EXIT
+
+ ${pkgs.pass}/bin/pass show deuxfleurs/nix_priv_key > $NIXKEY
+
+ for flake in "$@"; do
+ echo "---- Updating cache for flake ''${flake} ----"
+ if [ "$FULLMODE" = "1" ]; then
+ derivation=$(${pkgs.nix}/bin/nix path-info --derivation "''${flake}")
+ ${pkgs.nix}/bin/nix copy -j8 \
+ --to "s3://nix?endpoint=garage.deuxfleurs.fr&region=garage&secret-key=$NIXKEY" \
+ $(${pkgs.nix}/bin/nix-store -qR ''${derivation})
+ else
+ ${pkgs.nix}/bin/nix copy -j8 \
+ --to "s3://nix?endpoint=garage.deuxfleurs.fr&region=garage&secret-key=$NIXKEY" \
+ "''${flake}"
+ fi
+ done
+
+'';
+in
+{
+ environment.systemPackages = [ bnc ];
+}
diff --git a/nixos/common.nix b/nixos/common.nix
index 6055e25..b8067f7 100644
--- a/nixos/common.nix
+++ b/nixos/common.nix
@@ -7,6 +7,10 @@ let
in
{
+ imports = [
+ ./bnc.nix
+ ];
+
boot.supportedFilesystems = [ "ntfs" ];
boot.cleanTmpDir = true;
@@ -86,6 +90,7 @@ in
vimPlugins.fzf-vim
vimPlugins.nerdtree
nixfmt
+ nix-index
aspell
hunspell
aspellDicts.fr