From e2925966a0a65ee7a91fa5ecb9f24a1e5f9798a1 Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Fri, 7 Jan 2022 19:03:31 +0000 Subject: [PATCH] Add script to update system and user --- flake.lock | 12 ++++++------ scripts/aupdate | 13 +++++++++++++ user/daniel/home.nix | 5 +++++ 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100755 scripts/aupdate diff --git a/flake.lock b/flake.lock index f08d379..5cbdbc0 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1639329010, - "narHash": "sha256-k9OXwR06419/s0FAnRalUs24+8EI6GepGaatAXhBc+0=", + "lastModified": 1641459437, + "narHash": "sha256-z0IOcc6LLbVhyri/aTyWzRqJs3p1pBK9idOiMwCWiqs=", "owner": "nix-community", "repo": "home-manager", - "rev": "3d46c011d2cc2c9ca24d9b803e9daf156d9429ea", + "rev": "c751aeb19e84a0a777f36fd5ea73482a066bb406", "type": "github" }, "original": { @@ -57,11 +57,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1639256808, - "narHash": "sha256-RRKWi6grwe5lioKUyfZNQ4ojc5kjUTX55fPNzsGH2PY=", + "lastModified": 1641528457, + "narHash": "sha256-FyU9E63n1W7Ql4pMnhW2/rO9OftWZ37pLppn/c1aisY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e675946ecde5606c505540de2024e2732bae4185", + "rev": "ff377a78794d412a35245e05428c8f95fef3951f", "type": "github" }, "original": { diff --git a/scripts/aupdate b/scripts/aupdate new file mode 100755 index 0000000..aa6491d --- /dev/null +++ b/scripts/aupdate @@ -0,0 +1,13 @@ +#!/bin/sh + +if [ "$UID" -ne 0 ]; then + sudo true # Prompt user for password so it doesn't happen in the middle of the script +fi +pushd ~/.dotfiles +nix flake update + +sudo nixos-rebuild switch --flake .# + +hn=$(hostname) +home-manager switch --flake .#daniel-$hn +popd diff --git a/user/daniel/home.nix b/user/daniel/home.nix index 2bb0f45..7d72ea2 100644 --- a/user/daniel/home.nix +++ b/user/daniel/home.nix @@ -63,6 +63,11 @@ source = ../../scripts/update; executable = true; }; + + "bin/aupdate" = { + source = ../../scripts/aupdate; + executable = true; + }; }; packages = with pkgs; [