From 65da48fac0d1732f31f79ad3ac9956be5515bc2f Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Mon, 5 Apr 2021 23:11:17 -0400 Subject: [PATCH] add vm configuration --- flake.lock | 57 ++++++++++++++++++++++++++++++++++++++ flake.nix | 6 +++- hosts/configuration_vm.nix | 7 +++++ hosts/default.nix | 24 ++++++++++++++++ 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 hosts/configuration_vm.nix create mode 100644 hosts/default.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c7bd94d --- /dev/null +++ b/flake.lock @@ -0,0 +1,57 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1617673944, + "narHash": "sha256-0GYlbpsmTvt0jUUM47MfCLqBZBBsOqj1lwo4a/anQfY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7d10c949fa3cb4d9f44e6a8017b89f55bf58f07d", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "stable2009": "stable2009", + "unstable": "unstable" + } + }, + "stable2009": { + "locked": { + "lastModified": 1617542311, + "narHash": "sha256-YbYqpUA8EChwUaUSj8wIukv9ieFQdUnSSm5RypghNBA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "91b77fe6942fe999b1efbe906dc98024d1917c0d", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-20.09", + "type": "indirect" + } + }, + "unstable": { + "locked": { + "lastModified": 1617082367, + "narHash": "sha256-W0cQPGjc4IVzryaGycuoS8KZkXafS1P23w/fcKLoD5Y=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "04a2b269d8921505a2969fc9ec25c1f517f2b307", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index 509a05b..dc250ec 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,12 @@ { - outputs = { self, nixpkgs }: { + inputs.unstable.url = "nixpkgs/nixos-unstable"; + inputs.stable2009.url = "nixpkgs/nixos-20.09"; + + outputs = { self, nixpkgs, ... }@inputs: { nixosModule = { ... }: { imports = [ ./. ]; config = { sconfig.flakes.enable = true; }; }; + nixosConfigurations = import ./hosts { inherit (inputs) unstable stable2009; }; }; } diff --git a/hosts/configuration_vm.nix b/hosts/configuration_vm.nix new file mode 100644 index 0000000..41fc3d7 --- /dev/null +++ b/hosts/configuration_vm.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + networking.hostName = "vm"; + sconfig.profile = "server"; + boot.loader.grub.device = "/dev/vda"; + fileSystems."/" = { device = "/dev/vda1"; fsType = "ext4"; }; +} diff --git a/hosts/default.nix b/hosts/default.nix new file mode 100644 index 0000000..d304ea7 --- /dev/null +++ b/hosts/default.nix @@ -0,0 +1,24 @@ +{ unstable, stable2009 }: +let + mkStandardSystem = { name, pkgs }: pkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + pkgs.nixosModules.notDetected + (./. + "/configuration_${name}.nix") + ../. + ]; + }; + + mkQemuSystem = { name, pkgs }: pkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ({ modulesPath, ... }: { imports = [ "${modulesPath}/profiles/qemu-guest.nix" ]; }) + (./. + "/configuration_${name}.nix") + ../. + ]; + }; + +in +{ + vm = mkQemuSystem { name = "vm"; pkgs = unstable; }; +}