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

22 lines
698 B
Nix
Raw Normal View History

2019-07-26 15:31:26 +00:00
nixos-rebuild:
2019-07-25 21:35:59 +00:00
let
2019-08-02 03:17:00 +00:00
inherit (import ../lib)
writeHaskellScript get-niv-path home-manager gcRetentionDays pkgs;
in rec {
2019-07-25 21:35:59 +00:00
configPath = "/etc/nixos";
update-system = writeHaskellScript {
2019-07-31 21:56:52 +00:00
name = "update-system";
bins = [ get-niv-path nixos-rebuild ];
} ''
2019-08-13 22:24:38 +00:00
getNivPath name = get_niv_path "${configPath}/nix/sources.nix" name |> captureTrim
2019-07-25 21:35:59 +00:00
2019-07-26 15:31:26 +00:00
getNivAssign name = tag <$> getNivPath name
2020-01-19 16:40:02 +00:00
where tag str = ["-I" :: String, [i|#{name :: String}=#{str :: LByteString}|]]
2019-07-25 21:35:59 +00:00
main = do
paths <- fmap concat . mapM getNivAssign $ ["nixpkgs", "unstable", "home-manager"]
2019-07-28 22:51:10 +00:00
args <- getArgs
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
}