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

23 lines
775 B
Nix
Raw Normal View History

2020-05-27 13:20:08 +00:00
{ pkgs, nixos-rebuild }:
2021-04-17 16:12:20 +00:00
let
configPath = "/etc/nixos";
in
{
2021-05-18 14:33:28 +00:00
update-system = pkgs.writeHaskellScript
{
name = "update-system";
2021-06-02 00:33:20 +00:00
bins = [ nixos-rebuild pkgs.nix-output-monitor pkgs.nvd ];
2021-05-18 14:33:28 +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-12-16 18:26:20 +00:00
setEnv "WITH_SECRETS" "false"
2021-07-05 16:19:43 +00:00
nix_build (paths ++ buildSystemParams ++ ["--no-out-link"] ++ remoteBuildParams ++ fmap toString args) &!> StdOut |> nom
2020-12-16 18:26:20 +00:00
setEnv "WITH_SECRETS" "true"
2021-04-17 16:12:20 +00:00
oldSystem <- readlink "-f" "/run/current-system" |> captureTrim
nixos_rebuild (paths ++ ["switch"] ++ fmap toString args) &!> StdOut |> nom
2021-04-17 16:12:20 +00:00
newSystem <- readlink "-f" "/run/current-system" |> captureTrim
2021-05-18 16:05:38 +00:00
nvd "diff" oldSystem newSystem
2019-07-31 21:56:52 +00:00
'';
2019-08-02 03:17:00 +00:00
}