From fa4f6748533a229216f9239ab4bc17500c2dfaf1 Mon Sep 17 00:00:00 2001 From: Hung Date: Thu, 23 Mar 2023 13:49:13 -0700 Subject: [PATCH] add upload to cache --- flake.lock | 24 ++++++++++++------------ flake.nix | 2 -- nix-conf/home-manager/hwtr/nix.conf | 1 + scripts/hm-switch.sh | 5 +++-- scripts/upload-to-cache.sh | 11 +++++++++++ 5 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 scripts/upload-to-cache.sh diff --git a/flake.lock b/flake.lock index 885c6b0..ade82ac 100644 --- a/flake.lock +++ b/flake.lock @@ -287,11 +287,11 @@ }, "locked": { "dir": "contrib", - "lastModified": 1679453843, - "narHash": "sha256-A5K608V6vAgWyqf6Q4pUWXsDJZ8K+cxSvegbUcdmSbg=", + "lastModified": 1679556473, + "narHash": "sha256-1kABkonN3VFGTUqb5vKCd5vrU182FGKww67KdnZ6QdQ=", "owner": "neovim", "repo": "neovim", - "rev": "a7b537c7a4e5b6114cd75df5178199f4449c6480", + "rev": "ea0b66d208dbcd5d5c0a17810596d769c7a0b6dd", "type": "github" }, "original": { @@ -308,11 +308,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1679472829, - "narHash": "sha256-hcSVMIpuFuAyFEs+7h2fKym0cDUivgdkjm0TjMgEvYo=", + "lastModified": 1679559242, + "narHash": "sha256-2qQlbQPLRLmMgbFsY48qnMmgBlCsN9onqpZHx6DPXG0=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "7a114101d1b72e734fbaba9e523026dd1598bc7e", + "rev": "583c7d315e87975b3a226cafd3ac099b8fdd0b6b", "type": "github" }, "original": { @@ -330,11 +330,11 @@ "rust-overlay": "rust-overlay_2" }, "locked": { - "lastModified": 1679477897, - "narHash": "sha256-QI0YuJskVtEhV+7E7GAi04SYbU7KOQ7PEHLxuam7B40=", + "lastModified": 1679587834, + "narHash": "sha256-x55B7l1Sp/oMrPecwZFcDiqYh1uL+h19nkw274mgKys=", "owner": "tweag", "repo": "nickel", - "rev": "0c9fa8a960ca84bd5fa21a61f52834362a04ad4d", + "rev": "7284ce50a312c0a96b188e4c81e6e258b9521075", "type": "github" }, "original": { @@ -589,11 +589,11 @@ "nixpkgs": "nixpkgs_5" }, "locked": { - "lastModified": 1679451618, - "narHash": "sha256-gWFYRgmeT+8xDYHK4HSuCY9Pi7mSxC+2illHrmDkG7A=", + "lastModified": 1679537973, + "narHash": "sha256-R6borgcKeyMIjjPeeYsfo+mT8UdS+OwwbhhStdCfEjg=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "a89d328ca7d106c3fdbbd072b6c7088ab5b798a3", + "rev": "fbc7ae3f14d32e78c0e8d7865f865cc28a46b232", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 67aa746..28f6851 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,6 @@ nixConfig = { accept-flake-config = true; experimental-features = "nix-command flakes"; - # for darwin's browser - allowUnsupportedSystem = true; max-jobs = 4; }; description = "My personal configuration in Nix (and some native configurations)"; diff --git a/nix-conf/home-manager/hwtr/nix.conf b/nix-conf/home-manager/hwtr/nix.conf index 899ea7a..cd5ea59 100644 --- a/nix-conf/home-manager/hwtr/nix.conf +++ b/nix-conf/home-manager/hwtr/nix.conf @@ -1,3 +1,4 @@ accept-flake-config = true experimental-features = nix-command flakes +post-build-hook = /etc/nix/upload-to-cache.sh diff --git a/scripts/hm-switch.sh b/scripts/hm-switch.sh index 4ee08c7..afc4854 100755 --- a/scripts/hm-switch.sh +++ b/scripts/hm-switch.sh @@ -8,14 +8,15 @@ echo "SCRIPT_DIR: ${SCRIPT_DIR}" HOME_MANAGER_DIR="${SCRIPT_DIR}/../nix-conf/home-manager" # Manage nix.conf. Ideally, this should be done with snapshot-based version -# and with preview on-the-spot, with some timeout +# and with preview on-the-spot, with some timeout (like deploy-rs) if [ -f /etc/nix/nix.conf ]; then # managed nix.conf BACKUP_FILE="/etc/nix/nix.conf.backup" echo "overwriting /etc/nix/nix.conf. Please find latest backup in ${BACKUP_FILE}" sudo cp /etc/nix/nix.conf ${BACKUP_FILE} - sudo cp "${HOME_MANAGER_DIR}/hwtr/nix.conf" /etc/nix/ fi +sudo cp "${HOME_MANAGER_DIR}/hwtr/nix.conf" /etc/nix/ +sudo cp "${SCRIPT_DIR}/upload-to-cache.sh" /etc/nix/ # Mason is bad: it puts binaries onto xdg.data # let's make mason starts fresh, just in case we introduce RPATH hacks diff --git a/scripts/upload-to-cache.sh b/scripts/upload-to-cache.sh new file mode 100644 index 0000000..5c42b4f --- /dev/null +++ b/scripts/upload-to-cache.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -eu +set -f # disable globbing (/nix/store may contain glob chars) +export IFS=' ' + +# $OUT_PATHS when invoked by nix.settings.post-build-hook will be +# space-separated paths to /nix/store/ +echo "Uploading paths" $OUT_PATHS +exec nix copy --to "s3://example-nix-cache" $OUT_PATHS +