From fc50e78610d8cac0e60d89556d2b9b6b4f848599 Mon Sep 17 00:00:00 2001 From: yuri Date: Wed, 26 Jul 2023 01:09:38 +0200 Subject: [PATCH] Add output for nixos-generators --- .gitignore | 1 + configuration/nixos-generators/default.nix | 14 +++++++ configuration/proxmox-vm/default.nix | 4 -- .../proxmox-vm/hardware-configuration.nix | 2 +- flake.lock | 37 +++++++++++++++++++ flake.nix | 20 +++++++++- 6 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 configuration/nixos-generators/default.nix diff --git a/.gitignore b/.gitignore index 722d5e7..02b9567 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .vscode +result diff --git a/configuration/nixos-generators/default.nix b/configuration/nixos-generators/default.nix new file mode 100644 index 0000000..2cda85e --- /dev/null +++ b/configuration/nixos-generators/default.nix @@ -0,0 +1,14 @@ +{ ... }: +{ + boot.loader.grub = { + enable = true; + device = "/dev/vda"; + }; + + networking = { + hostName = "base"; + firewall.enable = true; + }; + + system.stateVersion = "23.05"; +} diff --git a/configuration/proxmox-vm/default.nix b/configuration/proxmox-vm/default.nix index 644147a..65105c0 100644 --- a/configuration/proxmox-vm/default.nix +++ b/configuration/proxmox-vm/default.nix @@ -1,8 +1,4 @@ { ... }: { - imports = [ - ./hardware-configuration.nix - ]; - services.qemuGuest.enable = true; } diff --git a/configuration/proxmox-vm/hardware-configuration.nix b/configuration/proxmox-vm/hardware-configuration.nix index c007292..5fbbefa 100644 --- a/configuration/proxmox-vm/hardware-configuration.nix +++ b/configuration/proxmox-vm/hardware-configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, modulesPath, ... }: +{ config, lib, modulesPath, ... }: { imports = [ (modulesPath + "/profiles/qemu-guest.nix") diff --git a/flake.lock b/flake.lock index 3f90c88..f4f6d2d 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,41 @@ { "nodes": { + "nixlib": { + "locked": { + "lastModified": 1689469483, + "narHash": "sha256-2SBhY7rZQ/iNCxe04Eqxlz9YK9KgbaTMBssq3/BgdWY=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "02fea408f27186f139153e1ae88f8ab2abd9c22c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": "nixlib", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1690133435, + "narHash": "sha256-YNZiefETggroaTLsLJG2M+wpF0pJPwiauKG4q48ddNU=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "b1171de4d362c022130c92d7c8adc4bf2b83d586", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1689679375, @@ -18,6 +54,7 @@ }, "root": { "inputs": { + "nixos-generators": "nixos-generators", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 95eb8e1..3fab58a 100644 --- a/flake.nix +++ b/flake.nix @@ -1,9 +1,13 @@ { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixos-generators = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, ... }: { + outputs = { self, nixpkgs, nixos-generators, ... }: { hosts = { nitter = { site = "vs"; @@ -34,6 +38,7 @@ imports = [ ./configuration/common ./configuration/proxmox-vm + ./configuration/proxmox-vm/hardware-configuration.nix ./hosts/${name} ]; }; @@ -57,5 +62,18 @@ ]; }; }; + + # Generate a base VM image for Proxmox with `nix build .#base-proxmox` + packages.x86_64-linux = { + base-proxmox = nixos-generators.nixosGenerate { + system = "x86_64-linux"; + modules = [ + ./configuration/common + ./configuration/nixos-generators + ./configuration/proxmox-vm + ]; + format = "proxmox"; + }; + }; }; }