From 50a538c78ec3f71a37bfc9416565b11aeb105c54 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 20 Sep 2022 04:01:45 +0000 Subject: [PATCH] start generator work --- flake.lock | 37 +++++++++++++++++++++++++++++++++++++ flake.nix | 20 +++++++++++++++++--- generators/aws.nix | 19 +++++++++++++++++++ 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 generators/aws.nix diff --git a/flake.lock b/flake.lock index a3a0bac..202ceab 100644 --- a/flake.lock +++ b/flake.lock @@ -74,6 +74,42 @@ "type": "github" } }, + "nixlib": { + "locked": { + "lastModified": 1636849918, + "narHash": "sha256-nzUK6dPcTmNVrgTAC1EOybSMsrcx+QrVPyqRdyKLkjA=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "28a5b0557f14124608db68d3ee1f77e9329e9dd5", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": "nixlib", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660727616, + "narHash": "sha256-zYTIvdPMYMx/EYqXODAwIIU30RiEHqNHdgarIHuEYZc=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "adccd191a0e83039d537e021f19495b7bad546a1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1663357389, @@ -124,6 +160,7 @@ "inputs": { "darwin": "darwin", "home-manager": "home-manager", + "nixos-generators": "nixos-generators", "nixpkgs": "nixpkgs", "nur": "nur", "wallpapers": "wallpapers", diff --git a/flake.nix b/flake.nix index 6ba3749..4b95a7c 100644 --- a/flake.nix +++ b/flake.nix @@ -32,9 +32,15 @@ flake = false; }; + # Used to generate NixOS images for other platforms + nixos-generators = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; - outputs = { self, nixpkgs, darwin, wsl, home-manager, nur, wallpapers }: + outputs = { self, nixpkgs, ... }@inputs: let @@ -57,14 +63,14 @@ in { - nixosConfigurations = { + nixosConfigurations = with inputs; { desktop = import ./hosts/desktop { inherit nixpkgs home-manager nur globals wallpapers; }; wsl = import ./hosts/wsl { inherit nixpkgs wsl home-manager globals; }; }; - darwinConfigurations = { + darwinConfigurations = with inputs; { macbook = import ./hosts/macbook { inherit nixpkgs darwin home-manager nur globals; }; @@ -110,6 +116,14 @@ }); + # Package servers into images with a generator + packages.x86_64-linux = with inputs; { + aws = import ./generators/aws.nix { + inherit nixpkgs nixos-generators home-manager globals; + system = "x86_64-linux"; + }; + }; + # Templates for starting other projects quickly templates = rec { default = basic; diff --git a/generators/aws.nix b/generators/aws.nix new file mode 100644 index 0000000..f1f54cd --- /dev/null +++ b/generators/aws.nix @@ -0,0 +1,19 @@ +{ nixpkgs, system, nixos-generators, home-manager, globals, ... }: + +nixos-generators.nixoGenerate { + inherit system; + imports = [ + globals + home-manager.nixosModules.home-manager + { + networking.hostName = "sheep"; + gui.enable = false; + colorscheme = (import ../../modules/colorscheme/gruvbox); + passwordHash = + "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; + } + ../hosts/common.nix + ../modules/nixos + ]; + format = "aws"; +}