NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.29k stars 1.48k forks source link

mix mac install assumed gnu diff and other /etc/synthetic.conf issues #7286

Open diekhans opened 1 year ago

diekhans commented 1 year ago

MacOS Ventura, M1 I want to have nix installed under

Steps To Reproduce

Create an /etc/synthetic.conf with /nix

nix       System/Volumes/Data/nix

and reboot then

sh <(curl -L https://nixos.org/nix/install) --daemon

Install then tries to edit out the nix line from synthetic.conf. I don't want it to do this. I don't want a new disk volume, I just want nix in System/Volumes/Data/nix

As part of insisting on edit the file, it calls diff with invalid arguments for MacOs

~~> Fixing any leftover Nix volume state                                                                                                
Before I try to install, I'll check for any existing Nix volume config
and ask for your permission to remove it (so that the installer can
start fresh). I'll also ask for permission to fix any issues I spot.

During install, I add 'nix' to /etc/synthetic.conf, which instructs
macOS to create an empty root directory for mounting the Nix volume.

---- warning! ------------------------------------------------------------------                                                        

/etc/synthetic.conf already contains a line instructing your system
to make '/nix' as a symlink:
    3:nix       System/Volumes/Data/nix

This may mean your system has/had a non-standard Nix install.

The volume-creation process in this installer is *not* compatible
with a symlinked store, so I'll have to remove this instruction to
continue.

If you want/need to keep this instruction, answer 'n' to abort.

Nix isn't the only thing in /var/folders/3k/fvyxn7p97976wmlmtkd7ltfr0000z8/T/tmp.XagVkQCxZv/synthetic.conf.edit,
but I think I know how to edit it out.
Here's the diff:
diff: unrecognized option `--unchanged-group-format=\033[2m%=\033[0m'
usage: diff [-aBbdilpTtw] [-c | -e | -f | -n | -q | -u] [--ignore-case]
            [--no-ignore-case] [--normal] [--strip-trailing-cr] [--tabsize]
            [-I pattern] [-F pattern] [-L label] file1 file2
       diff [-aBbdilpTtw] [-I pattern] [-L label] [--ignore-case]
            [--no-ignore-case] [--normal] [--strip-trailing-cr] [--tabsize]
            [-F pattern] -C number file1 file2
       diff [-aBbdiltw] [-I pattern] [--ignore-case] [--no-ignore-case]
            [--normal] [--strip-trailing-cr] [--tabsize] -D string file1 file2
       diff [-aBbdilpTtw] [-I pattern] [-L label] [--ignore-case]
            [--no-ignore-case] [--normal] [--tabsize] [--strip-trailing-cr]
            [-F pattern] -U number file1 file2
       diff [-aBbdilNPprsTtw] [-c | -e | -f | -n | -q | -u] [--ignore-case]
            [--no-ignore-case] [--normal] [--tabsize] [-I pattern] [-L label]
            [-F pattern] [-S name] [-X file] [-x pattern] dir1 dir2
       diff [-aBbditwW] [--expand-tabs] [--ignore-all-blanks]
            [--ignore-blank-lines] [--ignore-case] [--minimal]
            [--no-ignore-file-name-case] [--strip-trailing-cr]
            [--suppress-common-lines] [--tabsize] [--text] [--width]
            -y | --side-by-side file1 file2
       diff [--help] [--version]
Does the change above look right?                                                                                                       
[y/n] n
abathur commented 1 year ago

As the installer explained, it isn't compatible with a symlinked store. If you want to force it to work for some reason, you'll need to download the install scripts and modify them.

What diff do you have? GNU is what ships with macOS AFAIK. No strong reason not to pin that path down, so I've opened #7288 to do so.

diekhans commented 1 year ago
% /usr/bin/diff --version
Apple diff (based on FreeBSD diff)

It doesn't have --unchanged-group-format

It would be most useful if it was explicitly mentioned that the normal way one does synthetic.conf doesn't work in https://nixos.org/manual/nix/stable/installation/installing-binary.html#macos-installation.

It would be nice if apple support firmlinks by users.

I am sure it has been said before, but it is sad that nix installs in / instead of following the UNIX convention of /opt/. At least you don't splatter all over /usr/local ;-)

thanks!

abathur commented 1 year ago

What macos is this? Ventura? It's possible they swapped it out there and you are just the first report because of the symlink/synthetic.conf

diekhans commented 1 year ago

Yes, Ventura and correct, Big Sur reports:

% /usr/bin/diff --version diff (GNU diffutils) 2.8.1 Copyright (C) 2002 Free Software Foundation, In

abathur commented 1 year ago

Hmm. I guess we'll actually need a different fix, though I'm not quite sure what. I don't have a Ventura to poke at myself yet.

diekhans commented 1 year ago

If you give me something to test, I will try it out for you. The scribbling on / was enough to get me to hold off on investing time in Nix right now, so it is easy for me to reproduce without disrupting anything.

diff.man.txt

abathur commented 1 year ago

Thanks. I don't expect I'll have time to pick at how to adapt the formats for a few days myself. I asked on Matrix in case someone there will be up for taking a look.

pmarreck commented 1 year ago

Running into the exact same issue after upgrading to Ventura. Same diff issue as well. The diff issue can probably be fixed with brew install diffutils; just checked and the diff installed that way does understand that option.

bestlem commented 1 year ago

Any progress on this.

I am having enough issues with nix - that I don't want to have macports or HomeBrew to get a working version.

Although I note that if I just accept the diff output the script seemed to have worked.

abathur commented 1 year ago

Not that I'm aware of