From 253ebc725453f6ebff851bab8e8def5710610acf Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Mon, 2 Jan 2023 09:55:19 +0530 Subject: [PATCH] Add flake app to update primary inputs --- lib.nix | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/lib.nix b/lib.nix index 8838dd0..3d244f0 100644 --- a/lib.nix +++ b/lib.nix @@ -56,10 +56,8 @@ }; perSystem = { system, pkgs, lib, ... }: { - # A rough app for activating the system locally. - # - # TODO: Replace with deploy-rs or (new) nixinate - apps.activate = + # TODO: replace these with mission-control + apps = let # Create a flake app that wraps the given bash CLI. bashCmdApp = name: cmd: { @@ -74,14 +72,27 @@ }) + "/bin/${name}"; }; in - if system == "aarch64-darwin" then - bashCmdApp "darwin" '' - ${self.darwinConfigurations.default.system}/sw/bin/darwin-rebuild \ - switch --flake ${self}#default - '' - else - bashCmdApp "linux" '' - ${lib.getExe pkgs.nixos-rebuild} --use-remote-sudo switch -j auto - ''; + { + # A rough app for activating the system locally. + # + # TODO: Replace with deploy-rs or (new) nixinate + activate = + if system == "aarch64-darwin" then + bashCmdApp "darwin" '' + ${self.darwinConfigurations.default.system}/sw/bin/darwin-rebuild \ + switch --flake ${self}#default + '' + else + bashCmdApp "linux" '' + ${lib.getExe pkgs.nixos-rebuild} --use-remote-sudo switch -j auto + ''; + + update-primary = + let inputs = [ "nixpkgs" "home-manager" "darwin" ]; + in bashCmdApp "update-primary" '' + nix flake lock ${lib.foldl' (acc: x: acc + " --update-input " + x) "" inputs} + ''; + + }; }; }