dustinlyons / nixos-config

General purpose Nix configuration for macOS / NixOS with starter templates + step-by-step guides ✨
BSD 3-Clause "New" or "Revised" License
1.8k stars 113 forks source link

Question [Help] #37

Closed Rafi1018 closed 11 months ago

Rafi1018 commented 11 months ago
  1. I want to dual boot it with windows but it seems Running this will reformat my drive to the ext4 filesystem so what can I do about it ?
  2. What is "secrets" mentioned everywhere & what will installing the configuration with secrets will do?
dustinlyons commented 11 months ago

Hi, yes the current scripts will just do one partition. Before running the commands however you can swap out the disk-config with something like mine:

https://github.com/dustinlyons/nixos-config/blob/main/modules/nixos/disk-config.nix

_: {
  # This is the disk layout for a dual-boot system with Windows 10.
  disko.devices = {
    disk = {
      nvme0n1 = {
        device = "/dev/nvme0n1";
        type = "disk";
        content = {
          type = "gpt";
          partitions = {
            ESP = {
              type = "EF00";  # EFI partition type.
              size = "500M";
              content = {
                type = "filesystem";
                format = "vfat";
                mountpoint = "/boot";
              };
            };
            root = {
              start = "901G";  # Start immediately after Windows partition.
              size = "100%";  # Takes the remaining half of the disk space.
              content = {
                type = "filesystem";
                format = "ext4";
                mountpoint = "/";
              };
            };
          };
        };
      };
    };
  };
}

I had to first install Windows on the drive, then run the NixOS installer. I also had to manually add the place on the drive NixOS should start (901GB for me). Here is some info on that:

https://chat.openai.com/share/80ef0023-f68b-47af-bd6e-824861deca8e

Before running the final 3. Install configuration step, you'll have to swap out the disk-config in modules for the one you see above, and custom to your particular drive. Unfortunately I can't support this any further as it's not part of the standard install, but hopefully this info is enough.

  1. Secrets just mean you can keep sensitive data in your Nix configuration, like keys, certs, etc. So that when you install it, you don't have to manually set that stuff up. It's helpful to have a configuration that just "works out of the box".
Rafi1018 commented 11 months ago

Hi, yes the current scripts will just do one partition. Before running the commands however you can swap out the disk-config with something like mine:

https://github.com/dustinlyons/nixos-config/blob/main/modules/nixos/disk-config.nix

_: {
  # This is the disk layout for a dual-boot system with Windows 10.
  disko.devices = {
    disk = {
      nvme0n1 = {
        device = "/dev/nvme0n1";
        type = "disk";
        content = {
          type = "gpt";
          partitions = {
            ESP = {
              type = "EF00";  # EFI partition type.
              size = "500M";
              content = {
                type = "filesystem";
                format = "vfat";
                mountpoint = "/boot";
              };
            };
            root = {
              start = "901G";  # Start immediately after Windows partition.
              size = "100%";  # Takes the remaining half of the disk space.
              content = {
                type = "filesystem";
                format = "ext4";
                mountpoint = "/";
              };
            };
          };
        };
      };
    };
  };
}

I had to first install Windows on the drive, then run the NixOS installer. I also had to manually add the place on the drive NixOS should start (901GB for me). Here is some info on that:

https://chat.openai.com/share/80ef0023-f68b-47af-bd6e-824861deca8e

Before running the final 3. Install configuration step, you'll have to swap out the disk-config in modules for the one you see above, and custom to your particular drive. Unfortunately I can't support this any further as it's not part of the standard install, but hopefully this info is enough.

2. Secrets just mean you can keep sensitive data in your Nix configuration, like keys, certs, etc. So that when you install it, you don't have to manually set that stuff up. It's helpful to have a configuration that just "works out of the box".
  1. Gotcha thanks I think I can figure it out.
  2. so to get that out of the box experience I have to do all the installation steps?

And also what bootloader it uses?

Rafi1018 commented 11 months ago

Also

nix run .#build-switch -- what does it do?

nix flake update -- this updates the system right?

editing your system configuration building the (system closure) creating and switching to it (i.e creating a new generation)

What do you mean by it?

dustinlyons commented 11 months ago

If you're just starting out I would not worry about secrets for now, just get a config without secrets working first and understand it.

It's not that big of a deal to manually copy over some keys after the install is done.

NixOS uses systemd-boot with UEFI

dustinlyons commented 11 months ago

Also

nix run .#build-switch -- what does it do?

So Nix works by building everything as an isolated package on its own volume (the Nix "Store").

So when you build your configuration and switch to it, you're saying to your machine:

Yes, it says, update all inputs defined in the flake (nix-darwin, nixpkgs, etc) to the latest git hash.

Doesn't build or switch anything, but next time you build you'll grab the latest flake inputs.

editing your system configuration

building the (system closure)

creating and switching to it (i.e creating a new generation)

What do you mean by it?

Basically what I'm discussing above.

Rafi1018 commented 11 months ago

Also nix run .#build-switch -- what does it do?

So Nix works by building everything as an isolated package on its own volume (the Nix "Store").

So when you build your configuration and switch to it, you're saying to your machine:

* create everything I've defined in my config as a package in the Nix store, referencing its build instructions on how to build it (usually defined in nixpkgs), and then

* switch all my local packagss to a symlink that references the package in the Nix Store, instead of the actual package on my drive somewhere (probably installed by brew or its own installer).

nix flake update -- this updates the system right?

Yes, it says, update all inputs defined in the flake (nix-darwin, nixpkgs, etc) to the latest git hash.

Doesn't build or switch anything, but next time you build you'll grab the latest flake inputs.

editing your system configuration

building the (system closure)

creating and switching to it (i.e creating a new generation)

What do you mean by it?

Basically what I'm discussing above.

Got it thanks

Rafi1018 commented 11 months ago

Hey @dustinlyons sorry just one last thing I have made the disk configuration now How do I implement it?

Rafi1018 commented 11 months ago

Here's the disk config I created btw if you can review it for me :)

#Disk configuration for dual-booting NixOS with Windows 10
  disko.devices = {
    disk = {
      nvme0n1 = {
        device = "/dev/nvme0n1";
        type = "disk";
        content = {
          type = "gpt";
          partitions = {
            # Windows partitions (existing)
            ESP = {
              type = "EF00";  # EFI partition type
              size = "100M";
              content = {
                type = "filesystem";
                format = "vfat";
                mountpoint = "/boot";
              };
            };
            # NixOS partitions
            swap = {
              start = "373.766G";  # start point for swap
              size = "40G";
              content = {
                type = "swap";
              };
            };
            root = {
              start = "413.766G";  # After swap partition
              size = "100%";  # Take all remaining space
              content = {
                type = "filesystem";
                format = "ext4";
                mountpoint = "/";
              };
            };
          };
        };
      };
    };
  };
}
dustinlyons commented 11 months ago

Look in your modules/nixos directory. You should see a disk-config.nix file. Replace it with your configuration above.

Rafi1018 commented 11 months ago

Look in your modules/nixos directory. You should see a disk-config.nix file. Replace it with your configuration above.

Yes I meant then I have to create another repo then right? & does the disk-config look good?

dustinlyons commented 11 months ago

The README for this repository outlines a set of steps to use a template for NixOS. Once you've followed those instructions and created your Nix configuration, before running nix run #build-switch you should swap out the disk-config.nix located at modules/nixos/disk-config.nix with the one you created.