1
0
Fork 0
mirror of https://github.com/Mic92/sops-nix.git synced 2024-12-14 11:57:52 +00:00

allow for missing switch-to-configuration directory

NixOS' switch-to-configuration program creates the /run/nixos directory,
which may not be present if `system.switch.enable` is `false`.
This commit is contained in:
Jared Baur 2024-11-18 10:08:10 -08:00 committed by mergify[bot]
parent 472741cf3f
commit e39947d0ee

View file

@ -978,6 +978,13 @@ func handleModifications(isDry bool, logcfg loggingConfig, symlinkPath string, s
writeLines := func(list []string, file string) error { writeLines := func(list []string, file string) error {
if len(list) != 0 { if len(list) != 0 {
if _, err := os.Stat(filepath.Dir(file)); err != nil {
if os.IsNotExist(err) {
return nil
} else {
return err
}
}
f, err := os.OpenFile(file, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0o600) f, err := os.OpenFile(file, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0o600)
if err != nil { if err != nil {
return err return err