Create new install system with disko
This commit is contained in:
parent
29c9b505d1
commit
81237e88b0
8 changed files with 95 additions and 89 deletions
21
flake.lock
generated
21
flake.lock
generated
|
@ -1,5 +1,25 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"disko": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1749200714,
|
||||||
|
"narHash": "sha256-W8KiJIrVwmf43JOPbbTu5lzq+cmdtRqaNbOsZigjioY=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "disko",
|
||||||
|
"rev": "17d08c65c241b1d65b3ddf79e3fac1ddc870b0f6",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "disko",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-parts": {
|
"flake-parts": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs-lib": [
|
"nixpkgs-lib": [
|
||||||
|
@ -131,6 +151,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"disko": "disko",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"nixvim": "nixvim"
|
"nixvim": "nixvim"
|
||||||
}
|
}
|
||||||
|
|
14
flake.nix
14
flake.nix
|
@ -7,10 +7,19 @@
|
||||||
url = "github:nix-community/nixvim";
|
url = "github:nix-community/nixvim";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
disko = {
|
||||||
|
url = "github:nix-community/disko";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{ nixpkgs, nixvim, ... }:
|
{
|
||||||
|
nixpkgs,
|
||||||
|
nixvim,
|
||||||
|
disko,
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
nixosConfigurations =
|
nixosConfigurations =
|
||||||
(
|
(
|
||||||
|
@ -27,10 +36,12 @@
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
nixpkgs-flake = nixpkgs;
|
nixpkgs-flake = nixpkgs;
|
||||||
inherit nixvim;
|
inherit nixvim;
|
||||||
|
inherit disko;
|
||||||
};
|
};
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [
|
modules = [
|
||||||
{ networking.hostName = host; }
|
{ networking.hostName = host; }
|
||||||
|
disko.nixosModules.disko
|
||||||
./hosts/${host}/configuration.nix
|
./hosts/${host}/configuration.nix
|
||||||
./hosts/${host}/state.nix
|
./hosts/${host}/state.nix
|
||||||
];
|
];
|
||||||
|
@ -51,6 +62,7 @@
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
nixpkgs-flake = nixpkgs;
|
nixpkgs-flake = nixpkgs;
|
||||||
inherit nixvim;
|
inherit nixvim;
|
||||||
|
inherit disko;
|
||||||
};
|
};
|
||||||
system = "aarch64-linux";
|
system = "aarch64-linux";
|
||||||
modules = [
|
modules = [
|
||||||
|
|
25
hosts/installer-minimal/configuration.nix
Normal file
25
hosts/installer-minimal/configuration.nix
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
nixpkgs-flake,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
"${nixpkgs-flake}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
|
||||||
|
../../shared/base.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
environment.systemPackages = (
|
||||||
|
with pkgs;
|
||||||
|
[
|
||||||
|
cryptsetup
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
isoImage.squashfsCompression = "gzip -Xcompression-level 1";
|
||||||
|
networking.networkmanager.enable = lib.mkForce false;
|
||||||
|
|
||||||
|
#Many installs will need this, and it won't hurt either way
|
||||||
|
services.qemuGuest.enable = true;
|
||||||
|
}
|
1
hosts/installer-minimal/state.nix
Normal file
1
hosts/installer-minimal/state.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ }
|
|
@ -1,72 +0,0 @@
|
||||||
{ pkgs, ... }:
|
|
||||||
let
|
|
||||||
create-partitions = pkgs.writeScriptBin "create-partitions" ''
|
|
||||||
if [[ $# -ne 3 ]]
|
|
||||||
then
|
|
||||||
echo "Usage: create-partitions <device prefix> <BOOT suffix> <root suffix>"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
read -p "Erasing disk $1 -- Creating partition $1$2 as BOOT -- Creating partition $1$3 as root -- Are you sure? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
parted $1 -- mklabel gpt
|
|
||||||
parted $1 -- mkpart ESP fat32 1MB 512MB
|
|
||||||
parted $1 -- set 1 esp on
|
|
||||||
parted $1 -- mkpart root ext4 512MB 100%
|
|
||||||
fi
|
|
||||||
|
|
||||||
read -p "Setup root partition encryption?" -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
cryptsetup luksFormat $1$3
|
|
||||||
if cryptsetup open $1$3 nixos
|
|
||||||
then
|
|
||||||
echo "Encrypted device accessible via /dev/mapper/nixos"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
create-filesystems = pkgs.writeScriptBin "create-filesystems" ''
|
|
||||||
if [[ $# -ne 2 ]]
|
|
||||||
then
|
|
||||||
echo "Usage: create-filesystems <BOOT partition> <root partition>"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkfs.fat -F 32 -n BOOT $1
|
|
||||||
mkfs.ext4 -L nixos $2
|
|
||||||
'';
|
|
||||||
prep-install = pkgs.writeScriptBin "prep-install" ''
|
|
||||||
mkdir /mnt
|
|
||||||
mount /dev/disk/by-label/nixos /mnt
|
|
||||||
mkdir /mnt/boot
|
|
||||||
mount -o umask=077 /dev/disk/by-label/BOOT /mnt/boot
|
|
||||||
|
|
||||||
nixos-generate-config --root /mnt
|
|
||||||
mv /mnt/etc/nixos/configuration.nix configuration.nix.old
|
|
||||||
curl https://forgejo.sinerva.eu/VSinerva/nixos-conf/raw/branch/main/installer/template-configuration.nix -o /mnt/etc/nixos/configuration.nix
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
<nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
|
|
||||||
../base.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
environment.systemPackages =
|
|
||||||
(with pkgs; [
|
|
||||||
cryptsetup
|
|
||||||
])
|
|
||||||
++ [
|
|
||||||
create-partitions
|
|
||||||
create-filesystems
|
|
||||||
prep-install
|
|
||||||
];
|
|
||||||
|
|
||||||
isoImage.squashfsCompression = "gzip -Xcompression-level 1";
|
|
||||||
|
|
||||||
#Many installs will need this, and it won't hurt either way
|
|
||||||
services.qemuGuest.enable = true;
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-graphical-combined.nix>
|
|
||||||
./base.nix
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
{ lib, ... }:
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix>
|
|
||||||
./base.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
networking.networkmanager.enable = lib.mkForce false;
|
|
||||||
}
|
|
35
shared/disko/basic-ext4.nix
Normal file
35
shared/disko/basic-ext4.nix
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
disko.devices = {
|
||||||
|
disk = {
|
||||||
|
main-disk = {
|
||||||
|
device = "/dev/sda";
|
||||||
|
type = "disk";
|
||||||
|
content = {
|
||||||
|
type = "gpt";
|
||||||
|
partitions = {
|
||||||
|
ESP = {
|
||||||
|
name = "boot";
|
||||||
|
type = "EF00";
|
||||||
|
size = "512M";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "umask=0077" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
root = {
|
||||||
|
name = "nixos";
|
||||||
|
size = "100%";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "ext4";
|
||||||
|
mountpoint = "/";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue