Skip to content

Commit

Permalink
Merge pull request #9 from entropia/cloud-init
Browse files Browse the repository at this point in the history
cloud-init installer iso
  • Loading branch information
leona-ya committed Apr 18, 2024
2 parents fafe701 + db8cc07 commit 5868b25
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 0 deletions.
10 changes: 10 additions & 0 deletions checks/cloudInitImage.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ self, inputs, ... }:
let
inherit (inputs.nixpkgs) lib;
in
{
perSystem = { system, ... }: {
checks = lib.optionalAttrs (system == "x86_64-linux")
(lib.mapAttrs' (name: value: lib.nameValuePair "cloudInitImage-${name}" value) self.cloudInitImages.${system});
};
}
1 change: 1 addition & 0 deletions checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
imports = [
./devShells.nix
./nixosConfigurations.nix
./cloudInitImage.nix
];
}
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
./modules
./pkgs
./checks
./lib/cloud-init.nix
./flakeModules
];

perSystem = { pkgs, inputs', ... }: {
Expand Down
13 changes: 13 additions & 0 deletions flakeModules/cloud-init.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ lib, flake-parts-lib, ... }:
let
inherit (lib) mkOption types ;
inherit (flake-parts-lib) mkTransposedPerSystemModule ;
in
mkTransposedPerSystemModule {
name = "cloudInitImages";
option = mkOption {
type = types.lazyAttrsOf types.package;
default = { };
};
file = ./cloud-init.nix;
}
5 changes: 5 additions & 0 deletions flakeModules/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
imports = [
./cloud-init.nix
];
}
60 changes: 60 additions & 0 deletions lib/cloud-init.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{ inputs, ... }: {
perSystem = { system, ... }: {
cloudInitImages.default = (inputs.nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit inputs; };
modules = [
({ config, lib, pkgs, modulesPath, ... }: {
imports = [
../profiles/base
(modulesPath + "/profiles/minimal.nix")
(modulesPath + "/profiles/qemu-guest.nix")
(modulesPath + "/installer/cd-dvd/iso-image.nix")
inputs.colmena.nixosModules.deploymentOptions
inputs.sops-nix.nixosModules.default
];

nixpkgs.hostPlatform = system;
system.stateVersion = "24.05";

isoImage = {
makeEfiBootable = true;
forceTextMode = true;
isoBaseName = "nixos-cloudinit-entropia";
};

networking = {
useDHCP = true;
useNetworkd = true;
};

services.cloud-init = {
enable = true;
network.enable = true;
settings = {
cloud_init_modules = lib.mkForce [
"seed_random"
"bootcmd"
"resolv_conf"
"rsyslog"
"users-groups"
"ssh"
];

cloud_config_modules = lib.mkForce [
"set-passwords"
"timezone"
"disable_ec2_metadata"
];

cloud_final_modules = lib.mkForce [
"final-message"
];

};
};
})
];
}).config.system.build.isoImage;
};
}

0 comments on commit 5868b25

Please sign in to comment.