feat: working on it
Some checks failed
/ lint (push) Has been cancelled

This commit is contained in:
Tine 2024-09-01 10:10:21 +02:00
parent b28b696adc
commit 609e1089b1
Signed by: mentos1386
SSH key fingerprint: SHA256:MNtTsLbihYaWF8j1fkOHfkKNlnN1JQfxEU/rBU8nCGw
5 changed files with 53 additions and 140 deletions

4
.gitignore vendored
View file

@ -34,7 +34,9 @@ override.tf.json
.terraformrc
terraform.rc
# ENV
.env
admin.*config
# Nix
**/result/*

View file

@ -1,8 +1,45 @@
{ lib, pkgs, ... }:
{
config,
lib,
pkgs,
modulesPath,
...
}:
{
imports = [
"${toString modulesPath}/profiles/qemu-guest.nix"
];
system.stateVersion = "24.05";
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
autoResize = true;
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-label/ESP";
fsType = "vfat";
};
boot.growPartition = true;
boot.kernelParams = [ "console=ttyS0" ];
boot.loader.systemd-boot.enable = true;
#boot.loader.grub.device = "nodev";
#boot.loader.grub.efiSupport = true;
#boot.loader.grub.efiInstallAsRemovable = true;
boot.loader.timeout = 0;
system.build.qcow2 = import "${toString modulesPath}/../lib/make-disk-image.nix" {
inherit lib config pkgs;
name = "nixos";
diskSize = "auto";
format = "qcow2-compressed";
partitionTableType = "efi";
copyChannel = true;
configFile = pkgs.writeText "configuration.nix" (pkgs.lib.readFile ./configuration.nix);
};
services.qemuGuest.enable = true;

View file

@ -1,56 +1,5 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixlib": {
"locked": {
"lastModified": 1723942470,
"narHash": "sha256-QdSArN0xKESEOTcv+3kE6yu4B4WX9lupZ4+Htx3RXGg=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "531a2e8416a6d8200a53eddfbdb8f2c8dc4a1251",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixos-generators": {
"inputs": {
"nixlib": "nixlib",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1724028932,
"narHash": "sha256-U11ZiQPrpIBdv7oS23bNdX9GCxe/hPf/ARr64P2Wj1Y=",
"owner": "nix-community",
"repo": "nixos-generators",
"rev": "5fd22603892e4ec5ac6085058ed658243143aacd",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixos-generators",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1724316499,
@ -69,30 +18,7 @@
},
"root": {
"inputs": {
"nixos-generators": "nixos-generators",
"nixpkgs": "nixpkgs",
"xc": "xc"
}
},
"xc": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1724081153,
"narHash": "sha256-j2bfrmjBSf87ByVSGUaNzHk3Hh605/rOjar3slWAhjQ=",
"owner": "joerdav",
"repo": "xc",
"rev": "48e28d6f29623b0c2eedce688fcb7d29f0d2976e",
"type": "github"
},
"original": {
"owner": "joerdav",
"repo": "xc",
"type": "github"
"nixpkgs": "nixpkgs"
}
}
},

View file

@ -1,70 +1,18 @@
{
description = "Basic NixOS qcow2 image with CloudInit for Proxmox";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
xc = {
url = "github:joerdav/xc";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self, nixpkgs }:
{
nixpkgs,
nixos-generators,
xc,
...
}:
let
pkgsForSystem =
system:
import nixpkgs {
inherit system;
overlays = [ (final: prev: { xc = xc.packages.${system}.xc; }) ];
};
allVMs = [
"x86_64-linux"
"aarch64-linux"
];
forAllVMs =
f:
nixpkgs.lib.genAttrs allVMs (
system:
f {
inherit system;
pkgs = pkgsForSystem system;
}
);
in
{
packages = forAllVMs (
{ system, pkgs }:
{
vm = nixos-generators.nixosGenerate {
format = "qcow-efi";
system = system;
specialArgs = {
pkgs = pkgs;
};
nixosConfigurations = {
build-qcow2 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
# Pin nixpkgs to the flake input, so that the packages installed
# come from the flake inputs.nixpkgs.url.
(
{ ... }:
{
nix.registry.nixpkgs.flake = nixpkgs;
}
)
# Apply the rest of the config.
./configuration.nix
];
};
}
);
};
};
}

View file

@ -2,11 +2,11 @@ default:
@just --list
build:
@nix build .#vm
@nix build .#nixosConfigurations.build-qcow2.config.system.build.qcow2
apply: build
#!/usr/bin/env sh
export NIXOS_IMAGE=$(nix path-info --quiet .#vm)/nixos.qcow2
export NIXOS_IMAGE=$(nix path-info --quiet .#nixosConfigurations.build-qcow2.config.system.build.qcow2)/nixos.qcow2
export TF_VAR_image_path=$NIXOS_IMAGE
echo "Deploying $NIXOS_IMAGE"