Add flake app to update primary inputs

This commit is contained in:
Sridhar Ratnakumar 2023-01-02 09:55:19 +05:30
parent 884d21954d
commit 253ebc7254

37
lib.nix
View file

@ -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}
'';
};
};
}