diff --git a/configuration.nix b/configuration.nix index 8ccc71a..8b779d6 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,10 +1,14 @@ -{ config, lib, pkgs, ... }: { + config, + lib, + pkgs, + ... +}: { services.sshd.enable = true; services.nginx.enable = true; - networking.firewall.allowedTCPPorts = [ 80 ]; - + networking.firewall.allowedTCPPorts = [80]; + users.users.root.password = "nixos"; services.openssh.permitRootLogin = lib.mkDefault "yes"; services.getty.autologinUser = lib.mkDefault "root"; diff --git a/default.nix b/default.nix index 6ab9419..5922761 100644 --- a/default.nix +++ b/default.nix @@ -1,3 +1,5 @@ (import (builtins.fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) { src = ./.; -}).defaultNix.default +}) +.defaultNix +.default diff --git a/flake.nix b/flake.nix index bcedf65..adb882f 100644 --- a/flake.nix +++ b/flake.nix @@ -7,110 +7,131 @@ # Bin dependency inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - outputs = { self, nixpkgs, nixlib }: - + outputs = { + self, + nixpkgs, + nixlib, + }: # Library modules (depend on nixlib) - { - # export all generator formats in ./formats - nixosModules = nixlib.lib.mapAttrs' (file: _: { - name = nixlib.lib.removeSuffix ".nix" file; - # The exported module should include the internal format* options - value.imports = [ (./formats + "/${file}") ./format-module.nix ]; - }) (builtins.readDir ./formats); + { + # export all generator formats in ./formats + nixosModules = nixlib.lib.mapAttrs' (file: _: { + name = nixlib.lib.removeSuffix ".nix" file; + # The exported module should include the internal format* options + value.imports = [(./formats + "/${file}") ./format-module.nix]; + }) (builtins.readDir ./formats); - # example usage in flakes: - # outputs = { self, nixpkgs, nixos-generators, ...}: { - # vmware = nixos-generators.nixosGenerate { - # system = "x86_64-linux"; - # modules = [./configuration.nix]; - # format = "vmware"; - # }; - # } + # example usage in flakes: + # outputs = { self, nixpkgs, nixos-generators, ...}: { + # vmware = nixos-generators.nixosGenerate { + # system = "x86_64-linux"; + # modules = [./configuration.nix]; + # format = "vmware"; + # }; + # } - nixosGenerate = { pkgs ? null, lib ? nixpkgs.lib, format, system ? null, specialArgs ? { }, modules ? [ ], customFormats ? {} }: - let - extraFormats = lib.mapAttrs' (name: value: lib.nameValuePair - (name) - (value // { - imports = ( value.imports or [] ++ [ ./format-module.nix ] ); - } ) - ) customFormats; - formatModule = builtins.getAttr format (self.nixosModules // extraFormats); - image = nixpkgs.lib.nixosSystem { - inherit pkgs specialArgs; - system = if system != null then system else pkgs.system; - lib = if lib != null then lib else pkgs.lib; - modules = [ - formatModule - ] ++ modules; - }; - in - image.config.system.build.${image.config.formatAttr}; - - } - - // - - - # Binary and Devshell outputs (depend on nixpkgs) - ( - let - forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" "x86_64-darwin" "i686-linux" "aarch64-linux" "aarch64-darwin" ]; - in { - - formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); - - packages = forAllSystems (system: let - pkgs = nixpkgs.legacyPackages."${system}"; - in rec { - nixos-generators = nixpkgs.lib.warn '' - - Deprecation note from: github:nix-community/nixos-generators - - Was renamed: - - Was: nixos-generators.packages.${system}.nixos-generators - Now: nixos-generators.packages.${system}.nixos-generate - - Plase adapt your references - '' nixos-generate; - nixos-generate = pkgs.stdenv.mkDerivation { - name = "nixos-generate"; - src = ./.; - meta.description = "Collection of image builders"; - nativeBuildInputs = with pkgs; [ makeWrapper ]; - installFlags = [ "PREFIX=$(out)" ]; - postFixup = '' - wrapProgram $out/bin/nixos-generate \ - --prefix PATH : ${pkgs.lib.makeBinPath (with pkgs; [ jq coreutils findutils ])} - ''; + nixosGenerate = { + pkgs ? null, + lib ? nixpkgs.lib, + format, + system ? null, + specialArgs ? {}, + modules ? [], + customFormats ? {}, + }: let + extraFormats = + lib.mapAttrs' ( + name: value: + lib.nameValuePair + name + (value + // { + imports = (value.imports or [] ++ [./format-module.nix]); + }) + ) + customFormats; + formatModule = builtins.getAttr format (self.nixosModules // extraFormats); + image = nixpkgs.lib.nixosSystem { + inherit pkgs specialArgs; + system = + if system != null + then system + else pkgs.system; + lib = + if lib != null + then lib + else pkgs.lib; + modules = + [ + formatModule + ] + ++ modules; }; - }); - - defaultPackage = forAllSystems (system: self.packages."${system}".nixos-generate); - - devShell = forAllSystems (system: let - pkgs = nixpkgs.legacyPackages."${system}"; - in pkgs.mkShell { - buildInputs = with pkgs; [ jq coreutils findutils ]; - }); - - # Make it runnable with `nix run` - apps = forAllSystems (system: let - nixos-generate = { - type = "app"; - program = "${self.packages."${system}".nixos-generate}/bin/nixos-generate"; - }; - in { - inherit nixos-generate; - - # Nix >= 2.7 flake output schema uses `apps..default` instead - # of `defaultApp.` to signify the default app (the thing that - # gets run with `nix run . -- `) - default = nixos-generate; - }); - - defaultApp = forAllSystems (system: self.apps."${system}".nixos-generate); + in + image.config.system.build.${image.config.formatAttr}; } - ); + // + # Binary and Devshell outputs (depend on nixpkgs) + ( + let + forAllSystems = nixpkgs.lib.genAttrs ["x86_64-linux" "x86_64-darwin" "i686-linux" "aarch64-linux" "aarch64-darwin"]; + in { + formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); + + packages = forAllSystems (system: let + pkgs = nixpkgs.legacyPackages."${system}"; + in rec { + nixos-generators = + nixpkgs.lib.warn '' + + Deprecation note from: github:nix-community/nixos-generators + + Was renamed: + + Was: nixos-generators.packages.${system}.nixos-generators + Now: nixos-generators.packages.${system}.nixos-generate + + Plase adapt your references + '' + nixos-generate; + nixos-generate = pkgs.stdenv.mkDerivation { + name = "nixos-generate"; + src = ./.; + meta.description = "Collection of image builders"; + nativeBuildInputs = with pkgs; [makeWrapper]; + installFlags = ["PREFIX=$(out)"]; + postFixup = '' + wrapProgram $out/bin/nixos-generate \ + --prefix PATH : ${pkgs.lib.makeBinPath (with pkgs; [jq coreutils findutils])} + ''; + }; + }); + + defaultPackage = forAllSystems (system: self.packages."${system}".nixos-generate); + + devShell = forAllSystems (system: let + pkgs = nixpkgs.legacyPackages."${system}"; + in + pkgs.mkShell { + buildInputs = with pkgs; [jq coreutils findutils]; + }); + + # Make it runnable with `nix run` + apps = forAllSystems (system: let + nixos-generate = { + type = "app"; + program = "${self.packages."${system}".nixos-generate}/bin/nixos-generate"; + }; + in { + inherit nixos-generate; + + # Nix >= 2.7 flake output schema uses `apps..default` instead + # of `defaultApp.` to signify the default app (the thing that + # gets run with `nix run . -- `) + default = nixos-generate; + }); + + defaultApp = forAllSystems (system: self.apps."${system}".nixos-generate); + } + ); } diff --git a/format-module.nix b/format-module.nix index bc55d42..22d650e 100644 --- a/format-module.nix +++ b/format-module.nix @@ -1,4 +1,4 @@ -{ lib, ... }: rec { +{lib, ...}: rec { _file = ./format-module.nix; # This deliberate key makes sure this module will be deduplicated # regardless of the accessor path: either via flake's nixosModule @@ -18,4 +18,3 @@ }; }; } - diff --git a/formats/amazon.nix b/formats/amazon.nix index 0326d3f..8835b88 100644 --- a/formats/amazon.nix +++ b/formats/amazon.nix @@ -1,5 +1,4 @@ -{ modulesPath, ... }: -{ +{modulesPath, ...}: { imports = [ "${toString modulesPath}/../maintainers/scripts/ec2/amazon-image.nix" ]; diff --git a/formats/azure.nix b/formats/azure.nix index d7135db..95b592b 100644 --- a/formats/azure.nix +++ b/formats/azure.nix @@ -1,5 +1,4 @@ -{ modulesPath, ... }: -{ +{modulesPath, ...}: { imports = [ "${toString modulesPath}/virtualisation/azure-image.nix" ]; diff --git a/formats/cloudstack.nix b/formats/cloudstack.nix index 1c5841e..e25a74d 100644 --- a/formats/cloudstack.nix +++ b/formats/cloudstack.nix @@ -1,14 +1,20 @@ -{ config, lib, pkgs, modulesPath, ... }: { + config, + lib, + pkgs, + modulesPath, + ... +}: { imports = [ "${toString modulesPath}/virtualisation/cloudstack-config.nix" ]; - system.build.cloudstackImage = import "${toString modulesPath}/../lib/make-disk-image.nix" { + system.build.cloudstackImage = import "${toString modulesPath}/../lib/make-disk-image.nix" { inherit lib config pkgs; diskSize = 8192; format = "qcow2"; - configFile = pkgs.writeText "configuration.nix" + configFile = + pkgs.writeText "configuration.nix" '' { imports = [ "${toString modulesPath}/virtualisation/cloudstack-config.nix" ]; diff --git a/formats/do.nix b/formats/do.nix index 8b5d0e3..f6fb953 100644 --- a/formats/do.nix +++ b/formats/do.nix @@ -1,5 +1,4 @@ -{ modulesPath, ... }: -{ +{modulesPath, ...}: { imports = [ "${toString modulesPath}/virtualisation/digital-ocean-image.nix" ]; diff --git a/formats/docker.nix b/formats/docker.nix index dd7bec7..6310da4 100644 --- a/formats/docker.nix +++ b/formats/docker.nix @@ -1,5 +1,8 @@ -{ modulesPath, lib, ... }: { + modulesPath, + lib, + ... +}: { imports = [ "${toString modulesPath}/virtualisation/docker-image.nix" ]; diff --git a/formats/gce.nix b/formats/gce.nix index 8910efa..587d5a6 100644 --- a/formats/gce.nix +++ b/formats/gce.nix @@ -1,5 +1,4 @@ -{ modulesPath, ... }: -{ +{modulesPath, ...}: { imports = [ "${toString modulesPath}/virtualisation/google-compute-image.nix" ]; diff --git a/formats/hyperv.nix b/formats/hyperv.nix index 91d6a63..94c924b 100644 --- a/formats/hyperv.nix +++ b/formats/hyperv.nix @@ -1,5 +1,4 @@ -{ modulesPath, ... }: -{ +{modulesPath, ...}: { imports = [ "${toString modulesPath}/virtualisation/hyperv-image.nix" ]; diff --git a/formats/install-iso-hyperv.nix b/formats/install-iso-hyperv.nix index 5cf89eb..30f1889 100644 --- a/formats/install-iso-hyperv.nix +++ b/formats/install-iso-hyperv.nix @@ -1,11 +1,15 @@ -{ config, lib, modulesPath, ... }: { + config, + lib, + modulesPath, + ... +}: { imports = [ "${toString modulesPath}/installer/cd-dvd/installation-cd-base.nix" ]; # override installation-cd-base and enable wpa and sshd start at boot - systemd.services.sshd.wantedBy = lib.mkForce [ "multi-user.target" ]; + systemd.services.sshd.wantedBy = lib.mkForce ["multi-user.target"]; virtualisation.hypervGuest.enable = true; formatAttr = "isoImage"; diff --git a/formats/install-iso.nix b/formats/install-iso.nix index c8acfb1..bc788b6 100644 --- a/formats/install-iso.nix +++ b/formats/install-iso.nix @@ -1,12 +1,16 @@ -{ config, lib, modulesPath, ... }: { + config, + lib, + modulesPath, + ... +}: { imports = [ "${toString modulesPath}/installer/cd-dvd/installation-cd-base.nix" ]; # override installation-cd-base and enable wpa and sshd start at boot - systemd.services.wpa_supplicant.wantedBy = lib.mkForce [ "multi-user.target" ]; - systemd.services.sshd.wantedBy = lib.mkForce [ "multi-user.target" ]; + systemd.services.wpa_supplicant.wantedBy = lib.mkForce ["multi-user.target"]; + systemd.services.sshd.wantedBy = lib.mkForce ["multi-user.target"]; formatAttr = "isoImage"; filename = "*.iso"; diff --git a/formats/iso.nix b/formats/iso.nix index 5362eac..a371618 100644 --- a/formats/iso.nix +++ b/formats/iso.nix @@ -1,5 +1,8 @@ -{ config, modulesPath, ... }: { + config, + modulesPath, + ... +}: { imports = [ "${toString modulesPath}/installer/cd-dvd/iso-image.nix" ]; diff --git a/formats/kexec-bundle.nix b/formats/kexec-bundle.nix index e2878d7..0be095a 100644 --- a/formats/kexec-bundle.nix +++ b/formats/kexec-bundle.nix @@ -1,6 +1,5 @@ -{ lib, ... }: -{ - imports = [ ./kexec.nix ]; +{lib, ...}: { + imports = [./kexec.nix]; formatAttr = lib.mkForce "kexec_bundle"; filename = lib.mkForce "*-kexec_bundle"; diff --git a/formats/kexec.nix b/formats/kexec.nix index 47878fb..ef17df3 100644 --- a/formats/kexec.nix +++ b/formats/kexec.nix @@ -1,11 +1,17 @@ -{ config, pkgs, lib, modulesPath, options, ... }: let - +{ + config, + pkgs, + lib, + modulesPath, + options, + ... +}: let clever-tests = builtins.fetchGit { url = "https://github.com/cleverca22/nix-tests"; rev = "a9a316ad89bfd791df4953c1a8b4e8ed77995a18"; # master on 2021-06-13 }; - inherit (import ../lib.nix { inherit lib options; }) maybe; + inherit (import ../lib.nix {inherit lib options;}) maybe; in { imports = [ "${toString modulesPath}/installer/netboot/netboot-minimal.nix" @@ -17,7 +23,10 @@ in { system.build = rec { kexec_tarball = maybe.mkForce (pkgs.callPackage "${toString modulesPath}/../lib/make-system-tarball.nix" { storeContents = [ - { object = config.system.build.kexec_script; symlink = "/kexec_nixos"; } + { + object = config.system.build.kexec_script; + symlink = "/kexec_nixos"; + } ]; contents = []; }); @@ -50,10 +59,11 @@ in { boot.loader.grub.enable = false; boot.kernelParams = [ - "console=ttyS0,115200" # allows certain forms of remote access, if the hardware is setup right - "panic=30" "boot.panic_on_fail" # reboot the machine upon fatal boot issues + "console=ttyS0,115200" # allows certain forms of remote access, if the hardware is setup right + "panic=30" + "boot.panic_on_fail" # reboot the machine upon fatal boot issues ]; - systemd.services.sshd.wantedBy = lib.mkForce [ "multi-user.target" ]; + systemd.services.sshd.wantedBy = lib.mkForce ["multi-user.target"]; networking.hostName = lib.mkDefault "kexec"; formatAttr = "kexec_tarball"; diff --git a/formats/kubevirt.nix b/formats/kubevirt.nix index b36d4e8..aff34c8 100644 --- a/formats/kubevirt.nix +++ b/formats/kubevirt.nix @@ -1,5 +1,4 @@ -{ modulesPath, ... }: -{ +{modulesPath, ...}: { imports = [ "${toString modulesPath}/virtualisation/kubevirt.nix" ]; diff --git a/formats/linode.nix b/formats/linode.nix index 8b62b26..75d31d6 100644 --- a/formats/linode.nix +++ b/formats/linode.nix @@ -1,5 +1,10 @@ -{ config, lib, pkgs, modulesPath, ... }: { + config, + lib, + pkgs, + modulesPath, + ... +}: { imports = [ "${toString modulesPath}/profiles/qemu-guest.nix" ]; @@ -23,7 +28,7 @@ autoResize = true; }; - swapDevices = [{ device = "/dev/sdb"; }]; + swapDevices = [{device = "/dev/sdb";}]; # Enable LISH and Linode booting w/ GRUB boot = { @@ -38,7 +43,7 @@ growPartition = true; # Set up LISH serial connection: - kernelParams = [ "console=ttyS0,19200n8" ]; + kernelParams = ["console=ttyS0,19200n8"]; loader = { # Increase timeout to allow LISH connection: diff --git a/formats/lxc-metadata.nix b/formats/lxc-metadata.nix index c50b78e..f0bed97 100644 --- a/formats/lxc-metadata.nix +++ b/formats/lxc-metadata.nix @@ -1,6 +1,9 @@ -{ config, pkgs, modulesPath, ... }: - { + config, + pkgs, + modulesPath, + ... +}: { imports = [ "${toString modulesPath}/virtualisation/lxc-container.nix" ]; @@ -8,4 +11,3 @@ formatAttr = "metadata"; filename = "*/tarball/*.tar.xz"; } - diff --git a/formats/lxc.nix b/formats/lxc.nix index cf62106..4a84ec6 100644 --- a/formats/lxc.nix +++ b/formats/lxc.nix @@ -1,6 +1,10 @@ -{ config, pkgs, lib, modulesPath, ... }: - { + config, + pkgs, + lib, + modulesPath, + ... +}: { imports = [ "${toString modulesPath}/virtualisation/lxc-container.nix" ]; diff --git a/formats/openstack.nix b/formats/openstack.nix index 670d29a..76405ca 100644 --- a/formats/openstack.nix +++ b/formats/openstack.nix @@ -1,11 +1,17 @@ -{ modulesPath, lib, ... }: -if lib.pathExists "${toString modulesPath}/../maintainers/scripts/openstack/nova-image.nix" then { +{ + modulesPath, + lib, + ... +}: +if lib.pathExists "${toString modulesPath}/../maintainers/scripts/openstack/nova-image.nix" +then { imports = [ "${toString modulesPath}/../maintainers/scripts/openstack/nova-image.nix" ]; formatAttr = "novaImage"; -} else { +} +else { imports = [ "${toString modulesPath}/../maintainers/scripts/openstack/openstack-image.nix" ]; diff --git a/formats/proxmox-lxc.nix b/formats/proxmox-lxc.nix index 3e7f0d9..2785931 100644 --- a/formats/proxmox-lxc.nix +++ b/formats/proxmox-lxc.nix @@ -1,5 +1,4 @@ -{ modulesPath, ... }: -{ +{modulesPath, ...}: { imports = [ "${toString modulesPath}/virtualisation/proxmox-lxc.nix" ]; diff --git a/formats/proxmox.nix b/formats/proxmox.nix index 58d599e..198aa14 100644 --- a/formats/proxmox.nix +++ b/formats/proxmox.nix @@ -1,5 +1,4 @@ -{ modulesPath, ... }: -{ +{modulesPath, ...}: { imports = [ "${toString modulesPath}/virtualisation/proxmox-image.nix" ]; diff --git a/formats/qcow.nix b/formats/qcow.nix index 308ab3e..e2f18d6 100644 --- a/formats/qcow.nix +++ b/formats/qcow.nix @@ -1,5 +1,10 @@ -{ config, lib, pkgs, modulesPath, ... }: { + config, + lib, + pkgs, + modulesPath, + ... +}: { # for virtio kernel drivers imports = [ "${toString modulesPath}/profiles/qemu-guest.nix" @@ -12,17 +17,16 @@ }; boot.growPartition = true; - boot.kernelParams = [ "console=ttyS0" ]; - boot.loader.grub.device = if (pkgs.stdenv.system == "x86_64-linux") then - (lib.mkDefault "/dev/vda") - else - (lib.mkDefault "nodev"); + boot.kernelParams = ["console=ttyS0"]; + boot.loader.grub.device = + if (pkgs.stdenv.system == "x86_64-linux") + then (lib.mkDefault "/dev/vda") + else (lib.mkDefault "nodev"); boot.loader.grub.efiSupport = lib.mkIf (pkgs.stdenv.system != "x86_64-linux") (lib.mkDefault true); boot.loader.grub.efiInstallAsRemovable = lib.mkIf (pkgs.stdenv.system != "x86_64-linux") (lib.mkDefault true); boot.loader.timeout = 0; - system.build.qcow = import "${toString modulesPath}/../lib/make-disk-image.nix" { inherit lib config pkgs; diskSize = 8192; diff --git a/formats/raw-efi.nix b/formats/raw-efi.nix index 697825b..c918c47 100644 --- a/formats/raw-efi.nix +++ b/formats/raw-efi.nix @@ -1,9 +1,14 @@ -{ config, lib, options, pkgs, modulesPath, ... }: - -let - inherit (import ../lib.nix { inherit lib options; }) maybe; +{ + config, + lib, + options, + pkgs, + modulesPath, + ... +}: let + inherit (import ../lib.nix {inherit lib options;}) maybe; in { - imports = [ ./raw.nix ]; + imports = [./raw.nix]; boot.loader.grub = { device = "nodev"; diff --git a/formats/raw.nix b/formats/raw.nix index ec15e4b..82ff737 100644 --- a/formats/raw.nix +++ b/formats/raw.nix @@ -1,5 +1,10 @@ -{ config, lib, pkgs, modulesPath, ... }: { + config, + lib, + pkgs, + modulesPath, + ... +}: { fileSystems."/" = { device = "/dev/disk/by-label/nixos"; autoResize = true; @@ -8,13 +13,12 @@ boot = { growPartition = true; - kernelParams = [ "console=ttyS0" ]; + kernelParams = ["console=ttyS0"]; loader.grub.device = lib.mkDefault "/dev/vda"; loader.timeout = lib.mkDefault 0; - initrd.availableKernelModules = [ "uas" ]; + initrd.availableKernelModules = ["uas"]; }; - system.build.raw = import "${toString modulesPath}/../lib/make-disk-image.nix" { inherit lib config pkgs; diskSize = "auto"; diff --git a/formats/sd-aarch64-installer.nix b/formats/sd-aarch64-installer.nix index a38a47d..c3597cf 100644 --- a/formats/sd-aarch64-installer.nix +++ b/formats/sd-aarch64-installer.nix @@ -1,5 +1,8 @@ -{ config, modulesPath, ... }: { + config, + modulesPath, + ... +}: { imports = [ "${toString modulesPath}/installer/sd-card/sd-image-aarch64-installer.nix" ]; diff --git a/formats/sd-aarch64.nix b/formats/sd-aarch64.nix index 7228948..53e5337 100644 --- a/formats/sd-aarch64.nix +++ b/formats/sd-aarch64.nix @@ -1,5 +1,10 @@ -{ config, lib, pkgs, modulesPath, ... }: { + config, + lib, + pkgs, + modulesPath, + ... +}: { imports = [ "${toString modulesPath}/installer/sd-card/sd-image-aarch64.nix" ]; diff --git a/formats/vagrant-virtualbox.nix b/formats/vagrant-virtualbox.nix index f4edcd2..53311c0 100644 --- a/formats/vagrant-virtualbox.nix +++ b/formats/vagrant-virtualbox.nix @@ -1,5 +1,4 @@ -{ modulesPath, ... }: -{ +{modulesPath, ...}: { imports = [ "${toString modulesPath}/virtualisation/vagrant-virtualbox-image.nix" ]; diff --git a/formats/virtualbox.nix b/formats/virtualbox.nix index 144d33c..38de997 100644 --- a/formats/virtualbox.nix +++ b/formats/virtualbox.nix @@ -1,5 +1,4 @@ -{ modulesPath, ... }: -{ +{modulesPath, ...}: { imports = [ "${toString modulesPath}/virtualisation/virtualbox-image.nix" ]; diff --git a/formats/vm-bootloader.nix b/formats/vm-bootloader.nix index eccfb04..a8d6388 100644 --- a/formats/vm-bootloader.nix +++ b/formats/vm-bootloader.nix @@ -1,5 +1,4 @@ -{ modulesPath, ... }: -{ +{modulesPath, ...}: { imports = [ ./vm.nix ]; diff --git a/formats/vm-nogui.nix b/formats/vm-nogui.nix index 449baf9..fda8bc9 100644 --- a/formats/vm-nogui.nix +++ b/formats/vm-nogui.nix @@ -1,5 +1,4 @@ -{ pkgs, ... }: -let +{pkgs, ...}: let resize = pkgs.writeScriptBin "resize" '' if [ -e /dev/tty ]; then old=$(stty -g) @@ -15,8 +14,8 @@ in { ./vm.nix ]; virtualisation.graphics = false; - virtualisation.qemu.options = [ "-serial mon:stdio" ]; + virtualisation.qemu.options = ["-serial mon:stdio"]; - environment.systemPackages = [ resize ]; + environment.systemPackages = [resize]; environment.loginShellInit = "${resize}/bin/resize"; } diff --git a/formats/vm.nix b/formats/vm.nix index ecd07a6..7474f4e 100644 --- a/formats/vm.nix +++ b/formats/vm.nix @@ -1,5 +1,4 @@ -{ modulesPath, ... }: -{ +{modulesPath, ...}: { imports = [ "${toString modulesPath}/virtualisation/qemu-vm.nix" ]; diff --git a/formats/vmware.nix b/formats/vmware.nix index a52e871..a583d5c 100644 --- a/formats/vmware.nix +++ b/formats/vmware.nix @@ -1,5 +1,4 @@ -{ modulesPath, ... }: -{ +{modulesPath, ...}: { imports = [ "${toString modulesPath}/virtualisation/vmware-image.nix" ]; diff --git a/nixos-generate.nix b/nixos-generate.nix index 6f0c2e2..fddec9e 100644 --- a/nixos-generate.nix +++ b/nixos-generate.nix @@ -1,22 +1,21 @@ -{ nixpkgs ? -, configuration ? -, system ? builtins.currentSystem - -, formatConfig - -, flakeUri ? null -, flakeAttr ? null -}: -let +{ + nixpkgs ? , + configuration ? , + system ? builtins.currentSystem, + formatConfig, + flakeUri ? null, + flakeAttr ? null, +}: let module = import ./format-module.nix; # Will only get evaluated when used, so no worries flake = builtins.getFlake flakeUri; flakeSystem = flake.outputs.packages."${system}".nixosConfigurations."${flakeAttr}" or flake.outputs.nixosConfigurations."${flakeAttr}"; in - if flakeUri != null then + if flakeUri != null + then flakeSystem.extendModules { - modules = [ module formatConfig ]; + modules = [module formatConfig]; } else import "${toString nixpkgs}/nixos/lib/eval-config.nix" { diff --git a/shell.nix b/shell.nix index 99ea674..bfaa887 100644 --- a/shell.nix +++ b/shell.nix @@ -1,3 +1,5 @@ (import (builtins.fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) { src = ./.; -}).shellNix.default +}) +.shellNix +.default