Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre install/uninstall checks to planners #561

Merged

Conversation

Hoverbear
Copy link
Contributor

@Hoverbear Hoverbear commented Jul 10, 2023

Description

Add structured pre install/uninstall planner steps to mitigate users encountering #528.

Testing

ephemeraladmin@mac-epic-turducken ~ % curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/pr/561 | sh -s -- install

ephemeraladmin@mac-epic-turducken ~ % . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh

Create a flake.nix with these contents in some folder (mine is boop, then cd in:

{
  description = "John's darwin system";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-23.05-darwin";
    darwin.url = "github:lnl7/nix-darwin/master";
    darwin.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs@{ self, darwin, nixpkgs }: {
    darwinConfigurations."mac-epic-turducken" = darwin.lib.darwinSystem {
      modules = [(
        { pkgs, ... }:
        {
          # List packages installed in system profile. To search by name, run:
          # $ nix-env -qaP | grep wget
          environment.systemPackages =
            [ pkgs.vim
            ];

          # Auto upgrade nix package and the daemon service.
          services.nix-daemon.enable = true;
          nix.package = pkgs.nix;
          nixpkgs.hostPlatform = "aarch64-darwin";
        }
      )];
    };
  };
}

Doing the rest:

ephemeraladmin@mac-epic-turducken boop % nix build .#darwinConfigurations.mac-epic-turducken.system

ephemeraladmin@mac-epic-turducken boop % printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf

ephemeraladmin@mac-epic-turducken boop % sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t


ephemeraladmin@mac-epic-turducken boop % sudo ./result/sw/bin/darwin-rebuild switch --flake ~/boop               
warning: $HOME ('/Users/ephemeraladmin') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
building the system configuration...
warning: $HOME ('/Users/ephemeraladmin') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
warning: $HOME ('/Users/ephemeraladmin') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
user defaults...
setting up user launchd services...
setting up /Applications/Nix Apps...
setting up pam...
applying patches...
setting up /etc...
error: not linking environment.etc."bashrc" because /etc/bashrc already exists, skipping...
existing file has unknown content 08ffbf991a9e25839d38b80a0d3bce3b5a6c84b9be53a4b68949df4e7e487bb7, move and activate again to apply
error: not linking environment.etc."nix/nix.conf" because /etc/nix/nix.conf already exists, skipping...
existing file has unknown content 9b5b5aedd302e950e450a28d6d42cc087bfd1c40951c4617096b9b12b2007c5f, move and activate again to apply
system defaults...
setting up launchd services...
creating service org.nixos.activate-system
reloading service org.nixos.nix-daemon
reloading nix-daemon...
waiting for nix-daemon
waiting for nix-daemon
configuring networking...

ephemeraladmin@mac-epic-turducken boop % ./nix-installer uninstall
`nix-installer` needs to run as `root`, attempting to escalate now via `sudo`...
`nix-darwin` installation detected, it must be removed before uninstalling Nix. Please refer to https://github.com/LnL7/nix-darwin#uninstalling for instructions how to uninstall `nix-darwin`
Checklist
  • Formatted with cargo fmt
  • Built with nix build
  • Ran flake checks with nix flake check
  • Added or updated relevant tests (leave unchecked if not applicable)
  • Added or updated relevant documentation (leave unchecked if not applicable)
  • Linked to related issues (leave unchecked if not applicable)
Validating with install.determinate.systems

If a maintainer has added the upload to s3 label to this PR, it will become available for installation via install.determinate.systems:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/pr/$PR_NUMBER | sh -s -- install

@Hoverbear Hoverbear requested a review from cole-h July 10, 2023 20:58
@Hoverbear Hoverbear self-assigned this Jul 10, 2023
@Hoverbear Hoverbear added this to the 0.10.1 milestone Jul 10, 2023
@Hoverbear Hoverbear marked this pull request as ready for review July 10, 2023 20:58
@Hoverbear Hoverbear removed the request for review from cole-h July 10, 2023 20:58
@Hoverbear Hoverbear marked this pull request as draft July 10, 2023 20:58
@Hoverbear Hoverbear added the upload to s3 The labeled PR is allowed to upload its artifacts to S3 for easy testing label Jul 11, 2023
@Hoverbear Hoverbear marked this pull request as ready for review July 11, 2023 16:28
@Hoverbear Hoverbear requested a review from cole-h July 11, 2023 16:28
Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upload to s3 The labeled PR is allowed to upload its artifacts to S3 for easy testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants