Skip to content

Commit 3efd97a

Browse files
committed
iso installer
1 parent cb6f3b7 commit 3efd97a

10 files changed

Lines changed: 168 additions & 125 deletions

File tree

.github/workflows/OSkexec.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/installer.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: installer
2+
3+
on:
4+
push:
5+
tags:
6+
- "installer"
7+
8+
jobs:
9+
build-and-upload:
10+
runs-on: ${{ matrix.runner }}
11+
strategy:
12+
matrix:
13+
runner:
14+
- ubuntu-latest
15+
- ubuntu-24.04-arm
16+
17+
permissions:
18+
contents: write
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Install Nix
25+
uses: cachix/install-nix-action@v31
26+
with:
27+
nix_path: nixpkgs=channel:nixos-24.11
28+
29+
- name: Build kexec installer
30+
run: nix build --accept-flake-config ./os/installer#kexec
31+
32+
- name: Add kexec installer to release
33+
uses: softprops/action-gh-release@v2
34+
with:
35+
files: ./result/xnodeos-kexec-installer-*.tar.gz
36+
37+
- name: Build iso installer
38+
run: nix build --accept-flake-config ./os/installer#iso
39+
40+
- name: Add iso installer to release
41+
uses: softprops/action-gh-release@v2
42+
with:
43+
files: ./result/iso/xnodeos-iso-installer-*.iso

os/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e # Stop on error
44

55
# Download and extract kexec archive
6-
curl -L "https://github.com/Openmesh-Network/xnode-manager/releases/download/OSkexec/OSkexec-$(uname -m)-linux.tar.gz" | tar -xzf- -C /root
6+
curl -L "https://github.com/Openmesh-Network/xnode-manager/releases/download/installer/xnodeos-kexec-installer-$(uname -m)-linux.tar.gz" | tar -xzf- -C /root
77

88
# Boot into kexec
99
/root/xnodeos/install

os/installer/config.nix

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
inputs,
3+
modulesPath,
4+
config,
5+
pkgs,
6+
lib,
7+
...
8+
}:
9+
{
10+
system.stateVersion = config.system.nixos.release;
11+
12+
nix.settings = {
13+
extra-experimental-features = [
14+
"nix-command"
15+
"flakes"
16+
];
17+
accept-flake-config = true;
18+
};
19+
20+
systemd.services.install-xnodeos = {
21+
wantedBy = [ "multi-user.target" ];
22+
description = "Install XnodeOS.";
23+
wants = [ "network-online.target" ];
24+
after = [ "network-online.target" ];
25+
serviceConfig = {
26+
Type = "oneshot";
27+
User = "root";
28+
Group = "root";
29+
RemainAfterExit = true;
30+
};
31+
path = [
32+
pkgs.libuuid
33+
pkgs.jq
34+
pkgs.curl
35+
pkgs.nix
36+
pkgs.nixos-install
37+
inputs.disko.packages.${pkgs.system}.default
38+
inputs.nixos-facter.packages.${pkgs.system}.default
39+
pkgs.sbctl
40+
pkgs.clevis
41+
];
42+
script = lib.readFile ./install.sh;
43+
};
44+
}
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@
2828
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
2929
in
3030
{
31-
packages = forAllSystems (system: {
32-
default =
33-
(nixpkgs.legacyPackages.${system}.nixos [ self.nixosModules.default ])
34-
.config.system.build.kexecInstallerTarball;
35-
});
31+
packages = forAllSystems (
32+
system:
33+
let
34+
pkgs = nixpkgs.legacyPackages.${system};
35+
in
36+
{
37+
kexec = (pkgs.nixos [ self.nixosModules.kexec ]).config.system.build.kexecInstallerTarball;
38+
iso = (pkgs.nixos [ self.nixosModules.iso ]).config.system.build.isoImage;
39+
}
40+
);
3641
nixosModules = {
37-
default = import ./kexec.nix inputs;
42+
kexec = { pkgs, ... }@args: import ./kexec.nix (args // { inherit inputs; });
43+
iso = { pkgs, ... }@args: import ./iso.nix (args // { inherit inputs; });
3844
};
3945
};
4046
}
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Extract environmental variables
2-
sed '2q;d' /proc/cmdline > /tmp/xnode-env
3-
source /tmp/xnode-env
4-
51
mkdir -p /etc/nixos
62

73
# Generate disko-config.nix

os/installer/iso.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
inputs,
3+
modulesPath,
4+
pkgs,
5+
lib,
6+
...
7+
}@args:
8+
{
9+
imports = [
10+
(modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix")
11+
(import ./config.nix args)
12+
];
13+
14+
isoImage.isoName = lib.mkForce "xnodeos-iso-installer-${pkgs.stdenv.hostPlatform.system}.iso";
15+
}

os/installer/kexec.nix

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
inputs,
3+
modulesPath,
4+
config,
5+
pkgs,
6+
lib,
7+
...
8+
}@args:
9+
{
10+
imports = [
11+
(modulesPath + "/installer/netboot/netboot-minimal.nix")
12+
(import ./config.nix args)
13+
./minimal.nix
14+
];
15+
16+
boot.initrd.compressor = "xz";
17+
18+
# https://github.com/nix-community/nixos-images/blob/main/nix/kexec-installer/module.nix#L50
19+
system.build.kexecInstallerTarball = pkgs.runCommand "kexec-tarball" { } ''
20+
mkdir xnodeos $out
21+
cp "${config.system.build.netbootRamdisk}/initrd" xnodeos/initrd
22+
cp "${config.system.build.kernel}/${config.system.boot.loader.kernelFile}" xnodeos/bzImage
23+
cp "${config.system.build.kexecScript}" xnodeos/install
24+
cp "${pkgs.pkgsStatic.kexec-tools}/bin/kexec" xnodeos/kexec
25+
tar -czvf $out/xnodeos-kexec-installer-${pkgs.stdenv.hostPlatform.system}.tar.gz xnodeos
26+
'';
27+
28+
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/netboot/netboot.nix#L120
29+
# Modify kexec-boot to pass env variables to kexec environment
30+
system.build.kexecScript = lib.mkForce (
31+
pkgs.writeScript "kexec-boot" ''
32+
#!/usr/bin/env bash
33+
SCRIPT_DIR=$( cd -- "$( dirname -- "''${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
34+
''${SCRIPT_DIR}/kexec --load ''${SCRIPT_DIR}/bzImage \
35+
--initrd=''${SCRIPT_DIR}/initrd \
36+
--command-line "init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} && $(cat << EOF
37+
38+
export XNODE_OWNER="''${XNODE_OWNER}" && export DOMAIN="''${DOMAIN}" && export ACME_EMAIL="''${ACME_EMAIL}" && export USER_PASSWD="''${USER_PASSWD}" && export ENCRYPTED="''${ENCRYPTED}"
39+
EOF
40+
)"
41+
''${SCRIPT_DIR}/kexec -e
42+
''
43+
);
44+
45+
systemd.services.install-xnodeos.script = lib.mkBefore ''
46+
# Extract environmental variables
47+
sed '2q;d' /proc/cmdline > /tmp/xnode-env
48+
source /tmp/xnode-env
49+
'';
50+
}
Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,25 @@
1-
inputs:
21
{
32
modulesPath,
4-
config,
53
pkgs,
64
lib,
75
...
86
}:
97
{
8+
# Reduce closure size (https://github.com/nix-community/nixos-images/blob/main/nix/noninteractive.nix)
9+
1010
disabledModules = [
1111
# This module adds values to multiple lists (systemPackages, supportedFilesystems)
1212
# which are impossible/unpractical to remove, so we disable the entire module.
1313
"profiles/base.nix"
1414
];
1515

1616
imports = [
17-
(modulesPath + "/installer/netboot/netboot-minimal.nix")
1817
# reduce closure size by removing perl
1918
"${modulesPath}/profiles/perlless.nix"
2019
# FIXME: we still are left with nixos-generate-config due to nixos-install-tools
2120
{ system.forbiddenDependenciesRegexes = lib.mkForce [ ]; }
2221
];
2322

24-
boot.initrd.compressor = "xz";
25-
26-
system.stateVersion = config.system.nixos.release;
27-
28-
nix.settings = {
29-
extra-experimental-features = [
30-
"nix-command"
31-
"flakes"
32-
];
33-
accept-flake-config = true;
34-
};
35-
36-
# https://github.com/nix-community/nixos-images/blob/main/nix/kexec-installer/module.nix#L50
37-
system.build.kexecInstallerTarball = pkgs.runCommand "kexec-tarball" { } ''
38-
mkdir xnodeos $out
39-
cp "${config.system.build.netbootRamdisk}/initrd" xnodeos/initrd
40-
cp "${config.system.build.kernel}/${config.system.boot.loader.kernelFile}" xnodeos/bzImage
41-
cp "${config.system.build.kexecScript}" xnodeos/install
42-
cp "${pkgs.pkgsStatic.kexec-tools}/bin/kexec" xnodeos/kexec
43-
tar -czvf $out/OSkexec-${pkgs.stdenv.hostPlatform.system}.tar.gz xnodeos
44-
'';
45-
46-
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/netboot/netboot.nix#L120
47-
# Modify kexec-boot to pass env variables to kexec environment
48-
system.build.kexecScript = lib.mkForce (
49-
pkgs.writeScript "kexec-boot" ''
50-
#!/usr/bin/env bash
51-
SCRIPT_DIR=$( cd -- "$( dirname -- "''${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
52-
''${SCRIPT_DIR}/kexec --load ''${SCRIPT_DIR}/bzImage \
53-
--initrd=''${SCRIPT_DIR}/initrd \
54-
--command-line "init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} && $(cat << EOF
55-
56-
export XNODE_OWNER="''${XNODE_OWNER}" && export DOMAIN="''${DOMAIN}" && export ACME_EMAIL="''${ACME_EMAIL}" && export USER_PASSWD="''${USER_PASSWD}" && export ENCRYPTED="''${ENCRYPTED}"
57-
EOF
58-
)"
59-
''${SCRIPT_DIR}/kexec -e
60-
''
61-
);
62-
63-
systemd.services.install-xnodeos = {
64-
wantedBy = [ "multi-user.target" ];
65-
description = "Install XnodeOS.";
66-
wants = [ "network-online.target" ];
67-
after = [ "network-online.target" ];
68-
serviceConfig = {
69-
Type = "oneshot";
70-
User = "root";
71-
Group = "root";
72-
RemainAfterExit = true;
73-
};
74-
path = [
75-
pkgs.libuuid
76-
pkgs.jq
77-
pkgs.curl
78-
pkgs.nix
79-
pkgs.nixos-install
80-
inputs.disko.packages.${pkgs.system}.default
81-
inputs.nixos-facter.packages.${pkgs.system}.default
82-
pkgs.sbctl
83-
pkgs.clevis
84-
];
85-
script = lib.readFile ./install.sh;
86-
};
87-
88-
# Reduce closure size (https://github.com/nix-community/nixos-images/blob/main/nix/noninteractive.nix)
8923
documentation.enable = false;
9024
documentation.man.man-db.enable = false;
9125
system.installer.channel.enable = false;

rust-app/src/config/handlers.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -482,17 +482,7 @@ fn create_conf_file(container_id: &str) -> Option<HttpResponse> {
482482
let conf_file = containerconfig().join(format!("{}.conf", container_id));
483483
log::info!("Creating conf file {}", conf_file.display());
484484

485-
if let Err(e) = write(
486-
&conf_file,
487-
"
488-
PRIVATE_NETWORK=0
489-
HOST_ADDRESS=
490-
LOCAL_ADDRESS=
491-
HOST_BRIDGE=
492-
HOST_PORT=
493-
AUTO_START=0
494-
",
495-
) {
485+
if let Err(e) = write(&conf_file, "") {
496486
return Some(
497487
HttpResponse::InternalServerError().json(ResponseError::new(format!(
498488
"Error writing nixos container configuration file {}: {}",

0 commit comments

Comments
 (0)