diff --git a/flake.lock b/flake.lock index 9edc4dc..dfd6237 100644 --- a/flake.lock +++ b/flake.lock @@ -117,11 +117,11 @@ }, "locked": { "dir": "contrib", - "lastModified": 1659910079, - "narHash": "sha256-U9qnXPloIBYfg1BkfLo/RXwcfwkvCHtf4hoOXSiDVM0=", + "lastModified": 1659977912, + "narHash": "sha256-oEkmHMKRyv8HTJW6f3qFbSiuXdYSE/8eegJgcE5Gs8o=", "owner": "neovim", "repo": "neovim", - "rev": "18766e742bdc8d179ff73b739a530052c9a669e5", + "rev": "e6680ea7c3912d38f2ef967e053be741624633ad", "type": "github" }, "original": { @@ -140,11 +140,11 @@ ] }, "locked": { - "lastModified": 1659946779, - "narHash": "sha256-AAah3A42SRGlKRgyQIuJg3qBk0X2SWuYrLMF9lzCzP4=", + "lastModified": 1660033016, + "narHash": "sha256-LQVgEu5jPPq5e9b+fH1wKE9Sl8iErfqaGHWZcMkzGOE=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "58c6f277bee0907eb2819bf55dc08693b94e667c", + "rev": "1af7c5862b462e0ad938302805efc116548884d1", "type": "github" }, "original": { @@ -160,11 +160,11 @@ ] }, "locked": { - "lastModified": 1659947470, - "narHash": "sha256-fjtOYJWonmQcN9ciw62QYAcr+Tv4+9pUwmWym7yt1w4=", + "lastModified": 1660033736, + "narHash": "sha256-N03jvlh3R8+grynjG/TXGLPc2xQ9P2kSWGwai5w9pPw=", "owner": "nifoc", "repo": "nix-overlay", - "rev": "3cdca066378e09e32bc9b3d9454f334e9c60f694", + "rev": "2cfd669f9c7ec1bc812f483e17fe1854e34f86aa", "type": "github" }, "original": { @@ -175,11 +175,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1659931296, - "narHash": "sha256-MYLvZ1pN2DC79uYoPAoqs7PT5jLaA/I0vTtUUyhdE44=", + "lastModified": 1660017629, + "narHash": "sha256-Koz6/k7c6hx4qVz/bboxdR2QsBdkxjRWpNmsOWJtXZE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "053fb00690945ab06650c4508b98659c6a2343b6", + "rev": "9f15d6c3a74d2778c6e1af67947c95f100dc6fd2", "type": "github" }, "original": { diff --git a/home/hosts/Styx.nix b/home/hosts/Styx.nix index 23bc581..a4b8a21 100644 --- a/home/hosts/Styx.nix +++ b/home/hosts/Styx.nix @@ -1,5 +1,8 @@ -{ pkgs, ... }: +args@{ pkgs, ... }: +let + secret = import ../../secret/hosts/Styx.nix; +in { imports = [ ../programs/fish.nix @@ -13,6 +16,8 @@ ../programs/bat.nix + (import ../programs/custom-nix-cache.nix (args // { inherit secret; })) + ../programs/fzf.nix ../programs/jq.nix diff --git a/home/programs/custom-nix-cache.nix b/home/programs/custom-nix-cache.nix new file mode 100644 index 0000000..3b71a6d --- /dev/null +++ b/home/programs/custom-nix-cache.nix @@ -0,0 +1,64 @@ +{ config, lib, secret, ... }: + +let + user-bin-directory = "${config.home.homeDirectory}/.bin"; + cache = secret.nix-cache.nifoc; +in +{ + home.file."${user-bin-directory}/upload-nifoc-nix-cache" = lib.mkIf cache.enabled { + text = '' + #!/usr/bin/env nix-shell + #!nix-shell -i bash -p sqlite + + uncachedHashes=$(echo 'SELECT DISTINCT hashPart FROM NARs WHERE present = 0;' | sudo sqlite3 "${cache.database}") + signingKey="$HOME/.config/nifoc-nix/${cache.signingKey}" + + for uncachedHash in $uncachedHashes; do + storePath=$(readlink -f /nix/store/$uncachedHash-*) + + if [[ $storePath == *"darwin-system"* ]] || + [[ $storePath == *"home-manager-generation"* ]] || + [[ $storePath == *"-etc" ]] || + [[ $storePath == *"-source" ]] || + [[ $storePath == *".drv" ]] || + [[ $storePath == *".drv.chroot" ]] || + [[ $storePath == *".check" ]] || + [[ $storePath == *".lock" ]]; then + continue + fi + + if [ "$1" = "--list" ]; then + echo "$storePath" + else + nix store sign --key-file $signingKey $storePath + + echo "Uploading $storePath ..." + nix copy --to '${cache.s3Url}' $storePath + fi + done + ''; + + executable = true; + }; + + home.file."${config.home.homeDirectory}/.aws/credentials" = lib.mkIf cache.enabled { + text = '' + [nixbldr] + aws_access_key_id=${cache.accessKeyId} + aws_secret_access_key=${cache.secretAccessKey} + ''; + }; + + xdg.configFile."nifoc-nix/${cache.signingKey}" = { + text = cache.signingKeyValue; + }; + + home.activation = lib.mkIf cache.enabled { + customNixCacheActivation = lib.hm.dag.entryAfter [ "writeBoundary" ] '' + echo -n 'Copying AWS configuration: ' + $DRY_RUN_CMD sudo mkdir ${cache.rootDir}/.aws 2> /dev/null + $DRY_RUN_CMD sudo cp "$HOME/.aws/credentials" ${cache.rootDir}/.aws/ + echo 'Done' + ''; + }; +} diff --git a/home/programs/nvim/plugins.nix b/home/programs/nvim/plugins.nix index f1cd2e6..6bf1b02 100644 --- a/home/programs/nvim/plugins.nix +++ b/home/programs/nvim/plugins.nix @@ -3,12 +3,12 @@ { impatient-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { pname = "impatient.nvim"; - version = "2022-08-01"; + version = "2022-08-09"; src = pkgs.fetchFromGitHub { owner = "lewis6991"; repo = "impatient.nvim"; - rev = "4ccbe749ce439fa25d387d459e8c339131cc5d1f"; - sha256 = "1xalimlicn601qfjz5q2dv7khmzf38xn5jy4c0ykiz8zj77yid0a"; + rev = "49f4ed4a96e0dec3425f270001f341f78400fb49"; + sha256 = "06l6d0hrpsh0jxapf2j5d2hf5km5sg8dysxiggz3mhh4f1y5jlhy"; fetchSubmodules = false; }; }; @@ -113,12 +113,12 @@ }; nvim-ts-rainbow = pkgs.vimUtils.buildVimPluginFrom2Nix { pname = "nvim-ts-rainbow"; - version = "2022-08-07"; + version = "2022-08-09"; src = pkgs.fetchFromGitHub { owner = "p00f"; repo = "nvim-ts-rainbow"; - rev = "d16220f825c0521586499fac340b8a5c8b7117b0"; - sha256 = "1x4mfq63z7fxg7cyv2dmhzy7kxq9xgz16cvfj69gxz0mqxmmg3xz"; + rev = "0c19f1eda263a1d44b6741e727fef223886c80a8"; + sha256 = "0n01yfjldf2qcwyzmjpqnrccsy7xax191c26y1zsyahlfxk70ay9"; fetchSubmodules = false; }; }; @@ -135,12 +135,12 @@ }; telescope-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { pname = "telescope.nvim"; - version = "2022-08-04"; + version = "2022-08-09"; src = pkgs.fetchFromGitHub { owner = "nvim-telescope"; repo = "telescope.nvim"; - rev = "4725867ec66b9a0f5e5ad95a1fd94c2f97fa2d2c"; - sha256 = "0i04xvmz6rcpw47922i6sza34zysj0kc4bakm4qzc5xb26nyy243"; + rev = "8f80e821085bdb4583e78ea685e68dc34209d360"; + sha256 = "1m6cw6xgbmx07pnxn351650v53nmmndjwliwwk1fq6gsyiyixxk3"; fetchSubmodules = false; }; }; @@ -395,12 +395,12 @@ }; neoformat = pkgs.vimUtils.buildVimPluginFrom2Nix { pname = "neoformat"; - version = "2022-07-23"; + version = "2022-08-09"; src = pkgs.fetchFromGitHub { owner = "sbdchd"; repo = "neoformat"; - rev = "892be036fa82871f602f20a5245dfd4bc88d2f08"; - sha256 = "17mgv9qr9bn4ajy825yk5zr3cqhdqz113261vckx43sfia4ligbg"; + rev = "202b5082ee973fb6ec2ac04e15386bfd4f12d699"; + sha256 = "1asadm5wqa74p343p2xb0lsx0wfv59w212d26xwap29p3lrcnin2"; fetchSubmodules = false; }; }; @@ -505,12 +505,12 @@ }; toggleterm-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { pname = "toggleterm.nvim"; - version = "2022-08-07"; + version = "2022-08-09"; src = pkgs.fetchFromGitHub { owner = "akinsho"; repo = "toggleterm.nvim"; - rev = "dfce846c609b83feef3786930c5bd7e4bad851ac"; - sha256 = "09bv3cq6nd9dgpx2civ02d3p27vp34kzn0s8lgncqgffx088rcib"; + rev = "623664233bbe305bf7c86060b95670bb1575534d"; + sha256 = "07sb649rw5s5vnf7z3avai4frgswy6cny3lrsa1gckig5v8370z1"; fetchSubmodules = false; }; }; diff --git a/home/programs/scripts/nixpkgs-switch b/home/programs/scripts/nixpkgs-switch index f87ba1e..09febe5 100755 --- a/home/programs/scripts/nixpkgs-switch +++ b/home/programs/scripts/nixpkgs-switch @@ -31,4 +31,10 @@ set system_new (readlink /run/current-system) nvd diff "$system_old" "$system_new" rm -f result + +if test -e "$HOME/.bin/upload-nifoc-nix-cache" + echo "Updating nifoc-nix-cache ..." + upload-nifoc-nix-cache +end + popd diff --git a/secret/hosts/Styx.nix b/secret/hosts/Styx.nix index 2118ac2..5879c47 100644 Binary files a/secret/hosts/Styx.nix and b/secret/hosts/Styx.nix differ diff --git a/system/hosts/Styx.nix b/system/hosts/Styx.nix index 94b9bf3..e0bd8be 100644 --- a/system/hosts/Styx.nix +++ b/system/hosts/Styx.nix @@ -1,3 +1,10 @@ +{ lib, ... }: + +let + inherit (lib) optionals; + + secret = import ../../secret/hosts/Styx.nix; +in { imports = [ ../darwin/defaults.nix @@ -8,11 +15,15 @@ binaryCaches = [ "https://nix-community.cachix.org" "https://nifoc.cachix.org" + ] ++ optionals secret.nix-cache.nifoc.enabled [ + secret.nix-cache.nifoc.s3Url ]; binaryCachePublicKeys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "nifoc.cachix.org-1:ymuftq7RgN/lf/iWXFK8gpwDSAGFaGBeliWe9u6q8II=" + ] ++ optionals secret.nix-cache.nifoc.enabled [ + secret.nix-cache.nifoc.publicKeyValue ]; trustedUsers = [ diff --git a/system/nixos/arion.nix b/system/nixos/arion.nix index 2b61b31..bfe56e2 100644 --- a/system/nixos/arion.nix +++ b/system/nixos/arion.nix @@ -19,7 +19,6 @@ environment = { WATCHTOWER_POLL_INTERVAL = "28800"; WATCHTOWER_LABEL_ENABLE = "true"; - WATCHTOWER_NO_RESTART = "true"; }; volumes = [ "/var/run/docker.sock:/var/run/docker.sock" ]; };