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

Minimal nixos-config with disko #1

Merged
merged 17 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "CI"
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
# disko VM test requires a system with support for: {kvm, nixos-test}
# See https://github.com/nix-community/nixos-generators/issues/83#issuecomment-973294478
with:
extra-conf: "system-features = nixos-test benchmark big-parallel kvm"
- uses: DeterminateSystems/magic-nix-cache-action@main
# Run disko VM test (test partition creation and whether the VM boots up later)
- run: nix build .#nixosConfigurations.office.config.system.build.installTest
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# remote-development
NixOS configuration for shared remote development via SSH

## Getting started

Terminology:

- **Host**: The machine you are installing NixOS on.
- It must already be running Linux (which could even be booted off a rescue image)
- **Guest**: Your current machine, from which you are remotely doing the install.

| Step | Host | Guest |
| ---- | ------ | ---- |
| 1. | Add your SSH key to `authorized_keys` file in `/root/.ssh` | |
shivaraj-bh marked this conversation as resolved.
Show resolved Hide resolved
| 2. | Run `lsblk` to find the `<device-name>` of the disk to partition. For example, `nvme0n1` is the device here: <br><pre>❯ lsblk<br>NAME MAJ:MIN RM SIZE RO TYPE<br>nvme0n1 259:0 0 1.9T 0 disk</pre> | |
| 3. | In `disk-config.nix`, set `disko.devices.disk.main.device = "/dev/<device-name>";` | |
| 4. | | `nix run github:nix-community/nixos-anywhere -- --flake .#office root@<ip-address>` |

**Disclaimer**: The `<ip-address>` might change in kexec mode or post-installation, in which case you will have to stop the `Step 4` and rerun with updated `<ip-address>`.
Copy link
Member

Choose a reason for hiding this comment

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

Can we clarify this further?

When you say stop the Step 4, what is meant exactly? At what point (during the nix run ... process) exactly should the user stop it with Ctrl+C? Or is it that they must wait for it to error out (in which case, there is no need to stop the nix run ... process because it is already stopped), and then re-run it? If so, it would be useful to paste that error message here.

Copy link
Member

Choose a reason for hiding this comment

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

Also how do we find out the new ip address? It is worth including that as well.

Copy link
Member

Choose a reason for hiding this comment

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

(Disclaimer: I might be missing something, so we can also revisit these instructions after the actual install ....)

Copy link
Member Author

Choose a reason for hiding this comment

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

At what point (during the nix run ... process) exactly should the user stop it with Ctrl+C?

When the ssh starts timing out. I will add that point


37 changes: 37 additions & 0 deletions disk-config.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
disko.devices = {
disk = {
main = {
type = "disk";
device = "/dev/nvme0n1";
content = {
type = "gpt";
partitions = {
boot = {
size = "1M";
type = "EF02"; # for grub MBR
};
ESP = {
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};
};
};
};
}

48 changes: 48 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { nixpkgs, disko, ... }:
{
nixosConfigurations.office = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
disko.nixosModules.disko
({ modulesPath, ... }: {
imports = [
./disk-config.nix
];
services.openssh.enable = true;
users.users = {
root = {
# Post-installation, the IP might change if MAC is not the
# only identifier used by DHCP server to lease an IP, by setting a
# password you can find the changed IP.
initialHashedPassword = "";
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFN5Ov2zDIG59/DaYKjT0sMWIY15er1DZCT9SIak07vK"
];
};
};
boot.loader.grub = {
# adding devices is managed by disko
# devices = [ ];
efiSupport = true;
efiInstallAsRemovable = true;
};
system.stateVersion = "23.11";
}
)
];
};
};
}