This commit is contained in:
parent
b28b696adc
commit
609e1089b1
5 changed files with 53 additions and 140 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -34,7 +34,9 @@ override.tf.json
|
||||||
.terraformrc
|
.terraformrc
|
||||||
terraform.rc
|
terraform.rc
|
||||||
|
|
||||||
|
|
||||||
# ENV
|
# ENV
|
||||||
.env
|
.env
|
||||||
admin.*config
|
admin.*config
|
||||||
|
|
||||||
|
# Nix
|
||||||
|
**/result/*
|
||||||
|
|
|
@ -1,8 +1,45 @@
|
||||||
{ lib, pkgs, ... }:
|
|
||||||
{
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
modulesPath,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
"${toString modulesPath}/profiles/qemu-guest.nix"
|
||||||
|
];
|
||||||
|
|
||||||
system.stateVersion = "24.05";
|
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.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;
|
services.qemuGuest.enable = true;
|
||||||
|
|
||||||
|
|
|
@ -1,56 +1,5 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"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": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1724316499,
|
"lastModified": 1724316499,
|
||||||
|
@ -69,30 +18,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixos-generators": "nixos-generators",
|
"nixpkgs": "nixpkgs"
|
||||||
"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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,70 +1,18 @@
|
||||||
{
|
{
|
||||||
|
description = "Basic NixOS qcow2 image with CloudInit for Proxmox";
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
|
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 =
|
outputs =
|
||||||
|
{ self, nixpkgs }:
|
||||||
{
|
{
|
||||||
nixpkgs,
|
nixosConfigurations = {
|
||||||
nixos-generators,
|
build-qcow2 = nixpkgs.lib.nixosSystem {
|
||||||
xc,
|
system = "x86_64-linux";
|
||||||
...
|
|
||||||
}:
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
modules = [
|
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
|
./configuration.nix
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@ default:
|
||||||
@just --list
|
@just --list
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@nix build .#vm
|
@nix build .#nixosConfigurations.build-qcow2.config.system.build.qcow2
|
||||||
|
|
||||||
apply: build
|
apply: build
|
||||||
#!/usr/bin/env sh
|
#!/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
|
export TF_VAR_image_path=$NIXOS_IMAGE
|
||||||
|
|
||||||
echo "Deploying $NIXOS_IMAGE"
|
echo "Deploying $NIXOS_IMAGE"
|
||||||
|
|
Loading…
Reference in a new issue