diff --git a/flake.lock b/flake.lock index 0c9d554..58d64a2 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1694643239, - "narHash": "sha256-pv2k/5FvyirDE8g4TNehzwZ0T4UOMMmqWSQnM/luRtE=", + "lastModified": 1695224363, + "narHash": "sha256-+hfjJLUMck5G92RVFDZA7LWkR3kOxs5zQ7RPW9t3eM8=", "owner": "nix-community", "repo": "home-manager", - "rev": "d9b88b43524db1591fb3d9410a21428198d75d49", + "rev": "408ba13188ff9ce309fa2bdd2f81287d79773b00", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1694710316, - "narHash": "sha256-uRh46iIC86D8BD1wCDA5gRrt+hslUXiD0kx/UjnjBcs=", + "lastModified": 1695109627, + "narHash": "sha256-4rpyoVzmunIG6xWA/EonnSSqC69bDBzciFi6SjBze/0=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "570256327eb6ca6f7bebe8d93af49459092a0c43", + "rev": "cb4dc98f776ddb6af165e6f06b2902efe31ca67a", "type": "github" }, "original": { @@ -35,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1694422566, - "narHash": "sha256-lHJ+A9esOz9vln/3CJG23FV6Wd2OoOFbDeEs4cMGMqc=", + "lastModified": 1694959747, + "narHash": "sha256-CXQ2MuledDVlVM5dLC4pB41cFlBWxRw4tCBsFrq3cRk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3a2786eea085f040a66ecde1bc3ddc7099f6dbeb", + "rev": "970a59bd19eff3752ce552935687100c46e820a5", "type": "github" }, "original": { @@ -51,11 +51,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1694767346, - "narHash": "sha256-5uH27SiVFUwsTsqC5rs3kS7pBoNhtoy9QfTP9BmknGk=", + "lastModified": 1695145219, + "narHash": "sha256-Eoe9IHbvmo5wEDeJXKFOpKUwxYJIOxKUesounVccNYk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ace5093e36ab1e95cb9463863491bee90d5a4183", + "rev": "5ba549eafcf3e33405e5f66decd1a72356632b96", "type": "github" }, "original": { @@ -67,11 +67,11 @@ }, "nur": { "locked": { - "lastModified": 1694814340, - "narHash": "sha256-eo9444JGI/G9jZF+X3xmS5TMRuIT4VYPKyZQ11iF65Q=", + "lastModified": 1695329094, + "narHash": "sha256-IQSMk3jr38WwEV9VvcipUELaqmSpE97XO0KEzLgbOqM=", "owner": "nix-community", "repo": "NUR", - "rev": "9b70f21fd41d3b96580e7ca4a3d1c29e87bdab36", + "rev": "41797d553c8bc067fa3db0681db940b135590ab5", "type": "github" }, "original": { diff --git a/os.sh b/os.sh index b951fce..7a95dbc 100755 --- a/os.sh +++ b/os.sh @@ -1,4 +1,13 @@ +function help() { + echo "Usage: $0 {apply|upgrade|init} [name]" + exit 1 +} + +if [ -z "$1" ]; then + help +fi + ACTION=$1; shift LOCATION=$PWD @@ -14,6 +23,8 @@ function apply() { function upgrade() { if git -C "$LOCATION" diff-index --quiet HEAD --; then nix flake update --commit-lock-file "$LOCATION" + apply $1 + cleanup else echo "Error: git working tree is dirty" exit 1 @@ -21,18 +32,32 @@ function upgrade() { } function cleanup() { + amount=${1:-"7d"} + nix-env --delete-generations "$amount" nix-collect-garbage -d - nixos-store --optimise + nix-store --optimise + nix-store --verify --check-contents --repair +} + +function init() { + mkdir -p "$LOCATION" + git clone "https://github.com/morten-olsen/home-server.git" "$LOCATION" } case $ACTION in + init) + init $1 + ;; apply) apply $1 ;; upgrade) upgrade $1 ;; + cleanup) + cleanup $1 + ;; *) - echo "Usage: $0 {apply}" - exit 1 + help + ;; esac