From 5098a545b1eb34538aa50f4d99376fc6c1c65edc Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 26 Mar 2024 08:56:25 -0400 Subject: [PATCH 01/11] wip --- global/nixos-install-oneclick/disk-config.nix | 37 ++++++++++++++ global/nixos-install-oneclick/flake.lock | 48 +++++++++++++++++++ global/nixos-install-oneclick/flake.nix | 20 ++++++++ 3 files changed, 105 insertions(+) create mode 100644 global/nixos-install-oneclick/disk-config.nix create mode 100644 global/nixos-install-oneclick/flake.lock create mode 100644 global/nixos-install-oneclick/flake.nix diff --git a/global/nixos-install-oneclick/disk-config.nix b/global/nixos-install-oneclick/disk-config.nix new file mode 100644 index 00000000..c4404bf1 --- /dev/null +++ b/global/nixos-install-oneclick/disk-config.nix @@ -0,0 +1,37 @@ +{ + disko.devices = { + disk = { + main = { + # When using disko-install, we will overwrite this value from the commandline + device = "/dev/disk/by-id/some-disk-id"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + MBR = { + type = "EF02"; # for grub MBR + size = "1M"; + }; + ESP = { + type = "EF00"; + size = "500M"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + root = { + size = "100%"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/global/nixos-install-oneclick/flake.lock b/global/nixos-install-oneclick/flake.lock new file mode 100644 index 00000000..e9ae253a --- /dev/null +++ b/global/nixos-install-oneclick/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1711261295, + "narHash": "sha256-5DUNQl9BSmLxgGLbF05G7hi/UTk9DyZq8AuEszhQA7Q=", + "owner": "nix-community", + "repo": "disko", + "rev": "5d2d3e421ade554b19b4dbb0d11a04023378a330", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1711124224, + "narHash": "sha256-l0zlN/3CiodvWDtfBOVxeTwYSRz93muVbXWSpaMjXxM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "56528ee42526794d413d6f244648aaee4a7b56c0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "disko": "disko", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/global/nixos-install-oneclick/flake.nix b/global/nixos-install-oneclick/flake.nix new file mode 100644 index 00000000..fa81cf28 --- /dev/null +++ b/global/nixos-install-oneclick/flake.nix @@ -0,0 +1,20 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + disko.url = "github:nix-community/disko"; + disko.inputs.nixpkgs.follows = "nixpkgs"; + }; + outputs = { self, nixpkgs, disko, ... }: { + nixosConfigurations.oneclick = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./disk-config.nix + disko.nixosModules.disko + ({ pkgs, ... }: { + environment.systemPackages = [ pkgs.htop ]; + system.stateVersion = "23.11"; + }) + ]; + }; + }; +} From 0bac16fcc526c6dedd8e4773cd4d97fd3b029c35 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 26 Mar 2024 08:59:11 -0400 Subject: [PATCH 02/11] arm --- en/nixos-install-oneclick.md | 9 ++++++++- global/nixos-install-oneclick/flake.nix | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/en/nixos-install-oneclick.md b/en/nixos-install-oneclick.md index 90afbaca..d5de54bf 100644 --- a/en/nixos-install-oneclick.md +++ b/en/nixos-install-oneclick.md @@ -4,4 +4,11 @@ order: 3 # Install NixOS directly from a remote flake -[ ] To write +>[!todo] To Write +> This tutorial has not been written yet. What you see below are just rough notes. + +Boot from a NixOS install live CD, and then: + +```sh +nix --extra-experimental-features 'flakes nix-command' run github:nix-community/disko#disko-install -- --flake "github:nixos-asia/website/disko-install?dir=global/nixos-install-oneclick#oneclick" --disk main /dev/sda +``` \ No newline at end of file diff --git a/global/nixos-install-oneclick/flake.nix b/global/nixos-install-oneclick/flake.nix index fa81cf28..30f0f0d0 100644 --- a/global/nixos-install-oneclick/flake.nix +++ b/global/nixos-install-oneclick/flake.nix @@ -6,7 +6,8 @@ }; outputs = { self, nixpkgs, disko, ... }: { nixosConfigurations.oneclick = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; + # TODO: can we parametrize this? Maybe via --override-input? + system = "aarch64-linux"; modules = [ ./disk-config.nix disko.nixosModules.disko From 0eeeabe490421518fad1dec55579c93ce6418f67 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 26 Mar 2024 09:10:58 -0400 Subject: [PATCH 03/11] grub --- en/nixos-install-oneclick.md | 2 +- global/nixos-install-oneclick/flake.nix | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/en/nixos-install-oneclick.md b/en/nixos-install-oneclick.md index d5de54bf..e47dd7c3 100644 --- a/en/nixos-install-oneclick.md +++ b/en/nixos-install-oneclick.md @@ -10,5 +10,5 @@ order: 3 Boot from a NixOS install live CD, and then: ```sh -nix --extra-experimental-features 'flakes nix-command' run github:nix-community/disko#disko-install -- --flake "github:nixos-asia/website/disko-install?dir=global/nixos-install-oneclick#oneclick" --disk main /dev/sda +nix --extra-experimental-features 'flakes nix-command' run github:nix-community/disko#disko-install -- --flake "github:nixos-asia/website/disko-install?dir=global/nixos-install-oneclick#oneclick" --write-efi-boot-entries --disk main /dev/sda ``` \ No newline at end of file diff --git a/global/nixos-install-oneclick/flake.nix b/global/nixos-install-oneclick/flake.nix index 30f0f0d0..2ae0688f 100644 --- a/global/nixos-install-oneclick/flake.nix +++ b/global/nixos-install-oneclick/flake.nix @@ -13,6 +13,14 @@ disko.nixosModules.disko ({ pkgs, ... }: { environment.systemPackages = [ pkgs.htop ]; + boot.loader.grub = { + efiSupport = true; + efiInstallAsRemovable = true; + }; + networking.hostname = "oneclick"; + users.users.root.openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHQRxPoqlThDrkR58pKnJgmeWPY9/wleReRbZ2MOZRyd"; + ]; system.stateVersion = "23.11"; }) ]; From 35b8d4fd30442d116b2efd79fc77a41dfe5bcc32 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 26 Mar 2024 09:12:22 -0400 Subject: [PATCH 04/11] syn --- en/nixos-install-oneclick.md | 2 +- global/nixos-install-oneclick/flake.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/en/nixos-install-oneclick.md b/en/nixos-install-oneclick.md index e47dd7c3..a43c9708 100644 --- a/en/nixos-install-oneclick.md +++ b/en/nixos-install-oneclick.md @@ -10,5 +10,5 @@ order: 3 Boot from a NixOS install live CD, and then: ```sh -nix --extra-experimental-features 'flakes nix-command' run github:nix-community/disko#disko-install -- --flake "github:nixos-asia/website/disko-install?dir=global/nixos-install-oneclick#oneclick" --write-efi-boot-entries --disk main /dev/sda +sudo nix --extra-experimental-features 'flakes nix-command' run github:nix-community/disko#disko-install -- --flake "github:nixos-asia/website/disko-install?dir=global/nixos-install-oneclick#oneclick" --write-efi-boot-entries --disk main /dev/sda ``` \ No newline at end of file diff --git a/global/nixos-install-oneclick/flake.nix b/global/nixos-install-oneclick/flake.nix index 2ae0688f..f4972b31 100644 --- a/global/nixos-install-oneclick/flake.nix +++ b/global/nixos-install-oneclick/flake.nix @@ -19,7 +19,7 @@ }; networking.hostname = "oneclick"; users.users.root.openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHQRxPoqlThDrkR58pKnJgmeWPY9/wleReRbZ2MOZRyd"; + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHQRxPoqlThDrkR58pKnJgmeWPY9/wleReRbZ2MOZRyd" ]; system.stateVersion = "23.11"; }) From 90d9cc323162100b7df4b070a41491dacbc23810 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 26 Mar 2024 09:13:12 -0400 Subject: [PATCH 05/11] typo --- global/nixos-install-oneclick/flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global/nixos-install-oneclick/flake.nix b/global/nixos-install-oneclick/flake.nix index f4972b31..ee8ce1f6 100644 --- a/global/nixos-install-oneclick/flake.nix +++ b/global/nixos-install-oneclick/flake.nix @@ -17,7 +17,7 @@ efiSupport = true; efiInstallAsRemovable = true; }; - networking.hostname = "oneclick"; + networking.hostName = "oneclick"; users.users.root.openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHQRxPoqlThDrkR58pKnJgmeWPY9/wleReRbZ2MOZRyd" ]; From f56b3145d3385aa0c4b494bd1d65185e1e9ceaca Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 26 Mar 2024 09:16:23 -0400 Subject: [PATCH 06/11] can touch --- global/nixos-install-oneclick/flake.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/global/nixos-install-oneclick/flake.nix b/global/nixos-install-oneclick/flake.nix index ee8ce1f6..ffaa01c0 100644 --- a/global/nixos-install-oneclick/flake.nix +++ b/global/nixos-install-oneclick/flake.nix @@ -13,9 +13,13 @@ disko.nixosModules.disko ({ pkgs, ... }: { environment.systemPackages = [ pkgs.htop ]; - boot.loader.grub = { - efiSupport = true; - efiInstallAsRemovable = true; + boot.loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + /* grub = { + efiSupport = true; + efiInstallAsRemovable = true; + }; */ }; networking.hostName = "oneclick"; users.users.root.openssh.authorizedKeys.keys = [ From 6963a83639898af32d9959f86f276589c9d81b8e Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 26 Mar 2024 09:22:54 -0400 Subject: [PATCH 07/11] root passwd --- global/nixos-install-oneclick/flake.nix | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/global/nixos-install-oneclick/flake.nix b/global/nixos-install-oneclick/flake.nix index ffaa01c0..1e067697 100644 --- a/global/nixos-install-oneclick/flake.nix +++ b/global/nixos-install-oneclick/flake.nix @@ -16,15 +16,18 @@ boot.loader = { systemd-boot.enable = true; efi.canTouchEfiVariables = true; - /* grub = { + grub = { efiSupport = true; - efiInstallAsRemovable = true; - }; */ + # efiInstallAsRemovable = true; + }; }; networking.hostName = "oneclick"; - users.users.root.openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHQRxPoqlThDrkR58pKnJgmeWPY9/wleReRbZ2MOZRyd" - ]; + services.openssh.enable = true; + + # Remove this after setting up users and keys + services.openssh.settings.PermitRootLogin = "yes"; + users.users.root.initialHashedPassword = "root"; + system.stateVersion = "23.11"; }) ]; From 7a1301fc6dd91af97dcd7736a3b022b21aff1bdf Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 26 Mar 2024 09:32:45 -0400 Subject: [PATCH 08/11] key --- en/nixos-install-oneclick.md | 7 ++++++- global/nixos-install-oneclick/flake.nix | 13 ++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/en/nixos-install-oneclick.md b/en/nixos-install-oneclick.md index a43c9708..783a6c52 100644 --- a/en/nixos-install-oneclick.md +++ b/en/nixos-install-oneclick.md @@ -10,5 +10,10 @@ order: 3 Boot from a NixOS install live CD, and then: ```sh -sudo nix --extra-experimental-features 'flakes nix-command' run github:nix-community/disko#disko-install -- --flake "github:nixos-asia/website/disko-install?dir=global/nixos-install-oneclick#oneclick" --write-efi-boot-entries --disk main /dev/sda +sudo nix \ + --extra-experimental-features 'flakes nix-command' \ + run github:nix-community/disko#disko-install -- \ + --flake "github:nixos-asia/website/disko-install?dir=global/nixos-install-oneclick#oneclick" \ + --write-efi-boot-entries \ + --disk main /dev/sda ``` \ No newline at end of file diff --git a/global/nixos-install-oneclick/flake.nix b/global/nixos-install-oneclick/flake.nix index 1e067697..0fa7271c 100644 --- a/global/nixos-install-oneclick/flake.nix +++ b/global/nixos-install-oneclick/flake.nix @@ -5,6 +5,8 @@ disko.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, nixpkgs, disko, ... }: { + # A bare NixOS configuration that can be ssh'ed to as root, with known password + # For testing/demo purposes only. nixosConfigurations.oneclick = nixpkgs.lib.nixosSystem { # TODO: can we parametrize this? Maybe via --override-input? system = "aarch64-linux"; @@ -16,17 +18,14 @@ boot.loader = { systemd-boot.enable = true; efi.canTouchEfiVariables = true; - grub = { - efiSupport = true; - # efiInstallAsRemovable = true; - }; }; networking.hostName = "oneclick"; services.openssh.enable = true; - # Remove this after setting up users and keys - services.openssh.settings.PermitRootLogin = "yes"; - users.users.root.initialHashedPassword = "root"; + # Add your key here + users.users.root.openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHQRxPoqlThDrkR58pKnJgmeWPY9/wleReRbZ2MOZRyd"; + ]; system.stateVersion = "23.11"; }) From 75dcab4e0d26732c4cce3d75363fb95a0205072a Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 26 Mar 2024 09:34:39 -0400 Subject: [PATCH 09/11] grr --- global/nixos-install-oneclick/flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global/nixos-install-oneclick/flake.nix b/global/nixos-install-oneclick/flake.nix index 0fa7271c..12d0b8fb 100644 --- a/global/nixos-install-oneclick/flake.nix +++ b/global/nixos-install-oneclick/flake.nix @@ -24,7 +24,7 @@ # Add your key here users.users.root.openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHQRxPoqlThDrkR58pKnJgmeWPY9/wleReRbZ2MOZRyd"; + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHQRxPoqlThDrkR58pKnJgmeWPY9/wleReRbZ2MOZRyd" ]; system.stateVersion = "23.11"; From efc04cbbd0ff4e804384c53e11ef5c0280a4aedb Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 26 Mar 2024 09:38:31 -0400 Subject: [PATCH 10/11] fin --- en/nixos-install-oneclick.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/en/nixos-install-oneclick.md b/en/nixos-install-oneclick.md index 783a6c52..e479ee69 100644 --- a/en/nixos-install-oneclick.md +++ b/en/nixos-install-oneclick.md @@ -4,7 +4,7 @@ order: 3 # Install NixOS directly from a remote flake ->[!todo] To Write +>[!WARNING] To Write > This tutorial has not been written yet. What you see below are just rough notes. Boot from a NixOS install live CD, and then: @@ -16,4 +16,4 @@ sudo nix \ --flake "github:nixos-asia/website/disko-install?dir=global/nixos-install-oneclick#oneclick" \ --write-efi-boot-entries \ --disk main /dev/sda -``` \ No newline at end of file +``` From 7ac8236177f561d957a08e07fc53c5ac66296e9b Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 26 Mar 2024 12:27:42 -0400 Subject: [PATCH 11/11] .. --- global/nixos-install-oneclick/flake.nix | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/global/nixos-install-oneclick/flake.nix b/global/nixos-install-oneclick/flake.nix index 12d0b8fb..82e2d857 100644 --- a/global/nixos-install-oneclick/flake.nix +++ b/global/nixos-install-oneclick/flake.nix @@ -5,11 +5,8 @@ disko.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, nixpkgs, disko, ... }: { - # A bare NixOS configuration that can be ssh'ed to as root, with known password - # For testing/demo purposes only. nixosConfigurations.oneclick = nixpkgs.lib.nixosSystem { - # TODO: can we parametrize this? Maybe via --override-input? - system = "aarch64-linux"; + system = "x86_64-linux"; modules = [ ./disk-config.nix disko.nixosModules.disko