1
0
Fork 0
nixos-config/lib/update-system.nix

18 lines
655 B
Nix
Raw Normal View History

2020-05-27 13:20:08 +00:00
{ pkgs, nixos-rebuild }:
let configPath = "/etc/nixos";
in {
update-system = pkgs.writeHaskellScript {
2019-07-31 21:56:52 +00:00
name = "update-system";
2020-10-01 00:32:51 +00:00
bins = [ nixos-rebuild pkgs.git ];
2019-07-31 21:56:52 +00:00
} ''
2019-07-25 21:35:59 +00:00
main = do
2020-05-16 14:47:52 +00:00
paths <- myNixPath "${configPath}"
2019-07-28 22:51:10 +00:00
args <- getArgs
2020-10-01 00:32:51 +00:00
privateDeinit :: Either SomeException () <- try $ git "-C" "${configPath}" "submodule" "deinit" "private"
when (isRight privateDeinit) $ do
nixos_rebuild (paths ++ ["build"] ++ remoteBuildParams ++ fmap toString args)
git "-C" "${configPath}" "submodule" "update" "--init" "private"
2020-01-19 16:40:02 +00:00
nixos_rebuild (paths ++ ["switch"] ++ fmap toString args)
2019-07-31 21:56:52 +00:00
'';
2019-08-02 03:17:00 +00:00
}