summary refs log tree commit diff
diff options
context:
space:
mode:
authorArtturin <Artturin@artturin.com>2023-09-09 07:15:56 +0300
committerArtturin <Artturin@artturin.com>2023-09-09 07:22:05 +0300
commitf25f2a4209f9f86ce3d795f7531e128476ef9f68 (patch)
tree713746ba9a945d8b22bdaf313c12e3916d620a1b
parent81f2e77b36f44448e81c7156b6205212bd502b10 (diff)
downloadnixpkgs-f25f2a4209f9f86ce3d795f7531e128476ef9f68.tar
nixpkgs-f25f2a4209f9f86ce3d795f7531e128476ef9f68.tar.gz
nixpkgs-f25f2a4209f9f86ce3d795f7531e128476ef9f68.tar.bz2
nixpkgs-f25f2a4209f9f86ce3d795f7531e128476ef9f68.tar.lz
nixpkgs-f25f2a4209f9f86ce3d795f7531e128476ef9f68.tar.xz
nixpkgs-f25f2a4209f9f86ce3d795f7531e128476ef9f68.tar.zst
nixpkgs-f25f2a4209f9f86ce3d795f7531e128476ef9f68.zip
nixos/stage-2-init: dont use install to create /etc/nixos if it's a symlink
it should be checking that it is not a broken symlink but bash
conditionals are difficult

-d was causing the directory to not be created if it does not exist

```
$ install -m 0755 -d $PWD/hello
$ ls
hello/
$ ln -s something notexist
'notexist' -> 'something'
$ ls -l
lrwxrwxrwx artturin artturin 9 B Sat Sep  9 06:59:44 2023 notexist@ ⇒ something
drwxr-xr-x artturin artturin 2 B Sat Sep  9 06:59:36 2023 hello/
$ install -m 0755 -d $PWD/notexist
install: cannot change permissions of ‘/home/artturin/nixgits/my-nixpkgs/test/notexist’: No such file or directory
```
-rwxr-xr-xnixos/modules/system/boot/stage-2-init.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/nixos/modules/system/boot/stage-2-init.sh b/nixos/modules/system/boot/stage-2-init.sh
index c0af29e3b99..5a2133f960e 100755
--- a/nixos/modules/system/boot/stage-2-init.sh
+++ b/nixos/modules/system/boot/stage-2-init.sh
@@ -105,7 +105,7 @@ fi
 
 # Required by the activation script
 install -m 0755 -d /etc
-if [ -d "/etc/nixos" ]; then
+if [ ! -h "/etc/nixos" ]; then
     install -m 0755 -d /etc/nixos
 fi
 install -m 01777 -d /tmp